Jump to content

creating vector attributes in a python geo operator


Aearon

Recommended Posts

Hey guys,

is there anyway to create a vector type attribute? all i seem to get is a '3 float' type using

geo.addAttrib(hou.attribType.Point, "N", hou.Vector3(0.0,0.0,1.0))

or

geo.addAttrib(hou.attribType.Point, "N", (0.0,0.0,1.0))

but some of the standard attributes like 'N' and 'up' need to be vector attributes

Link to comment
Share on other sites

Seems to work for me ... (9.5.252)

geo = hou.pwd().geometry()

# for vector attributes, we need to send down True for transform_as_normal
geo.addAttrib(hou.attribType.Point, "N", (1.0,1.0,1.0), True)

# string attribute
geo.addAttrib(hou.attribType.Prim, "name", "")
for poly in geo.prims():
	if poly.number() % 2 == 0:
		poly.setAttribValue("name", "even");
	else:
		poly.setAttribValue("name", "odd");

Link to comment
Share on other sites

thanks edward, i didn't know about the transform as normal attribute

as for the string attribute, i tried it like this before:

attr = geo.addAttrib(hou.attribType.Prim, "name", "")
poly.setAttribValue(attr, "even");

this is the way it's done in some of the HOM Cookbook examples, but apparently this doesn't work for strings? it does work for the vector attribs i'm adding. anyway your method works fine and i'm on my way. thanks!

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