I would like to make a list of all materials in a document (so I can change a value on all of them if the value is lower than 0) I can not find any ways to do this.
Thanks!
I would like to make a list of all materials in a document (so I can change a value on all of them if the value is lower than 0) I can not find any ways to do this.
Thanks!
Hi Jorgen,
Here is RS and RDK sample - RhinoScript itself does not handle all materials too well from what I tried so far, so its better to go using RDK, as cryptic as the documentation is. Obviously there must be better Python/RhinoCommon way to do it…
'get RDK Object`
Dim rdk : Set rdk = Rhino.GetPlugInObject("Renderer Development Kit")
'get list of all RDK data ids in the document
Dim rdkALL : rdkALL = rdk.FactoryList()
'filtered materials ID list
Dim arrMatIDList : arrMatIDList = rdk.ContentList("material")
'get materials names
Dim i,arrMatNames : arrMatNames = array(): ReDim arrMatNames(Ubound(arrMatIDList))
For i=0 To Ubound(arrMatIDList)
arrMatNames(i) = rdk.ContentInstanceName(arrMatIDList(i))
Next
hth,
–jarek
Excellent Thanks!
I had to dig into the documentation and use the .ContentInstanceName() and here is the python version:
import rhinoscriptsyntax as rs
#get RDK Object`
rdk = rs.GetPlugInObject("Renderer Development Kit")
#get list of all RDK data ids in the document
rdkALL = rdk.FactoryList()
#filtered materials ID list
arrMatIDList = rdk.ContentList("material")
print len(arrMatIDList)
#get materials names
arrMatNames = []
for i in range(len(arrMatIDList)):
arrMatNames.append( rdk.ContentInstanceName(arrMatIDList[i]) )
for i in range(len(arrMatNames)):
print arrMatNames[i]