t-bud Posted March 9, 2022 Share Posted March 9, 2022 (edited) 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 March 9, 2022 by t-bud Insert code instead of attachment Quote Link to comment
t-bud Posted April 6, 2022 Author Share Posted April 6, 2022 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 Quote Link to comment
Vectorworks, Inc Employee klinzey Posted April 6, 2022 Vectorworks, Inc Employee Share Posted April 6, 2022 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 Quote Link to comment
t-bud Posted April 6, 2022 Author Share Posted April 6, 2022 It may not be proper, I found just putting the new Symbol Name string into just the Symbol Definition field also works. 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.