Jump to content
gemini

Modifying a Menu Script Code By Python ( Digital Asset )

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

Share this post


Link to post
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,

Share this post


Link to post
Share on other sites
Posted (edited)

Yes. Thanks, but this is not what i am searching for.  I would replace my menu script ( which has been written ) with an other script by a python script.

Edited by gemini

Share this post


Link to post
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().

Share this post


Link to post
Share on other sites
Posted (edited)

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

Share this post


Link to post
Share on other sites

use

pt.itemGeneratorScript(), pt.itemGeneratorScriptLanguage()

and

pt.setItemGeneratorScript(), pt.setItemGeneratorScriptLanguage()

 

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×