Forum: Poser Python Scripting


Subject: How do you avoid UAC problems writing to poser.AppLocation() subfolders ?

3dcheapskate opened this issue on Apr 23, 2020 ยท 38 posts


3dcheapskate posted Fri, 24 April 2020 at 9:38 AM

...and here the equivalent bit for the WorldBall script:

##################################
#    Functions: readWorldBallData()
##################################
# Set up the global envlist[] using data from WorldBallData.txt            
def readWorldBallData():
    envdatafile = ""
    filetocheck = ""
    # Check for the data file in the application location
    poserpath=os.path.split(poser.AppLocation())
    filetocheck =  os.path.join(poserpath[0],'Runtime','Python','poserScripts','3DCheapskate','WorldBall','WorldBallData.txt')
    if os.path.exists(filetocheck):
        envdatafile = filetocheck
    # Check for the data file in the mapped libraries (if already found we still check for multiple copies)
    try:
        aLibs = poser.Libraries()
        for lib in aLibs:
            filetocheck =  os.path.join(lib,'Runtime','Python','poserScripts','3DCheapskate','WorldBall','WorldBallData.txt')
            if os.path.exists(filetocheck):
                if envdatafile == "":
                    envdatafile = filetocheck
                else:
                    poser.DialogSimple.MessageBox("Multiple 'WorldBallData.txt' files found")
    except:
        pass
    # Return if we didn't find the file, open it and read all the data in if we did
    if envdatafile == "" or not os.path.exists(envdatafile):
        return False
    else:
        f = open(envdatafile)
        ...  

...which I think is basically the same thing.


The 3Dcheapskate* occasionally posts sensible stuff. Usually by accident. And it usually uses Poser 11, with units set to inches. Except when it's using Poser 6 or PP2014, or when its units are set to PNU or something else.
*soon only to be available in two flavours - 
 DAZ and Renderosity