Forum: Poser Python Scripting


Subject: Modifying Materials

JimX opened this issue on Jun 06, 2023 ยท 7 posts


JimX posted Tue, 06 June 2023 at 2:57 PM

I did some Python scripting for another application a few years ago. The Python knowledge is coming back just fine, but I am slowly slogging up the learning curve for the Poser classes and methods. I've studied the pydoc, and I've looked at a lot of sample scripts. I am using Poser 12 on a Mac.

My project involves changing the Texture Map (and maybe later, some other maps) on an object. I wrote a quick script to test my understanding of the process:

import poser

scene = poser.Scene()

actor = scene.CurrentActor()

mtl = actor.Material('hair')

mtl.SetDiffuseColor(0.5, 0.0, 0.0)

print ('Diffuse Color should have been set')

print ('Texture before =', mtl.TextureMapFileName() )

mtl.SetTextureMapFileName('/Users/Shared/Poser 12 Content/Downloads/Runtime/textures/KozHair/KyokoHair_Mk2/KyokoHr2TxBlondGold.jpg')

print ('Texture after =', mtl.TextureMapFileName() )


I have a basic scene with on Victoria 4 figure and one prop-style hair object parented to it. I have the hair selected, and in the Material Room I have the "hair" material selected. There is the Poser_Surface node, and three image nodes (one each for texture map, specular map, and transparency map). When I run the script, I get

Diffuse Color should have been set

Texture before = /Users/Shared/Poser 12 Content/Downloads/Runtime/textures/KozHair/KyokoHair_Mk2/KyokoHr2TxBlack.jpg

Texture after = /Users/Shared/Poser 12 Content/Downloads/Runtime/textures/KozHair/KyokoHair_Mk2/KyokoHr2TxBlondGold.jpg


So some texture map path somewhere seems to have been changed.

However, the Diffuse_Color on the Poser_Surface node has not changed at all. Nor have any of the texture maps in either of the image_map nodes changed (they are still exactly what was printed on the "Texture before = " line).

Clearly, my understanding of the process still needs some help. Does anyone have any pointers?

Many thanks for any suggestions.