Forum: Poser Python Scripting


Subject: Apply a graphic (Image Map) to the 'diffuse color'

timarender opened this issue on Jul 13, 2012 · 4 posts


timarender posted Fri, 13 July 2012 at 6:13 AM

Please excuse me if I am using the wrong terminology.

I want to apply a graphic which is not a Material in the Library. Manually, I would open the Material room, create an 'Image Map', choose the selected graphic; and then apply the image map to Diffuse Color.

Using script, I could use "LoadMaterialCollection" to apply a material from the Library. But that does not work with a graphic outside the Library, eg:  d:tempa.jpg

Can anyone point me in the right direction, please.

Alternatively; is there a scripting way to take a bunch of graphic file and convert them into materials?

I appreciate all this may involve itinerating through materials etc. But, I am really getting lost in the Poser Python manual.

Thanks for any assistance.


millighost posted Fri, 13 July 2012 at 8:42 AM

It should roughly look like this:

import poser

scene = poser.Scene ()

use the currently selected actor

actor = scene.CurrentActor ()

use the first material that is there:

material = actor.Materials ()[0]

manipulate the shader tree...

shader = material.ShaderTree ()

create a new image map

image_map = shader.CreateNode (poser.kNodeTypeCodeIMAGEMAP)

set the path of the image_map

path_input = image_map.InputByInternalName ("Image_Source")
path_input.SetString ("d:my_image.png")

connect the nodes

surface = shader.NodeByInternalName ("PoserSurface")
shader.AttachTreeNodes (surface, "Diffuse_Color", image_map)


timarender posted Fri, 13 July 2012 at 9:28 AM

That was very helpful. Thank you very much for taking the time to assist me.


bagginsbill posted Fri, 13 July 2012 at 11:28 AM

Even easier with matmatic. It's a one-liner.

for name in os.listdir("some folder here"): if name.endswith(".jpg"): outputs += ["=Material[%s]" % name, Surface(ImageMap(name), .8)]

Of course I'm just showing off and that's not really a finished script as there would be some manipulation of the path name. But the part of making the material for each image file is correct:

Surface(ImageMap(imageFileName), .8)


Renderosity forum reply notifications are wonky. If I read a follow-up in a thread, but I don't myself reply, then notifications no longer happen AT ALL on that thread. So if I seem to be ignoring a question, that's why. (Updated September 23, 2019)