Tue, Nov 19, 5:36 AM CST

Renderosity Forums / Poser Python Scripting



Welcome to the Poser Python Scripting Forum

Forum Moderators: Staff

Poser Python Scripting F.A.Q (Last Updated: 2024 Sep 18 2:50 am)

We now have a ProPack Section in the Poser FreeStuff.
Check out the new Poser Python Wish List thread. If you have an idea for a script, jot it down and maybe someone can write it. If you're looking to write a script, check out this thread for useful suggestions.

Also, check out the official Python site for interpreters, sample code, applications, cool links and debuggers. This is THE central site for Python.

You can now attach text files to your posts to pass around scripts. Just attach the script as a txt file like you would a jpg or gif. Since the forum will use a random name for the file in the link, you should give instructions on what the file name should be and where to install it. Its a good idea to usually put that info right in the script file as well.

Checkout the Renderosity MarketPlace - Your source for digital art content!



Subject: Detect if a Poser UI panel is closed, and open it


HartyBart ( ) posted Mon, 07 November 2022 at 1:28 PM · edited Sat, 16 November 2024 at 11:37 PM

I am trying to have a script open the Animation Controls panel in Poser, if the user does not already have it open.

All I have to do this is...

poser.ProcessCommand(1459)

... which partly works, but this particular command will also close the panel (if the user already has it open).

Is there a way for a PoserPython script to detect if a particular Poser UI panel is closed, and open it?



Learn the Secrets of Poser 11 and Line-art Filters.


Dizzi ( ) posted Mon, 07 November 2022 at 2:06 PM
HartyBart ( ) posted Mon, 07 November 2022 at 2:21 PM

Wonderful, thanks Dizzi. This is tested and working in Poser 11 and 12 on Windows....

# Detect and show Poser palette panel, if not otherwise available as an official PaletteById code.
#
import poser
import wx
import wx.aui
bIsShown=False
for x in poser.WxAuiManager().GetManagedWindow().Children:
    try:
        if x.GetName()=='AnimationControls':
            bIsShown=x.IsShown()
        for y in x.Children:
            if y.GetName()=='AnimationControls':
                bIsShown=x.IsShown()
    exceptpass
if not bIsShown:
    poser.ProcessCommand(1459)




Learn the Secrets of Poser 11 and Line-art Filters.


adp001 ( ) posted Mon, 07 November 2022 at 3:05 PM

You can find any Poser window easy with this command:

root = poser.WxAuiManager().GetManagedWindow()
ui_window=root.FindWindowByName("PythonPalette")




HartyBart ( ) posted Mon, 07 November 2022 at 3:30 PM · edited Mon, 07 November 2022 at 3:31 PM

Thanks, both. Further tests show a problem. Works 'as described' for PythonPalette, for which it was originally intended. Also for AnimationPalette.

But does not work with the AnimationControls panel. I suspect that what fooled me into thinking it did, for a moment, was that the script defaults to the poser.ProcessCommand - and that does work. But only by toggling Animation Controls panel on/off un-intelligently. Which was my opening problem in this thread.

I suspect the script cannot find AnimationControls because there is no such panel label. It must be one of the panels without a given PaletteById 'Palette Code', which appears to be required. The available Palette Codes are listed in the Poser manual, and there are only a few.

This missing panel label (if there is one) is not an undocumented variant either, as I tried various:

AnimationControls

AnimationControl

Animation Control

Animation_Controls

AnimationControlsPalette

etc



Learn the Secrets of Poser 11 and Line-art Filters.


adp001 ( ) posted Mon, 07 November 2022 at 4:17 PM

The correct way would not be to address the window itself, but rather the AuiManager, which is responsible for the layout.

Each regular window is provided with a wrapper (wx.AuiPaneInfo) that contains everything needed to manage this window in the overall structure. The AuiManager knows all these structures and a Python script can use them.

All Poser windows can be listed this way:

auimgr = poser.WxAuiManager()
poser_windownames = [pane.name for pane in mgr.AllPanes]

If you only need a specific window whose name you know, you can get the AuiPaneInfo structure like this (without error detection):

known_name = "AnimationPalette"
pane_info = [pane for pane in auimgr.AllPanes if pane.name==known_name]

pane_info[0] is now of type wx.AuiPaneInfo()
On the wxPython website you can read what you can do with this structure now: https://docs.wxpython.org/wx.aui.AuiPaneInfo.html

Using the AuiPaneInfo() structure, your own script is able to do everything with the window that Poser can do with it. "ProcessCommand" is no longer needed to show or hide a window.


By the way, the animation part consists of two independent windows ("Panes"): SmallAnim and AnimationPalette





HartyBart ( ) posted Mon, 07 November 2022 at 4:22 PM

Hah, I got it! Success. I was correct, the above failing script was not detecting the panel as being named AnimationControls. The real Animation Controls label is undocumented, but is actually 'SmallAnim'.

First I used this old mini script...

import poser
import wx
import wx.aui

man = poser.WxAuiManager()
root = man.GetManagedWindow()

for pane in man.AllPanes:
    w = pane.window
    print("Window Name:",w.Name)


...to get a list of available panel names in the Poser UI, and I noted there a 'SmallAnim'. Could that be it? Yes, on testing it, that's what its correct label is. This works as I require...

# Detect and show the Poser panel/window for the Animation Controls,
# if not already open. If this panel is already open, do nothing.
import poser
import wx
import wx.aui

bIsShown=False
for x in poser.WxAuiManager().GetManagedWindow().Children:
    try:
        if x.GetName()=="SmallAnim":
            bIsShown=x.IsShown()
        for y in x.Children:
            if y.GetName()=="SmallAnim":
                bIsShown=x.IsShown()
    exceptpass
if not bIsShown:
    poser.ProcessCommand(1459)



Learn the Secrets of Poser 11 and Line-art Filters.


HartyBart ( ) posted Mon, 07 November 2022 at 4:32 PM

Thanks adp, I found the answer before I saw your feedback.

I should add also, tested and working in Poser 12.



Learn the Secrets of Poser 11 and Line-art Filters.


adp001 ( ) posted Mon, 07 November 2022 at 4:36 PM

You have to keep the actual wxWindows and the AUI structures apart. A wx.Window() can have a specific name (used with "GetWindowByName()"), but in the AUI Manager the pane structure can have a different name (listed via AuiManager.AllPanes). It's up to the programmer...




Privacy Notice

This site uses cookies to deliver the best experience. Our own cookies make user accounts and other features possible. Third-party cookies are used to display relevant ads and to analyze how Renderosity is used. By using our site, you acknowledge that you have read and understood our Terms of Service, including our Cookie Policy and our Privacy Policy.