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 10:29 AM

Thanks Y-Phil. Your caution about file path separators is important. I have been using os.path.join() to make sure that the separators are correct.

I had been using inp.SetString(".....") to set the value, as the documentation that I have does not mention any inp.SetValue. I had been looking for something like that. However, when I tried the SetValue() method, I got the error:

Traceback (most recent call last):

  File "/Users/jim/Library/Mobile Documents/com~apple~CloudDocs/Documents/Docs/Tech/Poser/Vic 4/Runtime/python/InTest.py", line 59, in <module>

    inp.SetValue(newFullPath)

AttributeError: 'poser.ShaderNodeInputType' object has no attribute 'SetValue'

So apparently, SetValue() doesn't exist on my version of Poser Python, which is in Poser 12 running on a Mac.

My problem with SetString() is that I get inconsistent results. Sometimes I even reboot and run the script again, and it comes out differently. There are two inconsistencies:

1. Sometimes the new string that is set into the Image_Source is the correct complete string. Sometimes it is just the file name, with all of the leading folders stripped off.

2. Sometimes the Image_Source data is updated. But more frequently the data is not actually updated at all-- so I do not effect any change.

------------

The context may be contributing to the confusion. I created a Python folder in my main runtime (not the one and the same folder as the app). I put this script in that folder. I then call the script from a specially-created shell .mt5 or .mc6 file. When I double-click on that materials file in the Poser library panel, it loads and the script is called.

What I am trying to do is to change the texture map without changing the transparency map. Or, alternatively, to change the transparency map without changing the texture map.

I have actually gotten this to execute correctly with an .mt5 file. So I have my hopes up that I may be getting close. But the script only if I have the Preview material selected (or, if I am in the Pose room, I respond to Poser's dialog box by saying 'Apply to Preview Material'). If I have the actual material to be changed selected, it does not change the Image_Source data. Frustrating, but at least I have detected a pattern there.

I have not yet gotten it to work at all from a similarly constructed shell .mc6 file.

----------

Any more ideas?