Jump to content

vs.SetRField changes not "sticking"


Recommended Posts

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)

 

Link to comment

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

Link to comment

@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 by Jesse Cogswell
Link to comment

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

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