Jump to content

ROP Network with Conditional String


gemini

Recommended Posts

Hi,

I have a simple problem with this python code ( part of a larger script ). It creates a rop network, opens a stored preset for it. And changes a parameter label.

It works. What is wrong that the script clears the conditional string of the rop network. Does anyone has an idea ?

Thanks in advance ! 

G

 

The script :


rop = hou.node('/obj').createNode('ropnet')
drop_preset_name = 'dROP2'

op_path = rop.path()

cmd = 'oppresetload %s "%s"' % (op_path, drop_preset_name)
hou.hscript(cmd)

# set the active toggle label as sim and as render , with version
is_sim = rop.userData( 'is_sim')
parm_obj = rop
ptg = parm_obj.parmTemplateGroup()
parmname = 'active'
pt = ptg.find( parmname)
if is_sim == '1':
    rop.parm('issimtoggle').set(1)
    pt.setLabel('Active / [ SIM ]  /  '+self.version)
elif is_sim == '0':
    rop.parm('issimtoggle').set(0)
    pt.setLabel('Active / [ RENDER ]  /  '+self.version)
ptg.replace( parmname, pt)
parm_obj.setParmTemplateGroup(ptg)

 

 

Link to comment
Share on other sites

I would guess that it is going to clear the user data because you are creating a new node each time. What if you check if the rop exists and fetch the node rather than creating it each time. Then your UserData might persist.

I'm just guessing at the name generated by the create node, you may have to control the name by specifying it directly upon creation.

rop = hou.node('/obj/ropnet1')
if rop == None:
	rop = hou.node('/obj').createNode('ropnet', 'ropnet1')

 

Edited by Atom
Link to comment
Share on other sites

THX , but sadly not.

These lines clearing the conditional string:

ptg = parm_obj.parmTemplateGroup()
parmname = 'active'
pt = ptg.find( parmname)
ptg.replace( parmname, pt)
parm_obj.setParmTemplateGroup(ptg)

 

It seems like a bug. Isn't it ?

Edited by gemini
Link to comment
Share on other sites

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.   Paste as plain text instead

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