Jump to content

Modifying a Menu Script Code By Python ( Digital Asset )


gemini

Recommended Posts

Hi, 

Can It be possible to modify a Digitial Asset Parameter's Menu Script by Python ?

I use a similar code like this to modify the callbacks , but I could not figure out with menu script..

        if not script == None:
            pt.setScriptCallback( script)
            pt.setScriptCallbackLanguage(hou.scriptLanguage.Python)
        elif not replace_in_script == None:
            replace_what = replace_in_script.split('|')[0]
            replace_to = replace_in_script.split('|')[1]
            pt.setScriptCallback( pt.scriptCallback().replace( replace_what, replace_to))
            pt.setScriptCallbackLanguage(hou.scriptLanguage.Python)

        ptg.replace( parm, pt)

        if not node.type().definition():
            node.setParmTemplateGroup(ptg)
        else:       
            ptg = node.type().definition().setParmTemplateGroup(ptg)

Any Help is Wellcome!!

Cheers, G

Link to comment
Share on other sites

Hey, if you want to put a script into the hda menu script, it must return a dictionnary with your menu items and their id, like

def myMenu():
	do something
	items = {"0" : "item1", "1" : "item2"}
	return items

myMenu()

I don't know if that seems clear to you, but as you replace the "classic" item list by a script, it must return some items, and those items are evaluated as a dictionnary.

 

Cheers,

Link to comment
Share on other sites

I don't understand what's your goal here. If you want to replace your script by another script using some condition, create a python module in your hda with your different functions and call them in the menu using hou.pwd().hdaModule.myFunction().

Link to comment
Share on other sites

Sorry the goal is clear as I wrote. If you have an asset which has about 150 parameters you would not like to modify it by hand too.  :)

And you will have the chance to make a mistake !

Any help ?

Edited by gemini
Link to comment
Share on other sites

Tomas , maybe you got into this:

oplib:/digic::Object/dScene2_test::1?digic::Object/dScene2_test::1 Warning(1314): incorrect number of #s in 'nassets' for multiparm depth of 1
oplib:/digic::Object/dScene2_test::1?digic::Object/dScene2_test::1 Warning(1446): incorrect number of #s in 'nrassets' for multiparm depth of 1
oplib:/digic::Object/dScene2_test::1?digic::Object/dScene2_test::1 Warning(1560): incorrect number of #s in 'nsagroups' for multiparm depth of 1

Did you? Probably an old Houdini version's asset , but I coudl not figure out how to solve.

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