Jump to content

menu script fail to work. please help.


Recommended Posts

I am a newbie and am trying the tutorial by Dan Letart, building a HDA with python.

Here is the tutorial.

http://203.208.39.132/search?q=cache:3hlSu...IN2hJZ0qaKbH9hg

but the menu script always failed to work. I do not know why.

Here is the script according to the tutorial:

echo `strreplace(pythonexprs("hou.pwd().hdaModule().buildMenu()"), "'", "\'")`

this step is to format the group in the input node above and display these groups in the parameter box in this HDA.

I really copy the script to the menu script. And I check the python function buildMenu, which is correct.

I am confused. Please help me. Thanks a lot.

Link to comment
Share on other sites

It's not using python. It's using hscript to call python via pythonexprs(). So don't specify a python menu script.

Thank you. I notice it. I set the menu script language to HScript in the parameter description. I failed once again.

But when I set the menu script language to Python, it works better, still not good because I get the 'r', 'a', 'd' three letter the group list. I do not why. Could you give me more hints ? Thanks .

In the attachment is the hip file and the otl file.

accumulator_node.hip

Accumulator.otl

Link to comment
Share on other sites

Here's the help that discusses the proper return values for menu scripts. Notice that they're different for python and hscript:

http://www.sidefx.com/docs/houdini10.0/ref...optype#menu_tab

In your python module code, you're only returning 1 token in the list no label. It should returning at least ["randGrp", "randGrp"]

Thank you very much. It works.

Here is the code of the buildMenu function:

def buildMenu():

import shlex

accumNode = hou.node('.')

pEntity = hou.Node.evalParm(accumNode, "pEntity")

# because in the Entity order menu, the order of primitives are 0, so I modify the if block.

if pEntity == 0:

groupsList = hou.hscriptExpression("primgrouplist(opinputpath(\".\", 0))")

else:

groupsList = hou.hscriptExpression("pointgrouplist(opinputpath(\".\", 0))")

names = ""

if groupsList != "":

for names in groupsList:

check = shlex.split(groupsList)

numGroups = len(check)

i = 0

final = []

while i < numGroups:

final += [check,check]

i = i + 1

try: final

except NameError:

final = []

return final

And below is the python menu script:

hou.pwd().hdaModule().buildMenu()

Thanks again.

Link to comment
Share on other sites

But there is another confusion.

Here I am studying the tutorial writen by Dan Letarte( thanks to him) and use the python codes directly. If I write the python functions myself, how could I debug the function and track the execution of the function step by step as the we could in Maya. It is well known that we could debug in the Maya enviroment with Visual Cpp. So how about Python in houdini?

Thanks for your suggestions.

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