Thu, Apr 18, 11:50 PM CDT

Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Mar 19 1:03 pm)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Using SciPy module in PoserPro2012


an0malaus ( ) posted Tue, 13 November 2012 at 11:13 PM · edited Mon, 25 March 2024 at 6:11 AM

Since PPro2012 now exposes most (but not all) of the ERC valueOp influences on a specified parameter, I was hoping to be able do do away with my linear regression "DialAndDelta" script to determine the actual parameter dial value, but unfortunately, SM have not implemented a method which exposes the interpolated influence of the valueOpKey ERC. Similarly, valueOpTimes and the various Divides can be calculated (except at their roots, i.e. y = x * 0 cannot be inverted to determine x from y due to a divide by zero).

Assuming that valueOpKey is interpolated as a cubic spline (I'm not 100% sure that it is), it should have been a (relatively) simple matter to import the numpy and scipy modules, populate the key, value arrays with the k, v pairs extracted from the relevant valueOpKey methods and call scipy.interp1d(), giving a function which can be used to interpolate the correct ERC influence of the valueOpKey at a given source parameter value, thus allowing the determination of the actual dial value of the parameter of interest.

Unfortunately, although the numpy module is bundled with PPro2012's python 2.7, scipy is not.

My question then, is, has anyone had success incorporating additional modules such as scipy from the standard python distributions into Poser? Does it require source or can binary modules be slotted into the python search path?



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


PhilC ( ) posted Wed, 14 November 2012 at 3:50 AM

You should be able to place the scipy module in site-packages and include a suitable .pth file

I've not done that in this version but by similar method I did add PIL to a previous Poser version. I would say therefore that its a reasonable assumption that the above will work in Poser Pro 2012.


an0malaus ( ) posted Thu, 15 November 2012 at 5:38 AM

Thanks PhilC, it's a bit of a struggle to match versions of inter-dependent modules, but I finally got to the point of importing SciPy and NumPy modules that will play nicely together. (If I just imported the latest scipy, numpy complained it was an older version and spat the dummy.)

Despite playing with .pth files and adding entries to the sys.path to try and force Poser to find a replacement numpy module before its own (within the app's site-packages directory), I ended up having to rename the Poser numpy directory to oldnumpy and then it happily (and silently) discovered the more recent version of numpy where I'd been telling it to look. I suspect that Poser's own internals might be hardwired to reference the "built-in" numpy, and unless you pull the plug on it, it won't find another numpy even if it's parent directory appears earlier in sys.path.

Of course, when I have to report a Poser bu## er, feature, I'll have to back out the oldnumpy change. :-/



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


FVerbaas ( ) posted Thu, 19 March 2020 at 5:47 PM · edited Thu, 19 March 2020 at 5:47 PM
Forum Coordinator

Diging up this old thread because I need some of the functionality in scipy.spatial.transform.Rotation

The part I need is not that large (get a rotation expressed in Euler angles in one order of roations expressed in another order of rotation axises), so question is whether to pull an old math book and program it or get scipy running.

Is it very difficult to get scipy in PoserPython? I need it for an own use tool only, not for distribution.


FVerbaas ( ) posted Thu, 19 March 2020 at 5:49 PM
Forum Coordinator

and of course I look at PoserPro 11.3, not Poser 2012,


an0malaus ( ) posted Sat, 21 March 2020 at 2:19 PM · edited Sat, 21 March 2020 at 2:23 PM

Given that there was a Poser update which did away with my pressing need to interpolate splines to find out the dial value of a parameter with valueOperation influence (the UnaffectedValue() method), I haven't needed SciPy for quite some time. However, that said, the biggest requirement was that the version of NumPy available matched that required by the SciPy module. I'll dig through my howto and post it here.

I'm doing other module inclusions in Poser via the soft link and module.pth method in site-packages (the path differs from Windows to MacOS on where this is). Until we get an update to Python in Poser, (I see beta test notes about Poser Python in Windows getting updated to 2.7.17, which will be useful if it comes to macOS as well) it requires the user to link from an OS level Python 2.7 installation (you can use pip or other package managers there, but pip within Poser Python is completely borked due to its TLS_1.0 protocol use being deprecated and now blocked by all the repository servers since April 2019, IIRC)

Here are my PIL replacement notes for macOS. The essentials will probably be the same for Windows, just the locations will differ.

Procedure to replace Poser Python's bundled PIL module with Pillow, to enable JPEG Image processing.

Having already installed the Pillow package in the macOS python framework, we need to tell Poser where to find it.

In a Finder window, navigate to /Applications/Poser 11/ and select Poser.app (or just Poser, if you haven't set the 
Finder to show hidden file extensions).
Control-Click (or two-finger-click) to bring up the contextual menu and select "Show Package Contents".
Within the current Finder window, navigate to Contents/Resources/site-packages/
In this folder you will see a PIL folder and a PIL.pth file, among other things.
Select the PIL folder, and rename it to 'oldPIL'.
Select the PIL.pth file, two-finger-click (or Control-Click) and choose Duplicate.
Select the PIL.pth file again, and rename it to 'oldPIL.pth'.
Select the 'PIL.pth copy' file, two-finger-click and choose 'Open With' to bring up the sub-menu.
If you see your preferred text editor, choose that, otherwise, choose 'Other ...' and select TextEdit from the dialog.
When the file opens, it should just have 'PIL' in it.
Select the entire line containing 'PIL' and delete it, as we will replace it momentarily.
Switch back to the Finder and open another window from the File menu's New Finder Window option (or press Cmd-N)
Navigate to the place where your macOS python Pillow package is installed. (On my system this is /usr/local/lib/python2.7/site-packages/PIL, so I go to /usr/local/lib/python2.7/site-packages)
Make sure you can see both the 'PIL.pth copy' text editor window and the Finder window with the PIL folder.
Drag the PIL folder from the Finder window to the text editor window and drop it.
That should give you a line similar to '/usr/local/lib/python2.7/site-packages/PIL'
Save the file and Quit the text editor.
In the original Finder window, select and rename the 'PIL.pth copy' file to just 'PIL.pth'
We cannot just Cmd-Option-Drag the PIL folder into Poser.app/Contents/Resources/site-packages, as that creates a MacOS Alias file, which the Finder knows how to resolve, but Python does not, and will be unable to find PIL at all, so we must resort to Unix shell commands to create a soft-link, which looks exactly the same in the Finder, but which Python can successfully traverse to load the PIL package.
In a new Finder window, navigate to the Utilities folder and run (Double-click) the Terminal application.
Copy the following lines and paste them into the terminal window:

cd /Applications/Poser\ 11/Poser.app/Contents/Resources/site-packages/
mv PIL oldPIL
ln -s /usr/local/lib/python2.7/site-packages/PIL
cp -p PIL.pth oldPIL.pth
echo '/usr/local/lib/python2.7/site-packages/PIL' >>PIL.pth

Quit the terminal application.
In your site-packages folder in the Finder, you should now see oldPIL, oldPIL.pth, PIL (with a curved arrow) and PIL.pth, plus whatever was there before.
Use the < button on the Finder window to navigate back out of the Poser.app Contents folder.

You should now be able to launch Poser and properly execute Python scripts which require working JPEG libraries with success.

NOTE: You will have to repeat this process every time you update Poser to a new version, as the installer will probably replace the link you created and the PIL.pth file you edited.

Here's the explanatory comment from the module I built to get dial values using SciPy to interpolate splines prior to UnaffectedValue() being implemented:

 PoserDialValue.py
 (c) 2014,2105 GeoffIX (Geoff Hicks)
 
 This module provides a function to determine (as accurately as possible) the actual dial setting
 of a Poser parameter value. Initial attempts to reverse the affects of ERC influence included in
 the parameter.Value() output were limited to linear regression. It is still not possible to fully
 account for the effect of parameter limit applied discontinuities in the inverse ERC function,
 but the recent exposure to python of parameter ValueOperations() has improved the situation greatly.
 As a consequence of the need to interpolate cubic and higher equations, numpy, scipy.interpolate
 and collections modules must be imported. Scipy is slightly problematic as it is not currently
 bundled with Python 2.7 libraries as used internally by Poser Pro 2014 and thus must be installed
 manually within Poser's python bundle. Note also that the quadratic spline interpolation (3 points)
 is not an accurate replication of Poser's interpolation which is currently undocumented.
 
 Using SciPy with Poser Python 2.7
 
 Procedure to allow PoserPro2012 on OS X to use SciPy python package for spline interpolation
 As determined by GeoffIX (Geoff Hicks) 15th November 2012
 
 *** WARNING: NOT FOR THE FAINT OF HEART ***
 
 Since SciPy relies on NumPy, the version of SciPy must be compiled against a compatible version of NumPy.
 Unfortunately, the NumPy bundled with PoserPro2012 is too old to support the latest builds of SciPy that
 work with the Python 2.7 installation bundled with PoserPro2012 and Mac OSX 10.7/8.
 
 Thus both SciPy and NumPy packages compatible with Python 2.7 need to be built and installed in Mac OS X's
 /Library/Python/2.7/site-packages/ folder
 
 Once that's done, we need to tell PoserPro2012 to use our newer version of NumPy and the SciPy package
 
 Python has several mechanisms to help it locate packages. The relevant one for this operation is the .pth file.
 Poser Python will also locate packages contained within a folder named for the package and containing an __init__.py
 file.
 
 Within the PoserPro2012 Application (Show Package Contents in the Finder) go to Contents/Resources/site-packages
 
 In here you will find a 'numpy' folder with PoserPro2012's bundled numpy package version 1.5.1 or so. This folder
 will need to be renamed ( to oldnumpy or somesuch ) or its existence will override the numpy.pth file we will create.
 
 Create a text file named scipy.pth with the content: (pointing to where you've installed the new scipy module)
 /Library/Python/2.7/site-package/scipy
 
 Create a text file named numpy.pth with the content: (pointing to where you've installed the new numpy module)
 /Library/Python/2.7/site-package/numpy
 
 NOTE:
 Every time you install an update to PoserPro2012, you will need to check whether a replacement numpy folder has been
 created in /Applications/Poser Pro 2012/Poser Pro 2012/Contents/Resources/site-packages to replace the one you
 renamed to oldnumpy and remove it. The installation process does not seem to remove any extraneous files, so the
 numpy.pth and scipy.pth added previously should remain untouched.

[Edited to get rid of the ridiculous monster font caused by the # comment prefix and the old backslash purge insanity in this forum]



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


an0malaus ( ) posted Sat, 21 March 2020 at 2:39 PM · edited Sat, 21 March 2020 at 2:41 PM

Hi @FVerbaas, I checked my Windows10 Bootcamp partition (Unfortunately broken by 1803 updates so I can't boot it to update Poser to 11.2/11.3) which still has the SmithMicro Poser 11.1 installed. The comparable site-packages for Poser lives in DriveLetter:\Program Files\Smith Micro\Poser 11\Runtime\Python\Lib\site-packages



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


adp001 ( ) posted Sun, 22 March 2020 at 1:54 PM

I didn't try it – but wouldn't it be easier to simply symlink the pathes into Poser? Or just overwrite the pathes of interest from Poser-installation (after a backup)? A little Python script can do this :)




an0malaus ( ) posted Sun, 22 March 2020 at 4:42 PM

Symlink is definitely the right concept, but may be foreign to macOS GUI only users who never need to go near a command line, so I wanted the process to be clear for those folks. My career background has been unix and PC, while mac is my hobby, so symlinks and vi are easy for me, but not for others.

For Poser's sake (until we get a refresh of the bundled Python), both the symlink and .pth file appear to be necessary.

@adp001, you mentioned in the other thread moving to Blender. Do you have a handle on how possible it is to transfer entire Poser scenes to Blender with full functionality?



My ShareCG Stuff

Verbosity: Profusely promulgating Graham's number epics of complete and utter verbiage by the metric monkey barrel.


adp001 ( ) posted Mon, 23 March 2020 at 12:40 PM

an0malaus posted at 6:24PM Mon, 23 March 2020 - #4384244

@adp001, you mentioned in the other thread moving to Blender. Do you have a handle on how possible it is to transfer entire Poser scenes to Blender with full functionality?

Possible? Yes, indeed. But not simple. I'm busy to study Blenders Python implementation (overwhelming complete). Poser's big advantage is the simplicity while posing figures. But why not use Poser exactly for this task? At least for the first steps? Converting shaders is mostly a laborious task. And some complicated arrangements may be not convertible at all. But the question is: Does it even make sense to translate complicated things, or shouldn't one use the better Blender system right away?




FVerbaas ( ) posted Mon, 14 September 2020 at 11:37 AM · edited Mon, 14 September 2020 at 11:37 AM
Forum Coordinator

I had shelved this project. It all got a bit more complicated than expected and real life got in the way anyhow.

Any idea whether we can expect these compatibility issues solved in Poser 12?


formoz ( ) posted Tue, 20 April 2021 at 5:42 AM

i spent some times to try to upgrade numpy 1.16.2 higher possible version with python 2.7.1 on poser 11.1.1.35510 without any success. Looks likes that DLLs (pyd and/or DLL) are the culprites. So i project to use "pipe" datas to my locally installed python 3.9 to work on with scipi.spatial calculations. Anyone of you tried the python mulit processing in Poser 11 ?


Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.