Forum: Poser Python Scripting


Subject: Useful Code Snippets

structure opened this issue on Jun 27, 2019 ยท 94 posts


structure posted Thu, 04 November 2021 at 5:45 AM Forum Coordinator

Get poser AppLocation outside of poser ( WINDOWS ONLY ) (you need to add this to POSER_FAKE by adp001, a separate file would be the best option probably. e.g. in the poser fake folder, add Applocation.py)

import winreg as reg
import POSER_FAKE as poser

class _REGISTRY:
    def _find_poser_win(self, version):
        # versions = ( 11, 12 ) # select version you want
        poser = r"SOFTWARE\Poser Software\Poser\Poser %d" %version
        with reg.OpenKey(reg.HKEY_LOCAL_MACHINE, poser ) as key:
            if poser.endswith( str(version) ) and key:
                return(reg.QueryValueEx(key, "InstallDir" )[0])

def AppLocation(installdirs = []):
    installdir = _REGISTRY()._find_poser_win(Version())
    if not installdir in installdirs:
        installdirs.append( installdir )
    return os.path.join(installdir, "Poser.exe")
print(poser.AppLocation())


Locked Out