nilsoncardososa Posted October 2, 2019 Share Posted October 2, 2019 Help I have a model with several materials in shop_materialpath. I want to get a list of each material (I will use this information to create groups later). I made the following code, and it works !. My question is if I did it right? Because with objects of many polygons, it is extremely slow. import hou root = hou.selectedNodes()[0] geo = root.geometry() path_a = [] path_b = [] for prim in geo.prims(): shop = prim.attribValue('shop_materialpath') path_a.append(shop) if shop not in path_b: path_b.append(shop) print path_b Quote Link to comment Share on other sites More sharing options...
symek Posted October 2, 2019 Share Posted October 2, 2019 Yep, iterating over points/primitives in Python isn't the fastest operator. Bellow line materials = list(set(geometry.primStringAttribValues("shop_materialpath"))) is considerably faster though, but if you're interested in creating groups per attribute value, I would consider VEX. Something like (untested): int success = 0; string material_name[] = split(primattrib(0, "shop_materialpath", @primnum, success), "/"); setprimgroup(0, material_name[-1], @primnum, 1); 1 Quote Link to comment Share on other sites More sharing options...
nilsoncardososa Posted October 2, 2019 Author Share Posted October 2, 2019 Thanks for the quick response I will try with vex Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.