Jump to content

hda python problem


Omy

Recommended Posts

The given below is a little snippet of my hda code.This is a shelf tool I am trying to implement.If i click once.It creates the operation well.But if i click the tool more than once.It does throw some error.Please let me know how to correct this.Thank you.

obj = hou.node('/obj') 
creategeo=obj.createNode('geo','geo1') 
s=obj.collapseIntoSubnet((creategeo,),'HOUDIGASS').moveToGoodPosition() 
subnets = hou.nodeType(hou.objNodeTypeCategory(), "subnet")
su_inst=subnets.instances()
for x in su_inst:
    myhd=x.createDigitalAsset('myhda')
    for parm in myhd.parmTuples():
        hideparm=parm.hide(True)
houda=hou.node('/obj/HOUDIGASS')
ol=hou.StringParmTemplate("llist","List",1,default_value=([""]),naming_scheme=hou.parmNamingScheme.Base1,string_type=hou.stringParmType.NodeReferenceList,menu_items=([]),menu_labels=([]),icon_names=([]),item_generator_script="",item_generator_script_language=hou.scriptLanguage.Python,menu_type=hou.menuType.Normal)
houda.addSpareParmTuple(ol)
#multiparm folder list
bgeo=hou.FolderParmTemplate("bgeofolder","Add BGEO",folder_type=hou.folderType.MultiparmBlock,default_value=0,ends_tab_group=False)
houda.addSpareParmTuple(bgeo)

Link to comment
Share on other sites

After first launching of the script you have "/obj/HOUDIGASS" node created with it's params.

When you launch the script second time you already have the "/obj/HOUDIGASS" created. And with houda.addSpareParmTuple(ol) you want to add param tuple with the name "llist" which already exists in this node.

You probably should create "/obj/HOUDIGASS" subnet not with the hardcoded name but with addition 1,2,3... to the end like Houdini does it by default.

Link to comment
Share on other sites

What do you want the script to do on the second run?

Hi Sam,

Basically nothing.I would like to behave this as a shelf tool.If the user clicks the tool for the 2nd time.I want to place the node 2nd time in the network.But if i click more than once im getting problem.Any solutions would be really coool

Thanks

Link to comment
Share on other sites

Why are you creating a digital asset on the script? Do you want a new digital asset each time?

It seems like you don't need a shell script at all. Just make a digital asset, and you can creat a new node with the tab menu.

I thought of making it as a shelf tool.

Link to comment
Share on other sites

Yeah, its always a good idea to know what we want to have as a final result :)

Maybe instead of creating a DA it would be better to just create a bunch of nodes and its params with your shelf tool. Now the script tends to create new DA on every using a shelf tool. But DAs didn't designed to behave like this. In addition if I'll choose HOUDIGASS from TAB menu it will creates not the same object as I'll create with a shelf tool. Its because you make changes in HOUDIGASS after creating it in your script.

Link to comment
Share on other sites

@Green Man

Which is the best way to create digital assets using script.Previously i tried creating all the nodes and parms and then hda-ed.But Later i got lot of referencing problems :( so now planning to rewrite it again!let me know what you think

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