tricecold Posted September 4, 2015 Share Posted September 4, 2015 I have this lots of geo imported as alembic. In the naming convection we have material IDs , objects inherit these names as group names in Houdini, I need to copy these names to points as strings, and then need to split them by "_" which I think I can manage, but I cannot find a way to copy the group names as strings in any kinda of wrangle sop ? any ideas Quote Link to comment Share on other sites More sharing options...
Atom Posted September 4, 2015 Share Posted September 4, 2015 (edited) I'm not sure how to wrangle that but in python you can fetch the groups using geo.primGroups(). How you get that string back out into where you need it is another question. node = hou.pwd() geo = node.geometry() # Add code to modify contents of geo. # Use drop down menu to select examples. print geo.primGroups() for g in geo.primGroups(): print g.name() Edited September 4, 2015 by Atom 1 Quote Link to comment Share on other sites More sharing options...
Atom Posted September 4, 2015 Share Posted September 4, 2015 (edited) So do you want to copy a group name onto the points of the same mesh or some target mesh? Edited September 4, 2015 by Atom Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted September 4, 2015 Share Posted September 4, 2015 (edited) Something along those lines Run Over Points should do the trick: string groupName = chs("groupnamepattern"); int groupCount = chi("groupcount"); for(int i = 0; i < groupCount; i++) { string formattedName = sprintf("%s%d", groupName, i); int success = inprimgroup(@OpInput1, formattedName, @primnum); if (success) s@groupname = formattedName; } groupCount expression: groupCount = argc(primgrouplist(opinputpath(".", 0))) groupName is partial name, so if you have 100 groups called id_number, you want to put there only id_ Edited September 4, 2015 by fântastîque Mântragorîè Quote Link to comment Share on other sites More sharing options...
tricecold Posted September 4, 2015 Author Share Posted September 4, 2015 Something along those lines Run Over Points should do the trick: string groupName = chs("groupnamepattern"); int groupCount = chi("groupcount"); for(int i = 0; i < groupCount; i++) { string formattedName = sprintf("%s%d", groupName, i); int success = inprimgroup(@OpInput1, formattedName, @primnum); if (success) s@groupname = formattedName; } groupCount expression: groupCount = argc(primgrouplist(opinputpath(".", 0))) groupName is partial name, so if you have 100 groups called id_number, you want to put there only id_ I'm not sure how to wrangle that but in python you can fetch the groups using geo.primGroups(). How you get that string back out into where you need it is another question. node = hou.pwd() geo = node.geometry() # Add code to modify contents of geo. # Use drop down menu to select examples. print geo.primGroups() for g in geo.primGroups(): print g.name() I'm not sure how to wrangle that but in python you can fetch the groups using geo.primGroups(). How you get that string back out into where you need it is another question.node = hou.pwd()geo = node.geometry() # Add code to modify contents of geo. # Use drop down menu to select examples. print geo.primGroups() for g in geo.primGroups(): print g.name() Hi Atom, I already got it working with python, and i set the names like this mat_attrib = geo.addAttrib (hou.attribType.Prim, "material","") and primitive.setAttribValue(my_string) I found sth similar to this on this forum also, which I cannot find now for some reason. I find it again, I will update this post Quote Link to comment Share on other sites More sharing options...
tricecold Posted September 4, 2015 Author Share Posted September 4, 2015 Something along those lines Run Over Points should do the trick: string groupName = chs("groupnamepattern"); int groupCount = chi("groupcount"); for(int i = 0; i < groupCount; i++) { string formattedName = sprintf("%s%d", groupName, i); int success = inprimgroup(@OpInput1, formattedName, @primnum); if (success) s@groupname = formattedName; } groupCount expression: groupCount = argc(primgrouplist(opinputpath(".", 0))) groupName is partial name, so if you have 100 groups called id_number, you want to put there only id_ Like I said, I got it working with pyhton, but it feels like its too slow, and I am really bad at python, so I would like to do this is vex, so I tried your code but the code returns groupname attribute empty what I dont understand is; there is one string and one integer you declare that should be a channel on the wrangle node or groupnamepattern and groupcount are already avaliable by default from Houdini. as far as I understood argc primgrouplist will get the numbers of total groups to run define the loop amount, but since every point has a group i use @ptnum instead. so I think I failed to understand the groupnamepattern part, I made a string input in my wrangle, and since my groups are named like object_something_IDmetal_shape , when I put in my string ID, it does not return anything Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted September 4, 2015 Share Posted September 4, 2015 (edited) Group names are the same on each point? Do you have some common name there or does it change completely, not only by number at the end of group name?It you don't have common name, than you will need to use python. You really don't want to do any too complicated string formatting in VEX. If you can't share the original file, can you copy group names to some simple geometry, lock it and attach here, so we could look? EDIT: Or just grab all group names with Python and pack them into string field on AttribWrangle, and then split this field text in Vex and run over each string from it. string groupnames = chs("groupnames"); string groups[] = split(groupnames); foreach (string group; groups) { // if point in group // transfer name to point } than you can run over any group name and don't care about any common pattern in name. Edited September 4, 2015 by fântastîque Mântragorîè Quote Link to comment Share on other sites More sharing options...
tricecold Posted September 4, 2015 Author Share Posted September 4, 2015 The object can have 1000 or 100000 points with random amount of group names ( group names are due to alembic being set as Name Group using Shape node Name), Some can be cityname_streetname_road_IDconcrete_shape cityname_streetname_bench_IDwood_shape cars_brand_IDmetal_shape building_floor01_furnitures_IDplastic_shape etc etc, IDmaterial could be after 2nd underscore, or 3rd or 4th, depends on how deep is the asset in the maya scene. I cannot upload anything from work, but I will make an example file at home. I will continue to use python then, thnx a lot for the input. Quote Link to comment Share on other sites More sharing options...
Guest mantragora Posted September 4, 2015 Share Posted September 4, 2015 I hope it helps... group_to_attribute.hipnc Quote Link to comment Share on other sites More sharing options...
tricecold Posted September 4, 2015 Author Share Posted September 4, 2015 thanks man. really appreciated, it works wonderfully Quote Link to comment Share on other sites More sharing options...
anim Posted September 4, 2015 Share Posted September 4, 2015 can't you just use path attribute that alembic sop automatically spits out? then you can just filter that string and do whatever you need, I use that all the time instead of groups 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.