View Full Version : Materials
10-01-2010, 07:45 AM
I'd like to be able to access the material information for an object that determines how it is displayed in the rendered viewport. That is, the information set under object/properties/material.
Ive had a go through rhinocommon, and found Rhino.DocObjects.Attributes.MaterialIndex but cant figure out how to get to the actual material definitions via Rhino.DocObjects.Tables.MaterialTable.
Can you help?
10-04-2010, 11:46 PM
I still need to do a lot of work on the material class. I'll start looking into implementing the rhinoscript material functions and once those are in place, I can give some better insight on how to get at the materials with RhinoCommon. For now, there just isn't a whole lot in Material that you could actually use.
I have had a look a the rhino common but somehow I can't seem to get anything useful out of it.
Probably it is quite simple, I would like to get a list om materials or their id's, That I then can iterate though.
listNames = rs.Layernames()
for name in listNames:
...Do something with each layer
I too recently wanted to do some stuff with materials. Here is what I found:
-It seems that in the RDK is 80% integrated into the standard Rhino materials...so it depends on what you want to do as to whether you need to get material info from the Rhino Doc Material table, or the RDK.
-From a user perspective, an object can have the material assigned per object, or per layer (or per parent, but I never used this). However, it seems that from Rhino's point of view, an object has two materials, one assigned to object and one from layer. If the user has selected an object's material to be from layer, you have to first look at the materialSource to determine this. Then you have to find the layer that the object is on, then find the material of that layer. If you just get the material of the object in rhinocommon then you will just get the per object material, no matter what the user is wanting to use.
-The material table seems to be a big list of every material ever made in the document. Every time a material is made, or assigned to something, an entry gets added to this table. So expect a lot of redundant info here.
So to answer your question, this is how I would get the materials:
import rhinoscriptsyntax as rs
import scriptcontext as sc
materialTableList = sc.doc.Materials
for material in materialTableList:
#do stuff with material such as-
This might not be the most super-correct way, but it works for me. For my uses (material converter) I wound up getting material data from the RDK, which is completely different. If you need to do this then look here:
and be prepared to spend many hours trying to figure stuff out. At least it took me many hours, but it did eventually work.
I am still trying to figure out how to add user text to a material. If anyone would like to chime in on this then it would be appreciated!
Powered by vBulletin™ Version 4.0.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.