Jump to content

Editing Parameter Interface with Python


RuschFX

Recommended Posts

I'm writing a python script that populates geometry nodes and edits each node's parameter interface, and I've ran into a few problems. I'm new at python so forgive me. I have been able to create new folder tabs and populate them with float parameters fairly easily. This is what I used to create one of the float parameters......

partTemplate = hou.FloatParmTemplate("timeOffset", ("Time Offset"), 1, default_value=([0]), min=-10, max=10, min_is_strict=False, max_is_strict=False, look=hou.parmLook.Regular, naming_scheme=hou.parmNamingScheme.Base1, disable_when="", tags={})
hou.node('/obj/geometry1').addSpareParmTuple(partTemplate, in_folder=([character1]), create_missing_folders=True)

The problem is I also need file and integer parameters....... The commands I'm pretty sure I need are hou.FileReferenceParmTemplate() and hou.IntParmTemplate(). I can't get them to work and the help says they haven't been implemented yet!? Can anybody hook me up with a script example of how to successfully add these parameters or know of a work around? Thanks in advance for any help your able to give......

- Jake R

Link to comment
Share on other sites

ok..... just shortly after I posted this, I ran hou.asCode() on a node I manually built and figured out how to get file and int parameters to work. :) So I figured I'd share, incase anybody else has run into this problem....

#MAKE A GEOMETRY NODE
curNode = hou.node('/obj').createNode('geo', 'character1')

#CREATE INT SLIDER IN PARAMETER INTERFACE
timeTemplate = hou.IntParmTemplate( "timeOffset", "Time Offset", 1, default_value=([0]), min=-100, max=100, min_is_strict=False, max_is_strict=False, naming_scheme=hou.parmNamingScheme.Base1, disable_when="", tags={})
curNode.addSpareParmTuple( timeTemplate, in_folder=([spareFolder]), create_missing_folders=True)

#CREATE FILE REFERENCE IN PARAMETER INTERFACE
fileTemplate = hou.StringParmTemplate( "fileIN", "File Input", 1, default_value=(["0"]), naming_scheme=hou.parmNamingScheme.Base1, string_type=hou.stringParmType.FileReference, disable_when="", tags={})
curNode.addSpareParmTuple( fileTemplate, in_folder=([spareFolder]), create_missing_folders=True)

Also, it's easy to create a new folder in the parm interface, but it puts it after the default tabs. Does anybody know how to move it from the last tab in the group to the first??? (ie. before the "Transform" tab...)

Thanks,

- Jake

  • Thanks 1
Link to comment
Share on other sites

  • 9 years later...

I have a python code which have a loop to get alembic files path from a dictionary and now i want to add a new parameter for each alembic path in a specific node according to loop count using python. can anybody tell me how can i do that.

newbie to python and houdini

 

 

Link to comment
Share on other sites

Untested, off the top of my head:

node = hou.node('your_node')
ptg = node.parmTemplateGroup()
for i, file_path in enumerate(paths):
  pt = hou.StringParmTemplate('file%d' % i, 'File %d' %i, 1, file_path)
  ptg.addParmTemplate(pt)

node.setParmTemplate(ptg)
  

Or you could multi-parm block: hou.FolderParmTemplate( ... folder_type=MultiparmBlock)

Link to comment
Share on other sites

  • 6 months later...

I could do it as you said with:

On 22/1/2009 at 8:09 PM, RuschFX said:

#CREATE FILE REFERENCE IN PARAMETER INTERFACE fileTemplate = hou.StringParmTemplate( "fileIN", "File Input", 1, default_value=(["0"]), naming_scheme=hou.parmNamingScheme.Base1, string_type=hou.stringParmType.FileReference, disable_when="", tags={}) curNode.addSpareParmTuple( fileTemplate, in_folder=([spareFolder]), create_missing_folders=True)

 

In my case I used:

for i in range(1,20):
...     new_folder.addParmTemplate(hou.StringParmTemplate("parm"+str(i), "Label"+str(i), 1, default_value=([""]), naming_scheme=hou.parmNamingScheme.Base1, string_type=hou.stringParmType.NodeReference, menu_items=([]), menu_labels=([]), icon_names=([]), item_generator_script="", item_generator_script_language=hou.scriptLanguage.Python, menu_type=hou.menuType.Normal))
... 

But, do we really have to use that full line of code?

Is there a shorter reference to call an "operator path"?

Thanks

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