Supersaqib Posted March 29, 2013 Share Posted March 29, 2013 Okay i've been at this for ages now. My Python skills are average maybe slightly below but in my efforts to improve i'm hitting a road block. I dont know why but i cant get the setAttribValue to work. The scene is i have about 50 points coming into my Python Geometry operator and all i'm doing is creating a new point attribute called myattr. After that i just wanna set is to something other than its default value using setAttribValue, but it doesnt matter what combination i use whether to refer to the attribute directly with quotation marks or reference it with a variable it doesnt seem to bloody work. geo = hou.pwd().geometry()fart = (1,2,1)geo.addAttrib(hou.attribType.Point, "myAttr", fart)geo.addAttrib(hou.attribType.Point, "author", 0)geo.setAttribValue("author", 5)[/CODE]Why does this not go on to set the author values to 5. Its all in the last line as without it the attributes are being generated to the points. My scene is 50 scattered points coming in thats it.I tried to do it per point with a for loop but that wasnt working either. Can someone help or give me a better example of using it and maybe using it to points in a for loop, before it drives me loopy.Doesnt help that my help browser is completly black too. Thanks Side Effects for the online Docs Quote Link to comment Share on other sites More sharing options...
graham Posted March 29, 2013 Share Posted March 29, 2013 hou.Geometry.setAttribValue is for setting global/detail attributes, so it won't ste your point attributes. You can do something like this: geo = hou.pwd().geometry() attrib = geo.addAttrib(hou.attribType.Point, "author", 0) for point in geo.points(): point.setAttribValue(attrib, 5) Quote Link to comment Share on other sites More sharing options...
Erik_JE Posted March 29, 2013 Share Posted March 29, 2013 Was just about to post the same thing as graham but as usual he was the quickest on the python questions. Here is another way of doing it for giggles: fiveArray = [5] * len(geo.points())geo.setPointFloatAttribValues("author", fiveArray)[/CODE] Quote Link to comment Share on other sites More sharing options...
Supersaqib Posted March 29, 2013 Author Share Posted March 29, 2013 hou.Geometry.setAttribValue is for setting global/detail attributes, so it won't ste your point attributes. You can do something like this: geo = hou.pwd().geometry() attrib = geo.addAttrib(hou.attribType.Point, "author", 0) for point in geo.points(): point.setAttribValue(attrib, 5) Was just about to post the same thing as graham but as usual he was the quickest on the python questions. Here is another way of doing it for giggles: fiveArray = [5] * len(geo.points())geo.setPointFloatAttribValues("author", fiveArray)[/CODE]Both Fantastic, Thanks Graham and Eric. This is why i love the Houdini community. 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.