HOM and primative groups

   3769   4   1
User Avatar
Member
3 posts
Joined:
オフライン
I am new to Houdini and am trying to use HOM to get primitive group names. I have two primitive attrs called mesh_name and part_name but am only interested in the mesh_name.

In a python text port i try the commands
>>>geo = hou.node(“/obj/geo1”).displayNode().geometry()
>>>for prim in geo.prims():
>>> print geo.prims

and it prints out:
<bound method Geometry.prims of <hou.Geometry in /obj/geo1/partition1>>

How do i get the primitive Attr Names?

Thanks in advance.

Attachments:
primHelp.hip (48.4 KB)

User Avatar
Member
798 posts
Joined: 4月 2020
オフライン
Hey Jimmy,

I think this might work for you:

n = hou.node(“/obj/geo1/attribcreate1”)
geo = n.geometry()
prims = geo.prims()
attr = geo.findPrimAttrib(“mesh_name”)
if attr:
for p in prims:
print p.stringAttribValue(attr)

Cheers,
Koen
User Avatar
Member
3 posts
Joined:
オフライン
Thanks Koen.

I thought I would try a new method of getting answers for my questions. I thought I was being a bother with all my questions. But it turns out you answered it anyway.

-Jj
User Avatar
Member
3 posts
Joined:
オフライン
I can not seem to find the HOM command to set a primitive attribute. Any one know ?
User Avatar
Member
798 posts
Joined: 4月 2020
オフライン
Hello James,

here is some code, using the attr from the previous example:

geo= hou.pwd().geometry()
prims = geo.prims()
attr = geo.findPrimAttrib(“mesh_name”)
for p in prims:
p.setAttribValue(attr,“mesh”)

This will only work inside a custom python sop, running this from a python shell will result in permission error.

Cheers,
Koen
  • Quick Links