Hello, I'm not well versed in this aspect of houdini yet need to manipulate some data coming in from alembic which was written out of maya. The (many) objects in the file follow this pattern "/Boy_B_rig_v001:body_SUBD/Boy_B_rig_v001:body_SUBDShape" What I want to do is take the first part "Boy_B" and write that as a new name, so the alembic rop at the end writes out a "washed" abc that only has the names without the rest of the garbage. I would also be fine with just maintaining the first namespace which is "Boy_B_rig_v001" and write that for every object in the incoming abc.
What would be the workflow for this? Any help would be greatly appreciated.
Renaming objects in alembic files
301 5 2-
- larkis
- Member
- 36 posts
- Joined: 3月 2014
- オフライン
-
- Italimpex Productions
- Member
- 11 posts
- Joined: 8月 2021
- オフライン
Hello. I recommend splitting the attribute by a colon so it becomes Boy_B_rig_v001. It will get complicated if we try to shorten further than that. I assume other objects are going to follow the same naming convention, and it's always useful to keep the version. Drop down a Primitive Wrangle node and paste the code below. It will split the path attribute by the colon sign, take the first item of the created array, delete remaining slashes, and store it into the path string. (If your geometry uses the name attribute instead of path, just swap s@path for s@name in the code).
I hope this helps!
s@path = strip(split(s@path, ":")[0], "/");
I hope this helps!
Italimpex Productions
CGI Studio specializing in directing and producing advertisements & films
CGI Studio specializing in directing and producing advertisements & films
-
- larkis
- Member
- 36 posts
- Joined: 3月 2014
- オフライン
Italimpex Productions
Hello. I recommend splitting the attribute by a colon so it becomes Boy_B_rig_v001. It will get complicated if we try to shorten further than that. I assume other objects are going to follow the same naming convention, and it's always useful to keep the version. Drop down a Primitive Wrangle node and paste the code below. It will split the path attribute by the colon sign, take the first item of the created array, delete remaining slashes, and store it into the path string. (If your geometry uses the name attribute instead of path, just swap s@path for s@name in the code).s@path = strip(split(s@path, ":")[0], "/");
I hope this helps!
Thank you. I ended up doing something similar because I needed to have the name repeated twice in order for maya to pick up the names
string raw = s@path;
string first = split(raw, "/");
string ns = split(first, ":");
s@path = "/" + ns + "/" + ns;
This gives me Boy_B_rig_v001/Boy_B_rig_v001 which works. Just curious, why did you use the strip function instead of just splitting the string directly?
-
- Liesbeth_Levick
- スタッフ
- 123 posts
- Joined: 6月 2024
- オフライン
Edit: I started writing this before your reply and only saw it after I posted it.
It's not entirely clear to me from your post what you are trying to do. Do you want your final attribute to be "Boy_B_rig_v001"? Because then the reply above will work. However, it seems more likely to me that you would want to extract the useful name from each object such as "body". If that is the case here are some things you can do.
If your path isand you want a name attribute then you can use a Muscle ID SOP with the Attribute Name set to `name` , Initialize from Input Attribute Toggled on, and Element Pos fom End set to 1. This will extract the second to last entry in the path attribute and store it as a name attribute.

If you wanted to clean the namespace from the name then you can use an Attribute String Edit SOP. Specify `name` in the Primitives field, and then it the Editor tab, in the From field put "Boy_B_rig_v001:*", and in To put "*". If you also wanted to remove the "_SUBD" you can instead put "Boy_B_rig_v001:*_SUBD" in the From field.

If you want your name to overwrite your path attribute, then you can use an Attribute Rename SOP, go to the Primitive tab, specify your From/To attributes, and toggle on Overwrite Existing Attributes.

Hope that answers your question!
It's not entirely clear to me from your post what you are trying to do. Do you want your final attribute to be "Boy_B_rig_v001"? Because then the reply above will work. However, it seems more likely to me that you would want to extract the useful name from each object such as "body". If that is the case here are some things you can do.
If your path is
/blah/blah../blah/Boy_B_rig_v001:body_SUBD/Boy_B_rig_v001:body_SUBDShape
Boy_B_rig_v001:body_SUBD
If you wanted to clean the namespace from the name then you can use an Attribute String Edit SOP. Specify `name` in the Primitives field, and then it the Editor tab, in the From field put "Boy_B_rig_v001:*", and in To put "*". If you also wanted to remove the "_SUBD" you can instead put "Boy_B_rig_v001:*_SUBD" in the From field.
If you want your name to overwrite your path attribute, then you can use an Attribute Rename SOP, go to the Primitive tab, specify your From/To attributes, and toggle on Overwrite Existing Attributes.
Hope that answers your question!
Edited by Liesbeth_Levick - 昨日 13:08:37
Liesbeth Levick
Technical Director: CFX
SideFX
Technical Director: CFX
SideFX
-
- Italimpex Productions
- Member
- 11 posts
- Joined: 8月 2021
- オフライン
In my code the order of execution is
1. split(s@path, ":") which splits s@path into 3 strings ( /Boy_B_rig_v001, body_SUBD/Boy_B_rig_v001, body_SUBDShape )
2. extracts the first item /Boy_B_rig_v001
3. and last comes strip() which only removed forward slash. It's an optional step. Leaving it out wouldn't make a practical difference. Path would just remain /Boy_B_rig_v001 instead of Boy_B_rig_v001. ROP Alembic will add a leading slash anyway.
Either way, in ROP Alembic, you must check "Build Hierarchy from Attribute" toggle with Path Attribute set to "path" to actually write to disk with that modified path attribute. Otherwise Houdini will generate default internal path like "/geo1/attribwrangle1".
In your code you could completely drop that second line and write it like this:
I hope this helps!
1. split(s@path, ":") which splits s@path into 3 strings ( /Boy_B_rig_v001, body_SUBD/Boy_B_rig_v001, body_SUBDShape )
2. extracts the first item /Boy_B_rig_v001
3. and last comes strip() which only removed forward slash. It's an optional step. Leaving it out wouldn't make a practical difference. Path would just remain /Boy_B_rig_v001 instead of Boy_B_rig_v001. ROP Alembic will add a leading slash anyway.
Either way, in ROP Alembic, you must check "Build Hierarchy from Attribute" toggle with Path Attribute set to "path" to actually write to disk with that modified path attribute. Otherwise Houdini will generate default internal path like "/geo1/attribwrangle1".
In your code you could completely drop that second line and write it like this:
string raw = s@path; string ns = split(raw, ":")[0]; // returns "/Boy_B_rig_v001" s@path = ns + ns; // previous line carries a slash (/Boy_B_rig_v001) so we don't write "/" + ns + "/" + ns
I hope this helps!
Edited by Italimpex Productions - 昨日 12:19:47
Italimpex Productions
CGI Studio specializing in directing and producing advertisements & films
CGI Studio specializing in directing and producing advertisements & films
-
- larkis
- Member
- 36 posts
- Joined: 3月 2014
- オフライン
-
- Quick Links


