Get Full Path of PBR Textures

Hoping someone can help me with this. Trying to write a script to consolidate all the textures used by a Render Material into one folder. Often times I’m pulling from a library but need to consolidate for downstream applications. It’s been easy to implement with the standard Rhino materials, but we’ve been using the new PBR material in the WIP and would love to be able to pull roughness, metal etc.

I’ve gotten as far getting the textures used by the materials, but got lost getting the full file path using the texture class and FindReference method


import Rhino.Render as rr
import scriptcontext as sc

for mat in sc.doc.RenderMaterials:
    mc = mat.GetTextureFromUsage(rr.RenderMaterial.StandardChildSlots.Diffuse)
    mm = mat.GetTextureFromUsage(rr.RenderMaterial.StandardChildSlots.PbrMetallic)
    mr = mat.GetTextureFromUsage(rr.RenderMaterial.StandardChildSlots.PbrRoughness)
    mn = mat.GetTextureFromUsage(rr.RenderMaterial.StandardChildSlots.Bump)
    if mc:
        print mc.Name
    if mm:
        print mm.Name
    if mr:
        print mr.Name
    if mn:
        print mn.Name

You can use something like below C# snippet:

			Material interim = rm.SimulatedMaterial(RenderTexture.TextureGeneration.Allow);
			if (interim.IsPhysicallyBased && interim.PhysicallyBased is Rhino.DocObjects.PhysicallyBasedMaterial pbrmat) {
				Rhino.DocObjects.Texture metallictex = pbrmat.GetTexture(TextureType.PBR_Metallic);

Thanks Nathan. This got me exactly where I needed to go.