csp Posted February 10, 2014 Share Posted February 10, 2014 Hi, the following code which is included in an ordered menu script, code does what supposed to do. menu = [] list = len(hou.pwd().node("OUT").geometry().prims()) for i in range(0,list): menu.append(i) menu.append(i) return menu But when even I copy paste the node or open the saved hip will give me an error: AttributeError: 'NoneType' object has no attribute 'geometry' I have not compiled an OTL, this parameter is on a subnet node and getting info from the SOP nodes inside. Why is there an error and at the same time the code is working? Quote Link to comment Share on other sites More sharing options...
graham Posted February 10, 2014 Share Posted February 10, 2014 I suspect that it's just an order of operations type thing. Houdini may be creating the main node, then attempting to display the menu parameter before it's actually created any of the child nodes. In this case the call to get the child node would fail (give you None). Just a guess anyway. Easiest thing to do would be to just do a check against the child node existing, and of not, return the empty menu. Chances are when the node goes to actually cook properly, things should be all good. Quote Link to comment Share on other sites More sharing options...
csp Posted February 10, 2014 Author Share Posted February 10, 2014 I suspect that it's just an order of operations type thing. Houdini may be creating the main node, then attempting to display the menu parameter before it's actually created any of the child nodes. In this case the call to get the child node would fail (give you None). Just a guess anyway. Easiest thing to do would be to just do a check against the child node existing, and of not, return the empty menu. Chances are when the node goes to actually cook properly, things should be all good. Thanks graham, that worked! for future reference: menu = [] geo = hou.pwd().node("OUT") if geo: list = len(geo.geometry().prims()) for i in range(0,list): menu.append(i) menu.append(i) return menu Quote Link to comment Share on other sites More sharing options...
csp Posted February 13, 2014 Author Share Posted February 13, 2014 Hey Graham, somehting weird is happing with this code. I have an OTL out of this tool now. I get an error when I copy paste the OTL and also when I submit the hip to the farm. AttributeError: 'NoneType' object has no attribute 'prims' But I will NOT get any error when a new instance of the OTL is down. I will NOT get any error when I copy paste and there is. I will NOT get any error when I copy paste when the OTL is in "Allow Editing Contents" mode, with is input or not. So I get the error only when is compiled, there is an input and I copy paste it. I suspect that it's just an order of operations type thing. Houdini may be creating the main node, then attempting to display the menu parameter before it's actually created any of the child nodes. In this case the call to get the child node would fail (give you None). Just a guess anyway. Easiest thing to do would be to just do a check against the child node existing, and of not, return the empty menu. Chances are when the node goes to actually cook properly, things should be all good. Quote Link to comment Share on other sites More sharing options...
csp Posted February 13, 2014 Author Share Posted February 13, 2014 fixed by replaced two lines of the code from: menu = [] geo = hou.pwd().node("OUT") if geo: list = len(geo.geometry().prims()) for i in range(0,list): menu.append(i) menu.append(i) return menu to: menu = [] geo = hou.pwd().node("OUT").geometry() if geo is not None: list = len(geo.prims()) for i in range(0,list): menu.append(i) menu.append(i) return menu Quote Link to comment Share on other sites More sharing options...
Stalkerx777 Posted February 13, 2014 Share Posted February 13, 2014 If you change this: list = len(geo.prims()) to this: list = len(geo.iterPrims()) You will get x100 speed boost on heavy models, since getting the length of generator is ultra fast. Quote Link to comment Share on other sites More sharing options...
csp Posted February 14, 2014 Author Share Posted February 14, 2014 If you change this: list = len(geo.prims()) to this: list = len(geo.iterPrims()) You will get x100 speed boost on heavy models, since getting the length of generator is ultra fast. thanks Alex for the tip. 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.