Jump to content

Problems with editing asset type parameters in python


bento

Recommended Posts

Hi,

I'm attempting to create a digital asset via python scripting and would like to set up some of the parameters and interface as part of that process.

 

I've had success creating parameters and arranging the interface for normal nodes (spare parameters), but taking the same sort of approach with an asset only appears to be half working.

 

Here is my debugging example code:

hou.hipFile.clear() # just whilst we're testing; do a fresh start


objNode = hou.node('/obj').createNode('geo')
objNode.setName('myAsset')
if objNode.canCreateDigitalAsset():
    objNode = objNode.createDigitalAsset(
                                name='test::myAssetA',
                                description='myAsset',
                                hda_file_name='/tmp/foo_v001.hda',
                              )


parm_group = objNode.type().definition().parmTemplateGroup()

first = parm_group.findFolder('Transform')

folderTemplate = hou.FolderParmTemplate('myFolder','My Folder')

buttonTemplate = hou.ButtonParmTemplate('myButton','My Button')
folderTemplate.addParmTemplate(buttonTemplate)

parm_group.insertBefore(first,folderTemplate)

objNode.type().definition().setParmTemplateGroup(parm_group)

What I'm hoping to do here is create an asset, add a folder as the first item in the interface, and add a button to that folder.

Like I said, this sort of seems to work - if I then go to the Edit Opertator Type Properties dialog I see the parameters listed as expected. Weirdly though, all the pre-existing folders are now renamed to match the new folder I added (i.e. myFolder_1,myFolder_2 etc).

Then when I look at the interface in the parameter editor, 'myFolder' appears as a check box instead of a folder and the custom UI elements are drawn last rather than first. (see attached screen grab).

 

So, the question is - am I going about this the wrong way (likely), or do you think this might be a bug (happy to log if so)?

 

cheers

Ben

 

Link to comment
Share on other sites

You're doing this right. It's ok that folder names are renamed, you are not going to work with folder names directly, instead you will use folder labels most of the time.

To actually see your parm in a folder, you need to create an instance of you newly create operator type. For some reason it's not updating right after creating from script.

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