Search the Community
Showing results for tags 'parmtemplate'.
-
Hi, I am studying how to make OnCreated.py by exporting codes with asCode. So far, I understood a procedure: 1 Create a new folder and create some parameters inside of the folder in edit parameter interface on a node. 2 Use findFolder() to take a new folder tab, and write out a python code with as Code. 3 Create actual a xxx_OnCreated.py that either imports or copy&paste the #2 written code. Questions are : 1 Can we export multi folder tabs at once as one master code? 2 Can we export expressions existing in a default parameter AND new folder tabs together, instead of separately? (I know I can manually add this code into OnCreated.py later.. ) I think a problem is that, if we export all folders and parameters including default param&folders, onCreated.py will get error due to the default one including. That makes this procedures difficult. # export new folder and its parameters. Let's say exportTab.py node = hou.node("/out/geometry1") ptg = node.parmTemplateGroup() folder = ptg.findFolder("NewFolder1") with open('f:/exportTab.py','w') as f: f.write( folder.asCode(function_name='createTab') ) ## Questions are ## I want to export NewFolder1 and NewFolder2 and NewFolder3 together and do f.write ## I want to export an expression together, for instance, "/obj/geo1/out_render" in Geometry1 > SOP Path param here, and do f.write. ## I could manually paste later like a node.parm('soppath').set('/obj/geo1/out_render') but ideally export together here.. #Then Let's say this is , Geoemetry_OnCreated.py, and try to attach the exported folder tab and parameters import exportTab node = kwargs['node'] ptg = node.parmTemplateGroup() defaultFolder = hou.FolderParmTemplate('default', 'Default', parm_templates=ptg.entriesWithoutFolders()) for p in ptg.entriesWithoutFolders(): ptg.remove(p) ptg.append(defaultFolder) ht = exportTab.createTab() ptg.append(ht) node.setParmTemplateGroup(ptg) Maybe my explanation is confusing, but I hope the code and screenshot help to show what I try to do. In other words, in conclusion, with the screenshot, how to export multi tabs¶m (#1) and expression(#2:sorry it's empty,,) ? Thanks!
-
I'm trying to create and customize a node through a python script. I'm adding parms using the hou.parmTemplate() class and for one of the parameters I need to edit the Channel tab (see below). I can't seem to find anything in the python documentation on how to do this; anybody know what the best solution would be? Thanks!
- 2 replies
-
- parmtemplate
- parm
-
(and 3 more)
Tagged with:
-
Hi! I'm trying to find a way to read a config when a button is pressed, and update the available items in a menu parameter. I've tried a couple of methods, but haven't managed to get anything to work yet. First Attempt: target_menu_items = ["a", "b", "c"] menu_parm = node.parm("menu_parm") template = menu_parm.parmTemplate() template.setMenuItems(target_menu_items) The interface remains unchanged. Reading the docs that is understandable: So I tried what the docs recommended without any luck: ptg = node.parmTemplateGroup() menu_parm = node.parm("menu_parm") template = menu_parm.parmTemplate() template.setMenuItems(target_menu_items) ptg.replace("menu_parm", template) node.setParmTemplateGroup(ptg) I had some success by adding a line, but this isn't really a solution. template.setName("bahhumbug") I assume it's failing to replace the template if the name of the replacement template matches that of the existing one. I don't understand why that would be a problem though. I've had a thorough Google and can't find any examples of this... so I'm worried I'm approaching it the wrong way. Can anyone explain where I'm going wrong? Many many thanks in advance, Dan
- 4 replies
-
- 1
-
- ParmTemplate
- python
-
(and 1 more)
Tagged with: