Doc.RenderMaterials Children

Any one know where I can find a list of the children of scriptcontext.doc.RenderMaterials:

I have “bitmap-texture” for the color bitmap

but would also like to get the transparency and bump maps?


For a RenderMaterial use GetTextureForUsage

Here a short script that gets that diffuse texture:

It should give you enough info to get started.

Hi Nathan

So I have this script for resetting the repeat of a color bitmap on a material but I want to do the same for the bump bitmap and for the transparency bitmap?

  for m in scriptcontext.doc.RenderMaterials:
    tex = m.FindChild("bitmap-texture")
    if tex != None:
        repeat = tex.GetRepeat()
        tempx = repeat.X
        tempy = repeat.Y
        if tempx!=1.0 and tempy!=1.0:
            reset = rg.Vector3d(1,1,0)

Thanks I advanced!

As I wrote use GetTextureForUsage() instead of FindChild(). From the documentarion you should be able to find the correct childslot enum values to use.

Ohh got ya, Thanks!

Diffuse 100 Corresponds to ON_Texture::TYPE::bitmap_texture.
Transparency 101 Corresponds to ON_Texture::transparancy_texture.
Bump 102 Corresponds to ON_Texture::TYPE::bump_texture.
Environment 103 Corresponds to ON_Texture::TYPE::emap_texture.

Im not sure im using it correct but I find it really hard to stuff in the SDK!

You should use the documentation pane in the Rhino Python Editor (which you get through command _EditPythonScript):

Once more the example script directly in this thread:

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino.Render as rr

for rm in sc.doc.RenderMaterials:
    rt = rm.GetTextureFromUsage(rr.RenderMaterial.StandardChildSlots.Diffuse)

    rt.SetProjectionMode(rr.TextureProjectionMode.MappingChannel, rr.RenderContent.ChangeContexts.Program)
    rt.SetMappingChannel(1, rr.RenderContent.ChangeContexts.Program)

Please pay attention to GetTextureFromUsage and the StandardChildSlots enumeration.

1 Like

As an extra bit of information: since the Python integration in Rhino is done with IronPython, a .NET implementation of Python, you have access to .NET, including the .NET SDK for Rhino called RhinoCommon. That is where you should be looking at for your API docs - it is what the tree I showed in the animated gif is generated from:

1 Like