Delete unused materials

   5110   4   2
User Avatar
Member
1268 posts
Joined: 3月 2014
Offline
Is there a function to delete all unused materials that I am missing in H15?
Werner Ziemerink
Head of 3D
www.luma.co.za
User Avatar
Member
1755 posts
Joined: 3月 2014
Offline
An option to display only the used, unused or all materials would be more useful, because then it's a simple matter of selecting them and deleting them all (whatever “all” might refer to - unused, etc)
User Avatar
Member
665 posts
Joined: 11月 2013
Offline
McNistor
An option to display only the used, unused or all materials would be more useful, because then it's a simple matter of selecting them and deleting them all (whatever “all” might refer to - unused, etc)

But it only work with material that assign to whole Object. Not showed those reference by Material Sop.
User Avatar
Member
2638 posts
Joined: 6月 2008
Offline
It could be scripted. Simply scan all nodes by children looking for node types of Material. Or work backwards, scan for all SHOP type nodes, collect up shader node names and then scan for matches.

Blender has a nice feature that is part of each node/datablock. It is simply a user count. When count is zero there are no users of that data and it can be safely removed from the scene.

Not sure how that would affect delayed load items, however…
Using Houdini Indie 20.0
Windows 11 64GB Ryzen 16 core.
nVidia 3050RTX 8BG RAM.
User Avatar
Member
320 posts
Joined:
Offline
I have a feeling it probably isn't simple to account for all the possible ways a material is being used, hence the option for mantra to embed all materials in the scene into the IFD… otherwise there would probably already be code in SOHO to find them more efficiently.

You could script for the simplest case pretty easily, just check for a “shop_materialpath” parameter on object nodes and delete any nodes that aren't referenced there.
  • Quick Links