Jump to content
Developer Wiki and Function Reference Links ×

Retrieving the names of all objects (plugin, text, line etc)


Recommended Posts

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 by hippothamus
Link to comment

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 by hippothamus
Link to comment

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

Link to comment
  • Vectorworks, Inc Employee

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

Link to comment
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 by hippothamus
Link to comment

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 by MullinRJ
Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...