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
Houdini Python for loop cycle through prim attribute
5704 2 0- madguru
- Member
- 96 posts
- Joined: 10月 2013
- Offline
- tamte
- Member
- 8532 posts
- Joined: 7月 2007
- Online
you can do that with 2 oneliner prim wrangles:
assuming your path is in more or less standard hierarchy “/some/parent/objects/objectname/geoname”
to extract objetname token (second from the end) as s@name attribtute you can do
but obviously you can combine tokens to get more unique name or process otherwise as you need
and then another prim wrangle to get array of all unique name values
but to answer your original Python question, you can also do it without any loop:
assuming your path is in more or less standard hierarchy “/some/parent/objects/objectname/geoname”
to extract objetname token (second from the end) as s@name attribtute you can do
s@name = split(s@path, "/")[-2];
and then another prim wrangle to get array of all unique name values
s[]@names = uniquevals(0, "prim", "name");
but to answer your original Python question, you can also do it without any loop:
attrib = geo.findPrimAttrib("name") unique_names = attrib.strings()
Edited by tamte - 2020年6月24日 02:31:59
Tomas Slancik
FX Supervisor
Method Studios, NY
FX Supervisor
Method Studios, NY
- madguru
- Member
- 96 posts
- Joined: 10月 2013
- Offline
-
- Quick Links