Hippocode Posted March 15, 2012 Share Posted March 15, 2012 (edited) Hello, I've made a script to select ALL symbols in a layer, where atleast one of them is allready selected. I'd like to extend it for other objects(plugin, line, text etc) but I fail at getting the names of the selected objects. I know i'll have to change the selection part, but I just need to find a way to get the selected objects info PROCEDURE SelectObjects; VAR OCount,i,j: INTEGER; r, g, b :LONGINT; OName,OName2,OName3,strinkie,test,selectie :STRING; ONames : DYNARRAY[] of STRING; FUNCTION SelectThem(h :HANDLE) :BOOLEAN; BEGIN OName := GetSymName(h); IF OName ='' THEN BEGIN OName := GetName(h); {can't get the object name ?} END; ONames:=OName; i:=i+1; END; BEGIN selectie:='Geselecteerde symbolen: '; OCount:=NumSelectedObjects; IF OCount<2 THEN OCount:=2; i:=1; ALLOCATE ONames [1..OCount]; ForEachObjectInLayer(SelectThem, 2, 0, 0); SortArray(ONames,OCount,1); DSelectAll; FOR j:=1 TO OCount DO BEGIN IF OName2<>ONames[j] THEN BEGIN strinkie:=concat(ONames[j]); OName2:=strinkie; SelectObj((S=strinkie)); selectie:=concat(selectie,strinkie,', '); END; END; AlrtDialog(selectie); END; RUN(SelectObjects); Edited March 15, 2012 by hippothamus Quote Link to comment
Hippocode Posted March 15, 2012 Author Share Posted March 15, 2012 I know I can retrieve the type with GetType(h); and change the selection code to retrieve all " lines " etc. But I still can't get the objects Quote Link to comment
Hippocode Posted March 15, 2012 Author Share Posted March 15, 2012 (edited) In best case, GetName(h) was able to return "none" which indicates the plugin object has no name. The same result with custom and standard plugin objects while they do have a "name" or lets say a "title" in the object info palette. Its that value I need in order to select the object. Anyone ? Edited March 15, 2012 by hippothamus Quote Link to comment
JBenghiat Posted March 15, 2012 Share Posted March 15, 2012 You're mixing up terminology a bit, so I'm not entirely sure what you are after. An "object" is anything in the drawing. A "Name" is a unique identifier for a drawing object, which you manually set in the data pane of object info. I think what you're after is the Plug-in name of a Plug-In Object (PIO). You can get the name of the PIO's data record -- GetName(GetRecord(h, 1)). Your selection criteria, would use PON=. -Josh Quote Link to comment
Hippocode Posted March 15, 2012 Author Share Posted March 15, 2012 I think what you're after is the Plug-in name of a Plug-In Object (PIO). You can get the name of the PIO's data record -- GetName(GetRecord(h, 1)). Your selection criteria, would use PON=. -Josh Ah, exactly what I was looking for, thanks. Quote Link to comment
JBenghiat Posted March 15, 2012 Share Posted March 15, 2012 Forgot to mention -- just to make sure you're not reinventing the wheel, have you checked out the select similar tool? -Josh Quote Link to comment
Vectorworks, Inc Employee klinzey Posted March 15, 2012 Vectorworks, Inc Employee Share Posted March 15, 2012 For Plugin objects you would need to do something like: If GetType(h) = 86 then PIO := GetName(GetParametricRecord(h)) Quote Link to comment
Vectorworks, Inc Employee klinzey Posted March 15, 2012 Vectorworks, Inc Employee Share Posted March 15, 2012 You can get the name of the PIO's data record -- GetName(GetRecord(h, 1)). -Josh Josh, If you use the record method it's not the first record, it would be the last. It should be GetName(GetRecord(h, NumRecords(h))) If you manually attach a record to an object you will get the name of that record and not the name of the PIO if you check the first record. Kevin Quote Link to comment
Hippocode Posted March 15, 2012 Author Share Posted March 15, 2012 (edited) Forgot to mention -- just to make sure you're not reinventing the wheel, have you checked out the select similar tool? -Josh The select similar tool is different as it will select ALL possible symbols when clicking on one. The tool I made will only select the "kind" of symbols I select. If I want to change All my lights named L1, I just need to click one and the script will select all placed L1 symbols in the layer. Select similar tool would select all symbols instead. If not, i'm a fool. (edit: never noticed the tool properties could be changed. Thus i'm a fool lol, good practice though.) As a sidenote I ran into another problem. when trying to select the basic objects ( text, line ) the command doesn't respond, even if the string is right. t_temp:=concat(BNames[j]); {this returns Text} UprString(t_temp); {make it TEXT} test:=concat('T=',t_temp); {create T=TEXT to select all text objects} SelectObj((test)); {no text gets selected ?} Edited March 15, 2012 by hippothamus Quote Link to comment
maarten. Posted March 15, 2012 Share Posted March 15, 2012 The "Select similar" tool can do this. Click on the settings button in the Mode Bar and choose "Symbol name" in the "Others" group box. Quote Link to comment
MullinRJ Posted March 16, 2012 Share Posted March 16, 2012 (edited) Too many parentheses. Try: SelectObj(test); { selects all text objects } If you want extra parentheses, put them in your concat statement: S := concat('(T=', S, ')'); { create (T=TEXT) to select all text objects } SelectObj(S); { selects all text objects } Raymond Edited March 16, 2012 by MullinRJ 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.