maphysart Posted July 10, 2009 Share Posted July 10, 2009 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. Quote Link to comment Share on other sites More sharing options...
maphysart Posted July 11, 2009 Author Share Posted July 11, 2009 in the attachment is HDA tutorial Accumulator by Dan Letarte I still do not find out what is wrong with menu script when I try to get the primgroupelist from the input node. Thank you for your help. letarte_accumulatorTutorial.pdf Quote Link to comment Share on other sites More sharing options...
edward Posted July 12, 2009 Share Posted July 12, 2009 It's not using python. It's using hscript to call python via pythonexprs(). So don't specify a python menu script. Quote Link to comment Share on other sites More sharing options...
maphysart Posted July 12, 2009 Author Share Posted July 12, 2009 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 Quote Link to comment Share on other sites More sharing options...
edward Posted July 12, 2009 Share Posted July 12, 2009 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"] Quote Link to comment Share on other sites More sharing options...
maphysart Posted July 13, 2009 Author Share Posted July 13, 2009 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. Quote Link to comment Share on other sites More sharing options...
maphysart Posted July 13, 2009 Author Share Posted July 13, 2009 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.