Forum: Poser Python Scripting


Subject: Is it OK to take code from 2 scrripts and mix for personal use?

grichter opened this issue on Aug 22, 2007 · 7 posts


ockham posted Thu, 23 August 2007 at 9:06 PM

For passing a command to an external script, a file is simplest.   The
file could be anywhere, as long as both sides know the absolute
filepath.

In P7, the new function ScriptLocation() gives the full path of
where the script is actually running, and you can base the
filename on that location.  In earlier versions you have to use
a more complicated trick to get the actual location.

Free-standing scripts can use arguments just like the argv
setup in C, but I don't think that works well inside the Poser system.
I remember trying it once and abandoning it quickly.  Might be
a way to do it in newer versions, though ... and there's undoubtedly
a way to pass using sockets, but that requires more overhead
than a file.

Also, look at the Pickle module in Python ... it gives you a way to write
any combination of structures (lists, arrays, etc) into a file,
then read the file directly out into the same combination.
Much easier than setting up your own text format when you need 
to pass a complicated set of variables from one script to another.

My python page
My ShareCG freebies