Jump to content
Sign in to follow this  
gemini

ROP Network with Conditional String

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)

 

 

Share this post


Link to post
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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×