Jump to content
Developer Wiki and Function Reference Links ×

Store All Symbol Names in Resource Manager To Popup OIP


Recommended Posts

Hello all, I am trying to gather all Symbol Names that have Record "x" attached to them in my file and store them to a Popup Menu in the OIP. I am a little stumped on the vsoWidgetPopupAdd that keeps throwing an error. Any ideas?

 

result:=GetCustomObjectInfo(objName,objHd,recHd,wallHd);

	vsoGetEventInfo(theEvent, theButton);
    CASE theEvent OF
		kObjOnInitXProperties:	{OIP STARTS UP }
			BEGIN
				result:=SetObjPropVS(kObjXPropHasUIOverride,TRUE);				{Enables OIP to be overriden}
				result:=SetObjPropVS(kWidgetButton,TRUE);						{Enables buttons in the OIP}
				result:=vsoInsertAllParams;									{Adds all 'non-hidden' params into the OIP}
				
			
				result:=vsoInsertWidget(2,kWidgetPopup,kSeparator1ID,'Tile',0);
				result:=vsoWidgetPopupClear(2);
				result:=vsoInsertWidget(1,8,kSeparator1ID,'LED 2',0);
				result:=vsoWidgetPopupAdd(kSeparator1ID,0,'LED Tile 1');

 

Link to comment

@stevenmorgan94

First off, what error are you getting? I assume you are getting syntax errors because vsoWidgetPopupClear(), and vsoWidgetPopupAdd() are not functions. They don't return values. If you're getting other errors, it might help to know what they are.

 

Secondly, build your OIP with an empty popup widget to make sure you have all your widgets in place – sans errors.

Then, you can add the symbol names to the popup in a loop. Something like this:

vsoWidgetPopupClear(2);
I := 1;
SymNam := GetSymNameWithRec(I);		{ user defined function }
while (SymNam <> '') do begin
	vsoWidgetPopupAdd(2, SymNam, SymNam);
	I := I + 1;
	SymNam := GetSymNameWithRec(I);
end;		{ for }

 

Raymond

Link to comment

Thank you both so much this works great. I'm a little hung up on the function to filter out by Record Name. If I replace GetSymNameWithRec in the loop with GetNameFomResourceList directly it works for troubleshooting sake. 

 

I'm able to loop through all the Symbols and add their names into the Popup. 

 

I know I need to take the INT in to find the corresponding NameFromResource list, I'm just not sure how to add a "IF R IN['LED_TILE']" argument. 

 

Thanks again

 

FUNCTION GetSymNameWithRec(i1:INTEGER):INTEGER;
BEGIN
	{ Filter Params }
	Symbol(((T=SYMBOL) & (R IN ['LED_Tile'])));

    { Currently works if used to replace function }
	GetNameFromResourceList(List1,i1);
END;

{ ======== RUN SCRIPT ======== }

BEGIN

	result:=GetCustomObjectInfo(objName,objHd,recHd,wallHd);

	vsoGetEventInfo(theEvent, theButton);
    CASE theEvent OF
		kObjOnInitXProperties:	{OIP STARTS UP }
			BEGIN
				result:=SetObjPropVS(kObjXPropHasUIOverride,TRUE);		{Enables OIP to be overriden}
				result:=SetObjPropVS(kWidgetButton,TRUE);				{Enables buttons in the OIP}
				result:=vsoInsertAllParams;								{Adds all 'non-hidden' params into the OIP}
				
				vsoWidgetPopupClear(1);

				List1:=BuildResourceList(16, 0, '', NumItems);
				
				I := 1;
				SymNam := GetSymNameWithRec(I);		{ user defined function }
				WHILE (SymNam <> '') DO BEGIN
					vsoWidgetPopupAdd(1, SymNam, SymNam);
					I := I + 1;
					SymNam := GetSymNameWithRec(I);
				END;

 

Link to comment

Are you aware of the VectorScript function reference? https://developer.vectorworks.net
 

Symbol() won’t help you at all — it places a new symbol in then drawing, and does not accept a criteria as a parameter. 
 

If you want to use criteria, I think Eval() should work. You need to get the handle of the resource in the list, check if the record is attached, and if so return the name, otherwise return an empty string. Otherwise, the check involves getting the number of records attached to the symbol, getting a handle to the record by index, and checking if the name matches. 
 

For a function to return a value in VS, set the name of the function to the value (you are not returning anything here). 
 

Also, your while loop will stop as soon as you a counter a symbol without your desired record attached. Instead, consider getting the number of resources in the list and using a for loop. 

Link to comment

Thanks Joshua, I'll give Eval a shot I hadn't come across that in the docs before, very new to this so I appreciate the help.

 

For an overview the goal of the script is to:

1) Search all symbols in the Resource Manager that have attatched Record "LED"

2) Store all those Symbol Names to the Popup

3) The popup allows easily switching the symbol via the populated list

 

Hopefully I'm going about it the right way currently.

 

 

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...