zuken86 Posted January 23, 2013 Share Posted January 23, 2013 I wrote a simply script using ForEachObject and would like to apply it only to a few objects selected on screen. What do I use to retrieve a group of selected objects? Thanks, Quote Link to comment
Vectorworks, Inc Employee Matt Panzer Posted January 23, 2013 Vectorworks, Inc Employee Share Posted January 23, 2013 Take a look at ForEachObjectInList. This should have options to do what you want. I'd expand on this farther, but I'm on my way out the door. Quote Link to comment
zuken86 Posted January 23, 2013 Author Share Posted January 23, 2013 Thanks. How do you pass a selected (highlighted) object to a HANDLE variable. I am a bit confused on h:HANDLE; h:=FSActLayer; I think FSActLayer only return the most recent object and not an object that I actually want to select. Thanks, Quote Link to comment
Miguel Barrera Posted January 23, 2013 Share Posted January 23, 2013 FSActLayer = First Selected object in the Active Layer Quote Link to comment
Pat Stanford Posted January 24, 2013 Share Posted January 24, 2013 You can use ForEachObject and then make the first step of your called procedure a test to see if the object is selected and only process it if it is. Or you could do as Matt suggested and use ForEachObjectInList so the called function will only get handles to the objects that are selected. Or you can just set up a loop and use FsActLayer and deselect the processed abject at the bottom of the loop. When FSActLayer returns a nil handle you have processed all the objects (on the active layer). Really depends on what you are trying to do.. Quote Link to comment
zuken Posted January 24, 2013 Share Posted January 24, 2013 I am trying to create a script to select multiple instances of a selected symbol by name in the active design layer. This is what I have so far but I am missing something. PROCEDURE SelectSameSymbol; VAR h:HANDLE; name:STRING; BEGIN h:=ActSymDef; {How do I pass a selected symbol to h?} name:=GetSDName(h); SelectObj(S=name); END; RUN(SelectSameSymbol); Thanks, Quote Link to comment
Pat Stanford Posted January 24, 2013 Share Posted January 24, 2013 So you want to select a single instance of the symbol and have the script select all the instances of the same symbol? Something like this should work. I have not run this so there may be some errors. PROCEDURE SelectSameSymbol; VAR h:HANDLE; name:STRING; BEGIN h:=FSActLayer; name:=GetSymName(h); DSelectAll; SelectObj(S=name); END; RUN(SelectSameSymbol); There used to be some kind of an issue with setting criteria using variables. The work around was to set the entire criteria to a string variable and then just put that single variable into the function/procedure that needed the criteria. Quote Link to comment
zuken86 Posted January 25, 2013 Author Share Posted January 25, 2013 Thanks Pat. DSelectAll does the trick. Quote Link to comment
zuken86 Posted April 12, 2013 Author Share Posted April 12, 2013 I created a rectangle and a series of oval using Vectorscript. I wanted to clip surface but I can't seem to make it work. I think it has something to do with the last too lines in my code SelectObj((T=RECT) AND (T=OVAL)); DoMenuTextByName('Clip Surface',0); Did I do something wrong? Thanks, Quote Link to comment
MullinRJ Posted April 14, 2013 Share Posted April 14, 2013 Short answer: Use OR instead of AND. Longwinded answer: SelectObj() is going through a list of objects one at a time and selecting any object that meets, in your case, both criteria (Rect AND Oval). Since an object cannot be a RECT and and OVAL at the same time, you want the OR operator, instead of the AND operator. You want to select any object that is either a RECT OR an OVAL. This will work for selecting all RECTs and OVALs: SelectObj((T=RECT) OR (T=OVAL)); Raymond 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.