justin1974 Posted December 13, 2002 Share Posted December 13, 2002 I'm just starting to learn Vectorscript, I'm using version 9.5, there doesn't seem to be much in the user manual, a little in the help menu on how it works, is there any tutorial books out there. I've had success in making some quite complex 3d kitchen joinery, with many varaibles. I have some quite simple questions if anyone can answer them; Whats the best way to use parameters set by pop-up menus? To give something a set line colour and thickness it needs a handle corret?. how do I give something a handle?. Does each object have to have its own handle? Can I give a group a handle?. Can I give objects dotted linestyles?. Quote Link to comment
joiner Posted December 13, 2002 Share Posted December 13, 2002 use h:=LNewObj; to get the handle of the most recently craeted object. look in you vectorscript function reference: Document/List handling for like functions. if you are doing kitchens i would use the NameClass function inside your script. this will both create and assign a class to all following objects until you've named another class. this way you can manipulate colors, line weights outside of the script. i think you'll find this more flexible. -jason Quote Link to comment
Kristen Posted December 13, 2002 Share Posted December 13, 2002 Someday I want to learn how to use VectorScript, too. It looks like there's pretty good information at http://nemetschek.net/support/custom/vscript/vsdex.html but I haven't really had time to delve into it yet. I think some of it might be specific to VW10, but some of it should be good for VW9, too. Let me know if it's actually worth using Quote Link to comment
justin1974 Posted December 14, 2002 Author Share Posted December 14, 2002 Thank you both for the info. Joiner, I want to have multiple line style and types. I've done enough drawing to know that I want secondary lines to be grey dotted and .05mm line weight . Can I set this up?. Quote Link to comment
MullinRJ Posted December 14, 2002 Share Posted December 14, 2002 justin1974, There is very little you can't do with VectorScript. On the flip side, the really intricate stuff can take a good while to develop. << Does each object have to have its own handle? >> Yes, actually, each object already has a handle which is nothing more than a unique number (an internal address) that is maintained by the software. Your program needs to get handles to the objects before you can do anything to those objects with the VS handle calls. Think of each object on a layer as stacked one on top of another, until you get to the last object created, which is on top of all the others on that layer. It doesn't have to be drawn on top of anything else, but a list of each object is maintained, and that list is ordered. Each layer is actually a doubly-linked list of objects. That means if you have the handle to any object in the list then you can get the handle to the Previous and/or Next object in the list. A CAD file is a giant list of lists. Getting a handle to an object is easy, but knowing what object you have a handle to requires a little care. To get a handle in your program, consider using one of the following commands where 'hnd' is a variable declared as 'HANDLE'. VAR hnd : HANDLE; hnd := FSActLayer; { this is how it's used. } FSActLayer - very popular, gets handle to the First Selected object on the Active Layer. FActLayer - gets handle to the First object on the Active Layer , selected or not. LSActLayer - gets handle to the Last Selected object on the Active Layer. LActLayer - gets handle to the Last object on the Active Layer , selected or not. LNewObj {This one is also very useful as it returns a handle to the Last newly created object on the layer } To get the NEXT or PREVIOUS object in the list, use NextObj or PrevObj respectively. hnd := NextObj(hnd); { This is how it is used } Notice that 'hnd' is passed as an argument to NextObj as that tells NextObj what list you are in and which way you want to go. NEXT takes you toward the top (end) of the list, and PREV takes you to the bottom (front) of the list. When you run out of objects in the list you are traversing NextObj and PrevObj will return the value NIL (a fancy name for zero) to indicate there are no more objects. Further calls to NextObj or PrevObj will result in a runtime error. continued... Quote Link to comment
MullinRJ Posted December 14, 2002 Share Posted December 14, 2002 If you haven't already seen one yet, here is a simple loop that will traverse a list of selected objects on the active layer. The I variable is incremented each time through the loop and displayed in a Message at the end. ************** Procedure ListWalk; VAR hnd : Handle; I :Integer; BEGIN I := 0; { initialize counter } hnd := FSActLayer; { get first object in list } while (hnd <> nil) do begin { test for end of list here } { do things of interest here } I := I + 1; hnd := NextSObj(hnd); { get next Selected object in list } end; { while } If (I=1) then Message ('There is 1 selected object on this layer.') else Message ('There are ', I, ' selected objects on this layer.'); END; Run (ListWalk); ************** continued... Quote Link to comment
MullinRJ Posted December 14, 2002 Share Posted December 14, 2002 << Can I give a group a handle? >> A GROUP is just another object, but it contains objects within it. You can ascertain an objects type by using the GETTYPE(hnd :Handle) function. It will return an integer representing the type of the object currently pointed to by the variable 'hnd'. Group is #11 in the list of object types. The numbers are listed in << Can I give objects dotted linestyles? >> Once you have a handle to your line, set line style and weight using: SetLS (hnd : Handle; LS : Integer); { sets line pattern, LS is between 0 & 71 } SetLS (hnd : Handle; LS : Integer); { sets line style, LS is between -8 & -1 } SetLW (hnd : Handle; LW : Integer); { sets line weight, LW is between 0 & 255 } SetPenFore (hnd : Handle; R,G,B : Longint); { sets foreground line color, R,G,B are between 0 & 65535 } SetPenBack (hnd : Handle; R,G,B : Longint); { sets background line color, R,G,B are between 0 & 65535 and is needed for PATTERNED lines } As you get comfortable getting handles to objects in lists, try using the procedures ForEachObject, ForEachObjectInLayer, & ForEachObjectInList. They will save you a lot of programming if you want to find objects that may be nested in groups or symbols. Though they may be hard to learn at first, you need only come back to this board for even longer diatribes on the subject. Have fun programming. HTH, Raymond PS - If you haven't downloaded the VS Function Reference guide you need to do so. Pick your flavor, Mac or PC, on page Documentation. Quote Link to comment
joiner Posted December 16, 2002 Share Posted December 16, 2002 it looks like you've gotten all your answers except reagrding pop-up menus. when a choice item is selected from either a pop-up, or radio buttons it returns the value into the script as a STRING variable. this can then be used to define other parameters through a conditional statement. if the actual STRING/TEXT isn't what you are after. example. where Choice is the name of your pop-up field: and on is a BOOLEAN. IF PChoice ='Pick Me' THEN on:=TRUE ELSE on:=FALSE hope this helps. also, when Vectorworks 8.5 came out it came with a great book called "Custom Solutions in Vectorworks" if you can track down one of these copies I think you will find it useful. -jason Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.