Jump to content

Simple Attribute value driving me bonkers


Supersaqib

Recommended Posts

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

Link to comment
Share on other sites

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)

Link to comment
Share on other sites

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]

Link to comment
Share on other sites

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.

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