Houdini Python for loop cycle through prim attribute

   1261   1   0
User Avatar
Member
1 posts
Joined: Oct. 2020
Offline
Hi,

I'm working on automating some steps in my alembic import process. I have a python node with code that cycles through all primitives in the alembic file, and creates a string attribute called “name” with a value based on the path variable.

After this for loop, I would like to cycle through the name attribute in a for loop and run code for each object that way. I tried

<code>
objLs = geo.findPrimAttrib(“name”)
</code>

but that does not seem to be correct. I want to get a list of values for that attribute, that I can cycle through. So, I would have a list with object names.

Thank you.

Adnan
User Avatar
Member
94 posts
Joined: April 2011
Offline
Hi gamo,

I would advise you to use VEX instead of python, as it is much easier to work with attributes with it (unless you need some specific functions which are available in python but not in VEX).

In VEX, you can easily do it inside a detail_wrangle, iterating on all the primitives. From that, you get the primitive name attribute and you test if it's inside an array containing all the values.

Here is a quick file showing how to do it.
Edited by Matthew05 - Oct. 30, 2020 13:26:27

Attachments:
List_of_all_different_name_attr.hiplc (99.2 KB)

  • Quick Links