Forum: Poser Python Scripting


Subject: runPythonScript not in docs-question

grichter opened this issue on Aug 31, 2007 · 3 posts


grichter posted Fri, 31 August 2007 at 9:31 AM

The command runPythonScript, which I have seen samples of and people use I can't find any reference to in P7 Python Methods Manual.

My key question actually is must myscript.py be located in the ":runtime:python:"  of the base runtime for the version of poser I am using or can it be elsewhere when called by the runPythonScript command? Like in a poser library folder for example?

Pages 1 and 2 of the manual talk about script locations in the script menu etc. But since I can't find a reference to the runPythonScript command I need a clarification. No where in the docs can I find verbiage that states a script must be in the root python folder to work.

I can run my script directly with it located elsewhere or outside the base runtime and in a library folder. It does work when located inside the python folder. But when I use relative or abosulte paths to a location outside the root python folder...nothing. So either I am missing a peice of code or it can't be done.

thanks

Gary

"Those who lose themselves in a passion lose less than those who lose their passion"


PhilC posted Fri, 31 August 2007 at 10:07 AM

runPythonScript is a command used within a Poser file such as a CR2, PZ2, MZ5 etc. It is not a Python method.

You can place scripts outside of the local runtime but you will need to include a file within RuntimePythonLibsite-packages to enable it to be recognised. See the README file within that folder for details. Although I have used this feature and found it to work I'm of the opinion that you need to have an outstandingly good reason to make it worth the trouble.

To get Poser to recognise scripts within the local runtime use:-

####################################
import os
import sys
import poser

pathname = os.path.split(poser.AppLocation())[0]
scriptPath = os.path.join(pathname, 'Runtime', 'Your Folder', 'Your sub folder')
sys.path.append(scriptPath)

####################################

Hope that helps.


grichter posted Fri, 31 August 2007 at 5:30 PM

I'll take your word for it and rethink what I want to do and try to keep it simple. Only for private use so if it is a little nutso, I am the only one that has to deal with any problems thanks

Gary

"Those who lose themselves in a passion lose less than those who lose their passion"