Preserve maya hierarchy

   1316   1   0
User Avatar
Member
33 posts
Joined: 5月 2015
Offline
Hello,

is there a way to preserve Maya hierachy upon "Baking Asset" from an houdiniEngine's Hda in maya?

All hierarchy is merged when using "Bake Asset" from houdini node.
Seems like I can use maya "Mesh -> separate" to separate mesh after baking, but I have no clue to associate baked meshes from the source ones. (used HDA's 'Split geos by group option')

I wished I could have set an attribute on original meshes in maya (ex; current path attribute) so I could have retrieved them in the baked geos (bake asset) and set meshes back to their original hierarchy/named upon baking.

Any workaround exists?

thanks
Jonathan
User Avatar
スタッフ
451 posts
Joined: 8月 2019
Offline
It's not pretty, but it's possible.

When a hierarchy is passed from Maya to Houdini, the primitive name attribute will describe the hierarchy.

Eg:
"|pSphere1|pSphere2|pSphereShape2"

In your asset, right before you output it, do the following:

Put down a primitive wrangle and enter:
s@safename = replace(s@name, "|", "ZZ");

This will produce a safename attribute with names such as:
"ZZpSphere1ZZpSphere2ZZpSphereShape2"

Now, add a Groups from Name node and specify the safename attribute, which will convert the primitive name attribute to groups with the same name. We needed to create the safe name as pipe characters cannot be used in a group name.

Now, in Maya, if you turn on "Split Geos By Group", it will split the objects based on these strings, giving you objects such as:
"|myAsset|myAsset|ZZpSphere1ZZpSphereShape1_1"

Now, all you need to do is bake the asset, chop off the prefix and _# at the end and replace the "ZZ" characters with "|" to get the original path of the objects.

If you're feeling adventurous, you could try and wrap this final process up into the post-sync callback. https://www.sidefx.com/docs/maya/_maya__scripting.html#Maya_Scripting_Mel_Callbacks [www.sidefx.com]
Edited by johnmather - 2023年5月9日 19:17:20
  • Quick Links