Forum: Poser Python Scripting


Subject: How to change an Image_Source path

JimX opened this issue on Jun 15, 2023 ยท 9 posts


JimX posted Fri, 16 June 2023 at 12:57 PM

Actually, I've got a lot of print statements in the code, for debugging purposes. Here are the results from one run:


Old path: /Users/jim/Library/Mobile Documents/com~apple~CloudDocs/Documents/Docs/Tech/Poser/Vic 4/Runtime/textures/KozHair/PonyTailHair/KptTailTXblack.jpg

New path: /Users/jim/Library/Mobile Documents/com~apple~CloudDocs/Documents/Docs/Tech/Poser/Vic 4/runtime/textures/KozHair/PonyTailHair/KptTailTXblond.jpg

ext name: PoserSurface int name: PoserSurface type: poser

ext name: Color_Texture int name: Image_Map type: image_map

Pre Path: /Users/jim/Library/Mobile Documents/com~apple~CloudDocs/Documents/Docs/Tech/Poser/Vic 4/Runtime/textures/KozHair/PonyTailHair/KptTailTXblack.jpg

Aft path: /KptTailTXblond.jpg

ext name: Transparency_Map int name: Image_Map_3 type: image_map

Pre Path: /Users/jim/Library/Mobile Documents/com~apple~CloudDocs/Documents/Docs/Tech/Poser/Vic 4/Runtime/textures/KozHair/PonyTailHair/KptTailTR.jpg

Aft path: /Users/jim/Library/Mobile Documents/com~apple~CloudDocs/Documents/Docs/Tech/Poser/Vic 4/Runtime/textures/KozHair/PonyTailHair/KptTailTR.jpg


(You may have to go to Full Screen for those long lines to make much sense)

The first line ("Old path:....") is what I am looking to change. It is in a local string property called oldFullPath.

The second line (" New path:....") is the value that I am trying to insert into the Image_Source data. It is in a local string property called newFullPath.

The third and fourth (and seventh) lines are just to make sure I am going where I was intending, as I looped through the Shader Nodes.

The fifth line is just print(inp.Value) ). It shows what was in the Image_Source before I did anything. One important thing is that it matches oldFullPath.

Then I executed:

if inp.Value() == oldFullPath:
inp.SetString(newFullPath)

The sixth line is the result of:

print('Aft path:', inp.Value() )

after having executed the inp.SetString(newFullPath) statement. This is one of those cases where Poser (or Python) also stripped off all of the leading folders.

The eighth and ninth lines are the Before & After for the next node I found. Since the Before path was not the same as the path I was looking for (oldFullPath), the Image_Source data was not changed. This is exactly what I intended.


By the way, I checked in Poser's Material Room after having run the script. The Image_Source data in the Shader Node that referenced the texture map that I was trying to change was still what it had been before executing the script. So even thought the inp.Value() seemed to have changed while running the script, the change did not stick.


If you have any ideas for where to go next, they would be most appreciated.

  - JimX