How to delete a RenderMaterial

Hi - I’m sure this is obvious, but I cannot see how to do it. How can I delete a RenderMaterial material via RhinoCommon pls?

Thanks

Paul

Hi Paul,

the material table has a DeleteAt method to which you can provide a material index. Note that it is still kept for Undo purposes, so you may need the IsDeleted property of a material if it still is listed when iterating over the runtime material table.

c.

Thanks - could you show a code sample for this pls? I have a RenderMaterial which I want to delete, but it’s Guid is not present in the Rhino.RhinoDoc.ActiveDoc.Materials table, so how can I determine the index to delete?

Paul

Hi Paul, i do not have a RhinoCommon example.Once you created the RenderMaterial, don’t you get a instance id so you can delete using DeleteContent(strContentInstanceID) ?

@andy, could you help here ?

c.

This is not implemented in Rhino 5. It is RhinoDoc.RenderMaterials.Remove in V6

Thanks - for clarity, is it NOT possible to delete a RenderMaterial? @andy

The reason is - I am trying to resolve the problems caused by Importing a 3dm results in duplicate RDK materials and the only way to do it is to find all RenderMaterials with the same hash and name and delete them, but if it’s not possible to delete them I have a problem.

Paul

Paul

Yes - I’m sorry about this. It was an oversight in Rhino 5.

I would still suggest you ensure that the contents of your buffer are the same for similar materials - even if the name is different. If I remember correctly, you store the material name in the buffer - and this is why you get a different hash.

  • Andy

Thanks @andy but I have triple checked, and the imported material has exactly the same name, and exactly the same contents as the existing material, but they have different hashes. So it creates a ton of duplicate materials when importing a scene. I have written a C# function to identify the duplicates, and reassign the meshes to use the original RenderMaterial, but I cannot delete the now unused duplicate.

Paul

Paul

This seems like something I need to look into. Can I get a copy of Octane to test with? And some instructions to repeat it (written for idiots!)

_Andy

This is very encouraging! Be careful Andy, you might get addicted to Octane, I sure did.

Paul, hope you and Andy can work this out. I can provide large yacht models that must surely have thousands of the sort of material defs that are under discussion here. That really slows down a very fast renderer. Good luck.

@andy you can download the demo version at https://render.otoy.com/plugindownloads/80/3b/81/d3/OctaneRenderForRhino_3_3_2_68_DEMO.rhi . You will need to run it on a PC with an Nvidia graphics card, with Nvidia driver 358.50 or later installed.

Then load Dropbox - File Deleted - Simplify your life into Rhino, then Import Dropbox - File Deleted - Simplify your life and you will see the duplicate Octane materials.

Paul

@andy any news on this pls?

Paul