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:57 PM

" I assume I can get the script name and parse it down and remove the .py and add.pz2. Just name the script the same as the target pz2 file name. If that can be done then I have the data I need."

Yup, sort of like this:

import os
import string
import poser

ScriptHere = poser.ScriptLocation()  # full name
front,ext = os.path.splitext(os.path.normpath(ScriptHere)) # Split the extension from the rest
FileToPass=front + ".PZ2" # Add pz2 to the rest
fp=open(FileToPass,"wt") # Then write what you want in the file.
fp.write("bunch of other stuff")
fp.close()

My python page
My ShareCG freebies