Forum: Poser Python Scripting


Subject: set preview window dimension

markschum opened this issue on Sep 11, 2009 · 6 posts


markschum posted Fri, 11 September 2009 at 12:34 PM

Is there a way to set the preview window size from python.

poser.Scene().SetOutputRes(x,y)  does not set the preview window.

also , set end frame for animations ? how ?

thanks


nruddock posted Fri, 11 September 2009 at 1:34 PM

Quote - Is there a way to set the preview window size from python.

poser.Scene().SetOutputRes(x,y)  does not set the preview window.

I think it's possible for P8, but not earlier versions.

Quote - set end frame for animations ? how ?

I'm pretty sure that you can't change the number of frames directly via Python, but there may be a trick involving writing a temp file and then reading it.


markschum posted Fri, 11 September 2009 at 2:06 PM

ok, thanks


semidieu posted Fri, 11 September 2009 at 2:10 PM

SetOutputRes sets the rendering size, not the preview window. The only way I found to do it is to create a 'pose' file containing the doc size.

For the animations... I really don't know as I don't do them...


ockham posted Fri, 11 September 2009 at 9:40 PM

The temp PZ2 is still the only way to change frame count.  I'm surprised they
haven't fixed that........

Here's the way to do it, in the form of a function that returns the same number
you asked for on success, or 0 on failure.

def FakeFrames(DesiredCount):
    # Write a short PZ2 file forcing the desired number of
    # frames; load it; delete it.
    BasePathUncut=poser.AppLocation()
    BasePath=BasePathUncut[:(-len('poser.exe'))]
    DirName=os.path.join(BasePath, 'runtime', 'libraries', 'pose', 'fakes')
    try:
        os.mkdir(DirName)
    except:
        pass # ignore 'already exists' error
    PZ2Name=os.path.join(DirName,'ztemp.pz2')
    fpFake=open(PZ2Name,'wt')
    if not fpFake: return 0
    fpFake.write('{nversionnt{ntnumber 4.2nt}nmovieInfont{nt')
    fpFake.write('numFrames %dnt}n}' % DesiredCount)
    fpFake.close()
    try:
        scene.LoadLibraryPose(PZ2Name)
    except:
        return 0
    os.remove(PZ2Name)
    return  DesiredCount

My python page
My ShareCG freebies


markschum posted Mon, 14 September 2009 at 11:45 PM

Thanks very much for that , it will be very useful.
I added some comment lines crediting you for it.