tagosaku Posted December 30, 2022 Share Posted December 30, 2022 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.