How to merge Objects and preserve materials?

   5161   4   3
User Avatar
Member
5 posts
Joined: March 2018
Offline
When Merging (using the Combine tool) Objects at Obj level, the materials set in Obj level is not retained down to SOP level.
In all other 3D packages Max, Maya Cinema 4D, the Materials gets transfered from “Object Level” to “Polygon selection/Cluster level”.

For us, that are dealing with CAD data and FBX files with alot of objects this is very important to reduce the complexity etc.
It should be possible to do this in Houdini and not being dependent on first bringing the files into Maya or C4D for cleaning.

As a possible workaround, i have noted that if the object has a material on SOP level it is not lost when Combining.
Is there a way to transfer materials that is set at Obj down to SOP material?

Thanks for any help!

Daniel
User Avatar
Member
385 posts
Joined: Nov. 2016
Offline
You could create material nodes in your objects before merging to set it as a primitive attribute. Use `chsop(“../shop_materialpath”)` as the material name to reference it from the object node.
User Avatar
Member
7755 posts
Joined: Sept. 2011
Online
On your object merge, check ‘Pack Geometry Before Merging’ and be sureh that ‘Add Path Attribute’ is enabled.

Append a primitive wrangle and insert the code:

string @path;
s@shop_materialpath = chs(@path+"/../shop_materialpath");

Depending on if your merge was pointing to the sop inside the object or the objects themselves, the path may or may not end in the object name. If the path ends in the object name, you can omit the ‘/..’ from the last line of the code. If your paths are mixed and matched, you may want to use a python sop instead and loop over the paths in a more programmatic way.

Edit: There appears to be a bug with the path generated when using wildcards. If using a wild card in your object merge's object pattern, enable ‘create Per-primitive path’ and use the name specified in the ‘path attribute’ parameter (objname by default) in place of ‘path’ in the code above.
Edited by jsmack - May 10, 2018 18:14:41
User Avatar
Member
5 posts
Joined: March 2018
Offline
Hi,

Thanks!, I will try it as soon as I have the time.
User Avatar
Member
85 posts
Joined: April 2017
Offline
jsmack
On your object merge, check 'Pack Geometry Before Merging' and be sureh that 'Add Path Attribute' is enabled.

Append a primitive wrangle and insert the code:

string @path;
s@shop_materialpath = chs(@path+"/../shop_materialpath");

Depending on if your merge was pointing to the sop inside the object or the objects themselves, the path may or may not end in the object name. If the path ends in the object name, you can omit the '/..' from the last line of the code. If your paths are mixed and matched, you may want to use a python sop instead and loop over the paths in a more programmatic way.

Edit: There appears to be a bug with the path generated when using wildcards. If using a wild card in your object merge's object pattern, enable 'create Per-primitive path' and use the name specified in the 'path attribute' parameter (objname by default) in place of 'path' in the code above.


Is there an easier way of doing this?
  • Quick Links