How to get textures settings from code?

How to get settings of texture?

@andy is this something you can help with? Jane is using C#…

@Zombik,

i am not quite sure if this is the right way to do it but below seems to work using RhinoCommon via Python. It lists materials with assigned bitmap-texture then prints the repeat, offset and rotation vectors. Note that if you use 3d textures there may be more values to print:

import Rhino
import scriptcontext
    
def DoSomething():
    
    for m in scriptcontext.doc.RenderMaterials:
        tex = m.FindChild("bitmap-texture")
        if tex != None:
            print "Material-Name:", m.Name
            print "Texture-Name:", tex.Name
    
            # get field values
            repeat = tex.GetRepeat()
            offset = tex.GetOffset()
            rotation = tex.GetRotation()
    
            # print field values
            print "U-Repeat:", repeat.X
            print "V-Repeat:", repeat.Y
            print "U-Offset:", offset.X
            print "V-Offset:", offset.Y
            print "Rotation:", rotation.Z
    
if __name__=="__main__":
    DoSomething()
 

i guess instead of using scriptcontext via python scripting like this:

scriptcontext.doc.RenderMaterials

you might have to access the render material table using the Item index to get a single material in C#. From there you might get the texture slot etc. as shown above. I´ve found the render texture methods here.

c.

2 Likes

I was searching it, but found just basic settings of texture.

thanks a lot