Create material, apply to layer and export to rmtl file

It looks like this never worked in V5. Sorry.

@nathanletwory
Thanks for the help, one more thing. So i’m exporting information from RenderMaterials and so I want to stop the Purge command from removing materials which are not used by rhino project itself, but is used by my plugin. Maybe flag them as used, or maybe there is some for the OnPurgeEvent where I could maybe double-check and guard them or something like that?

Thanks again for the help!

EDIT: One more thing came up, how can I get the texture information based on the texture type. So basically I want to recreate something like the Get(Bitmap)/(Bump)/(Transparency)Texture functionality from the normal Material class.

You’d use the dashed version of -_Purge, which gives you the possibility to set option _Materials to _No.

As far as I know there is no way of overriding deletion of materials or other data in that manner. You probably could provide a purge button with your plug-in, one that has the option set. Or create your own purge command that calls the original Purge with the option.

To get texture information you use the three functions GetTextureOnFromUsage, GetTextureFromUsage and GetTextureAmountFromUsage with one of the RenderMaterial.StandardChildSlots entries. In RhinoCycles/Raytraced I use those like so:

Cool in rhino6 it looks promising, is there a way to do the GetTextureFromUsage, OnFromUsage in V5 API? I’m working on a plugin which supports both platforms as of now.

Should it be the GetChildSlotParameter functionality?
I tried it like this. (material is a type of renderMaterial)

var textureChildSlotName = material.TextureChildSlotName(RenderMaterial.StandardChildSlots.Diffuse);
var bitmapTextureFileName = material.GetChildSlotParameter("filename", textureChildSlotName);
var transp = material.GetChildSlotParameter("transparent-color", textureChildSlotName);
var fileNameAndExtension = Path.GetFileName(bitmapTextureFileName.ToString());

and I can’t get any parameter back from the Texture.

EDIT: In rhino6 i can get every information that I want, except that if i use GetParameter(paramName) on the RenderTexture itself i get a Rhino.Render.Variant back which says that it’s a type of string but I don’t know how to get the actual Value out.
But if i use the FieldsDictionary of the Texture with GetField(paramName) and GetValue() everything works like a Charm.

EDIT2: I can get the texture information in Rhino5 with FindChild(childslotname) and GetParameter.

1 Like