Nerox Posted July 5, 2011 Share Posted July 5, 2011 I'm planning on implementing a A* path finding algorithm in a python SOP, ironically I get stuck on the first simple thing and thats creating an attribute on the Geometry . This is what I do: geo = hou.node('/obj/grid/attribcreate1').geometry() >>> geo <hou.Geometry in /obj/grid/attribcreate1> >>> geo.addAttrib(hou.attribType.Point, "test", 1) Traceback (most recent call last): File "<console>", line 1, in <module> File "/Users/prisms/builder-new/Nightly11.0/dev/hfs/houdini/python2.6libs/houpythonportion.py", line 605, in addAttrib create_local_variable) File "/Users/prisms/builder-new/Nightly11.0/dev/hfs/houdini/python2.6libs/hou.py", line 15228, in addAttrib return _hou.Geometry_addAttrib(*args) GeometryPermissionError: Geometry is read-only. Quote Link to comment Share on other sites More sharing options...
graham Posted July 5, 2011 Share Posted July 5, 2011 (edited) You can only modify hou.Geometry objects from inside the Code section of a Python SOP. Anywhere else the geometry is read-only. Edited July 5, 2011 by graham Quote Link to comment Share on other sites More sharing options...
Nerox Posted July 6, 2011 Author Share Posted July 6, 2011 (edited) You can only modify hou.Geometry objects from inside the Code section of a Python SOP. Anywhere else the geometry is read-only. Alright, well that makes sense :-). I also found the problem, it's rather embarrassing, there was a 'return this command' halfway a function which I missed . That's the reason it wasn't working . So I tried it in the shell which didn't work due to what's said above . I love trouble shooting, not the shit you have to go through but the rush when you 'conquer' the problem . @Graham Thanks dude , as always Edited July 6, 2011 by Nerox Quote Link to comment Share on other sites More sharing options...
kursad Posted July 6, 2011 Share Posted July 6, 2011 You can only modify hou.Geometry objects from inside the Code section of a Python SOP. Anywhere else the geometry is read-only. How about hython or scripts? Quote Link to comment Share on other sites More sharing options...
graham Posted July 6, 2011 Share Posted July 6, 2011 Nope, only from something within the cooking section. You can use external modules or scripts, called from within the section, but unless your hou.Geometry object comes from in there it will not be writable. Quote Link to comment Share on other sites More sharing options...
kursad Posted July 6, 2011 Share Posted July 6, 2011 Nope, only from something within the cooking section. You can use external modules or scripts, called from within the section, but unless your hou.Geometry object comes from in there it will not be writable. thanks for the insight Graham Quote Link to comment Share on other sites More sharing options...
eyevex Posted August 13, 2011 Share Posted August 13, 2011 I am having similar issues and am somewhat confused about the logic. I have a large SOP network. Amongst it is an edit node.... Now from my understanding of the above, I can NOT edit a point attrib here -yet if I open the spreadsheet, click on the attrib for that point, I can use the ladder and on release the attrib sets and I see the result as expected i nthe viewport. The edit node automatically becomes locked, which i am fine with. Now I want to build up an interface on the HDA to do the same. The edit node is white listed to editable and still behaves the same when attempting the alteration via the spreadsheet as above. Now I try the same via a callback py on the HDA button... something like ... mygeo = mysop.geometry() mypoints = mygeo.iterPoints() mypt = mypoints[123] mypt.setAttribValue('smoo', 1) and it errors... GeometryPermissionError: Geometry is read-only So is seetting point attribs in a pysop only --not always the case? is there a way to replicate this behavior other wise? am I just confused on the matter? or is this just totally inconsistant? Thank to anyone who has experiance with this. Quote Link to comment Share on other sites More sharing options...
Nerox Posted August 13, 2011 Author Share Posted August 13, 2011 I'm not sure what your up to, can you post an example file? Quote Link to comment Share on other sites More sharing options...
graham Posted August 13, 2011 Share Posted August 13, 2011 Your callback does not work because it is just that, a callback. As mentioned above, you can only modify geometry with Python from within the Code section of a Python SOP. You can get the same type of effect you are looking for with something like this: http://houdinitoolbox.com/houdini.php?asset=2 It allows you to be able to change any attribute value you want by using the parameter dialog and selecting the components in the viewer. Unfortunately there is no support for spreadsheet dialogs in Houdini. If you wanted to do a programmatic method of setting values you could do it quite easily with this operator as long as you have an understanding of how it stores its data. Quote Link to comment Share on other sites More sharing options...
eyevex Posted August 14, 2011 Share Posted August 14, 2011 Your callback does not work because it is just that, a callback. As mentioned above, you can only modify geometry with Python from within the Code section of a Python SOP. You can get the same type of effect you are looking for with something like this: http://houdinitoolbox.com/houdini.php?asset=2 It allows you to be able to change any attribute value you want by using the parameter dialog and selecting the components in the viewer. Unfortunately there is no support for spreadsheet dialogs in Houdini. If you wanted to do a programmatic method of setting values you could do it quite easily with this operator as long as you have an understanding of how it stores its data. Thanks for pointing me to your HDA, it looks useful but I am using py2.5 currently. Interestingly enough after posting this I started prototyping something similar but much narrower as I only need to deal with points of known attrib types/names and utilizing multiparms. I have a certain amount of concerns about speed as the amount of attrib change stack up, but Im going to have to go with somehting like it for now becuase of time constraints. I still lfind it odd, that it would seem that the spreadsheet used as I orinally was-- was acting on the points attrib from outside the cook method although it is possibe I misunderstand the underpinnings of the spreadsheet..... 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.