Trying to read a value from rmtl file



I’ve created a custom material (Rhino.Render.RenderMaterial) with different parameters added to Rhino UI like this:

var reflectance_field = Fields.Add(REFLECTANCE_COLOR_FIELD, my_Color4f, "Reflectance Color"); //Rhino.Render
        BindParameterToField(REFLECTANCE_COLOR_FIELD, reflectance_field, ChangeContexts.UI); //Rhino.Render.RenderContent

With this parameters I haven’t any problem, Rhino saves and loads it flawlessly from the rtml file…

I have also a custom ComboBox (Windows.Forms.UserControl) with an array of strings, the idea is take the selected string and save it with the other fields in a rmtl file. The problem is how to read back the stored value and show it in the ComboBox.

By creating a Field with:

Fields.Add("material", Material); //string

and setting its value when the combo changes I wrote my value in the file but I can’t read it. I tried to use the RenderContent.GetParameter(“material”) function, but it didn’t work… Can you help me?

Thank you!

(Dale Fugier) #2

@andy, is this something you can help with?

(Andrew le Bihan) #3

Could you put together a sample project to demonstrate this? Have you tried it with another field name -“material” might be problematic.


My main objective is to read a custom parameter from any RTML file. I saw that the RTML file which Rhino creates when you export a material is a simple XML file. This XML contains a section called “Parameters” where are stored the parameters of the material. I have put a RTML file sample in pastebin, note the commented line that it’s the parameter I want to read:

I also have created a dummy project, hope it helps =) (9.0 KB)

Thanks for the replies.



Any news about that problem? @andy @steve​baer @dale

We need to work on it.



(Andrew le Bihan) #6


I’m sorry, I still don’t understand what you mean. If you want to read a value out of any RMTL file, then you’ve already answered your own question - use an XML parser to get at the node.

Or - if you want to get at parameters on the live RenderMaterial (ie - after the RMTL has been loaded into the material editor) use RenderContent.GetParameter.