Forum: Poser Python Scripting


Subject: Need help, can this be done?

MaskimXul opened this issue on Feb 26, 2011 · 11 posts


markschum posted Sat, 26 February 2011 at 4:54 PM

here is one that looks for an image map name and replaces it , might not be quite what you want.

sorry for the name error , O am not at my poser machine so I am working from memory.

 

searches tree for all materials in figure and replaces named file with new file name

save as material collection to save running script again

import poser

file name used

myimgname = "c:/program files/e frontier/poser7/runtime/textures/oldimgname.jpg"   

new file name to be used

newimgname = "c:/program files/e frontier/poser7/runtime/textures/newimgname.jpg"  
scn = poser.Scene()
fig = scn.CurrentFigure()
mats = fig.Materials()
for mat in mats:
    print mat.Name()
    tree = mat.ShaderTree()
    nods = tree.Nodes()
    for nod in nods:
        if nod.Type() == poser.kNodeTypeCodeIMAGEMAP:
            img = nod.Input(0).Value()
            print img
            if img == myimgnam:
                nod.input(0).SetString(newimgname)     
    tree.UpdatePreview
scn.DrawAll()