Jump to content

Spotlight - Changing symbol with script not working in VW22


Recommended Posts

I have scripts that I have used for years, that change the symbol of Lighting Devices within the process of the script.  They are no longer working properly in VW 2022.

I am using SP2.1 on a Mac running OS 10.15.7 (Catalina).

 

The attached script should change the selected units to a 14deg unit.  The symbol for the 14deg is in the resource manager, and you can see with the debug, that the field value for the 'Symbol Name' has been changed, but it remains the old symbol upon completion.  However, the drawing is not updated, and in the OIP the symbol name remains unchanged, or is internally reverted back to its previous string.

 

What has changed in VW22, that this doesn't work anymore?  Is there a 'Proper" procedure that I am not using with Lighting Devices?

PROCEDURE ChangeSym;
{$DEBUG}
VAR
	SymNameStart, SymNameEnd	:STRING;
PROCEDURE replaceSymbol(objectHandle	:HANDLE);

BEGIN
	SymNameStart := GetRField(objectHandle, 'Lighting Device','Symbol Name');
	SetRField(objectHandle,'Lighting Device', 'Symbol Name', 'Light Instr Prolights EclipseFS 14deg');

	LDevice_Reset(objectHandle);	

	SymNameEnd := GetRField(objectHandle, 'Lighting Device','Symbol Name');
END;

BEGIN
	ForEachObject(replaceSymbol,Sel = TRUE);

END;

RUN(ChangeSym);

 

Edited by t-bud
Insert code instead of attachment
Link to comment
  • 4 weeks later...

I finally got a response from Support in regards to this issue.  Thanks to a friendly Beta tester, for poking them about this, since their only response to me was to look here for custom scripts.

 

Here is the response from support, that was helpful.

 

Quote

 Instead of changing the symbol name the user must now change the "Symbol Definition" parameter, lighting device symbols now rely purely on symbol internal indexes. Instead of symbol name the user should use the InternalIndex of the symbol. This can be found easily using the "Name2Index" function: https://developer.vectorworks.net/index.php/VS:Name2Index

 

Link to comment
  • Vectorworks, Inc Employee

I looks like you need to change both the "Symbol Definition" parameter and the "Symbol Name" parameter.
You should also call ApplyLightInfoRecord() if you want to update the lighting device with the record information from the new symbol.
Here is a sample script with a test file.

 

PROCEDURE ChangeSym;
VAR
    SymNameStart, SymNameEnd    :STRING;
PROCEDURE replaceSymbol(objectHandle    :HANDLE);

BEGIN
    SymNameStart := GetRField(objectHandle, 'Lighting Device','Symbol Name');
    If SymNameStart = 'Light Instr ETC Source 4 26deg'
        THEN
        SymNameEnd := 'Light Instr ETC Source 4 50deg'
        ELSE
        SymNameEnd := 'Light Instr ETC Source 4 26deg';
    SetRField(objectHandle,'Lighting Device', 'Symbol Name', SymNameEnd);
    SetRField(objectHandle,'Lighting Device', 'Symbol Definition', Concat(Name2Index(SymNameEnd)));
    ApplyLightInfoRecord(GetObject(SymNameEnd),objectHandle);
    ResetObject(objectHandle);    

    SymNameEnd := GetRField(objectHandle, 'Lighting Device','Symbol Name');
END;

BEGIN
    ForEachObject(replaceSymbol,Sel = TRUE);

END;

RUN(ChangeSym);

 

One Light 2022.vwx

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