Phsion Posted January 9, 2022 Share Posted January 9, 2022 Hi all, I'm updating Lighting Device properties via a script and the changes aren't sticking. I can see the updated values in the Object Info panel when I click on the objects, but as soon as I refresh the objects, or call vs.ResetObject(), the Object parameters change to what they we're before. The code below loops over every "Lighting Device" in the document, checks if the channel field matches one stored in a dict, then updates each parameter from the dict. vs.ForEachObject( update_from_data, "( (PON='LIGHTING DEVICE') )") def update_from_data(h): objinfo = vs.GetCustomObjectInfo(h) recordHandle = vs.GetParametricRecord(h) recname = vs.GetName(recordHandle) local_fixnum = vs.GetRField(h, recname, "channel") local_vwid = vs.GetRField(h, recname, "uid") if True: # update by channel for fixnum in import_fix_list_chan: if fixnum == local_fixnum: settings.message_append("TEST PASSED" + str(fixnum) + " " + str(local_fixnum)) set_fixture_data(h,recname,import_fix_list_chan[fixnum]) def set_fixture_data(h, recname, fixdic): for key, val in fixture.parameters_for_import.items(): if val and key: #data = getattr(self, key, data) data = fixdic[key] settings.message_append("(" + val + " = " + str(data) + ")") vs.SetRField(h, recname, val, data) Quote Link to comment
JBenghiat Posted January 9, 2022 Share Posted January 9, 2022 What data are you updating? Some parameters are actually calculated from other data, so you can't set them explicitly. Also, you should call ResetObject() from the script. Quote Link to comment
Jayme McColgan Posted January 9, 2022 Share Posted January 9, 2022 I'm not in front of my computer to test but I often have to use the vs.refreshlightingdevice() command (I think that’s the name) when working with lighting devices. Quote Link to comment
Phsion Posted January 11, 2022 Author Share Posted January 11, 2022 Thanks for the responses! @JBenghiatI'm updating a variety of fields, but mostly setting the Universe and DMX Address. I wouldn't assume those would be calculated? And not calling vs.ResetObject after updating each Lighting Device lets me see that the new parameter values are shown in the Object Info, until I use the menu command to Refresh Lighting Devices. Otherwise, the parameters are cleared before I can look in the Object Info. @Jayme McColgan I don't see that function anywhere? I've looked in the Function Reference wiki and vs.py in the SDK Quote Link to comment
Jesse Cogswell Posted January 11, 2022 Share Posted January 11, 2022 (edited) @Phsion The command you are looking for is vs.LDevice_Reset, though I just ran a little test changing a fixture's DMX address and was able to get it to stick with either LDevice_Reset or ResetObject (at least with Vectorscript). Not sure which version you are in, but Vectorworks now updates all related address fields when one field changes. For example, if you change the UniverseAddress field, it will automatically update Universe, DMX Address, and Absolute Address. EDIT: I just did a test in Python on VW2020, VW2021, and VW2022 with the following code and it was able to make changes stick. def ChangeAddress(h): vs.SetRField(h,'Lighting Device','UniverseAddress','2/101') vs.ResetObject(h) vs.ForEachObject(ChangeAddress,("((SEL=TRUE) & (R in ['Lighting Device']))")) I tried commenting out the vs.ResetObject(h) line, the fields in the OIP wouldn't immediately change, but if I deselected and reselected the fixture, the proper values would be in the OIP. Clicking the Refresh Labels button in the OIP to force a reset on the Lighting Device pushed the new values to the symbol. Edited January 11, 2022 by Jesse Cogswell Quote Link to comment
Jayme McColgan Posted January 12, 2022 Share Posted January 12, 2022 @Phsion here are the commands i was talking about: vs.LDevice_ResetVisual() vs.LDevice_Reset() Quote Link to comment
Phsion Posted January 13, 2022 Author Share Posted January 13, 2022 Thanks for all the help, figured it out. @JBenghiat was right, but not in anyway I was expecting! I was changing DMX Address and Universe fields and watching them, but it turns out Vectorworks calculates the separate DMX and Universe fields from the Universe/Address string. Setting the unique fields appears to work until a refresh, then they're recalculated from the Universe/Address field 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.