Jump to content

MultiParm - oncreate script


Annon

Recommended Posts

Urghh, scripting is not my strong suit...

 

I'm trying to set some parameters on creation, I can do them after creation, but can't initialize them straight away, this is what I currently have, which works if I just call force(), but not calling it on creation.

def force():    
    hou.pwd().cook(True)
    hou.pwd().parm("name1").set("density")
    hou.pwd().parm("name2").set("temperature")

With an "oncreated" handler with this in it:

kwargs['node'].hdaModule().force()

#stuck

Link to comment
Share on other sites

Guest mantragora

Try to pass

kwargs['node']
also to fucnction and replace

 

hou.pwd()
with this passed parameter. Edited by mantragora
Link to comment
Share on other sites

Thanks, that didn't seem to work.

I've now just disabled everything by default making the user initialize the node to get the right settings, instead of setting a default on creation.

If anyone can see away around this I'd love to know though.

Thanks

Christian

Link to comment
Share on other sites

Guest mantragora

Another thing you may do is to supply node creation scripts in your

$HOME/HoudiniX.XXX/scripts/
folder.

For example, if you want to have groupSOP always to start with $OS expression in group name field, you can create in this scripts directory

$HOME/HoudiniX.XXX/scripts/sop/group.py
and the in this file set it by writing

kwargs['node'].parm('crname').set('$OS')
Link to comment
Share on other sites

To be absolutely safe, you need to:

- Set the multiparm to the number of instances that you want

- Then *evaluate* the parameter to force it to create the instances

- Now the multiparm instances should exist

- Call cook() last, although I'm not sure why you need it.

Link to comment
Share on other sites

Ok thanks guys, I got around this particular issue but not in a scripty way ;)

I am hitting the same issue somewhere else though. So I am creating some children nodes on creation, which works fine and I'm using node.layoutChildren() etc to try to give them a good place to create them. But ideally what I'd like to do is get the position of the node and move them exactly where I want, but you can't get the position until the node exists etc so it just returns [0, 0].

 

Is there a way of getting around this, or am I to just live with it?

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