I'm typing this off the top of my head while watching the basketball game,
but I think there are a couple options...

1. Pretty sure the getPanel command has a "type" flag where you can give it
the name of the panel you got back from the "active" call.  That should
return something like "modelPanel" if it is a viewport.
2. The M3dView class has an active3dView static function that I'm pretty
sure returns the last active viewport if the current active panel is some
other type.  If that's the case then this is the one you want.


On Wed, Jun 5, 2019 at 8:18 PM kiteh <kiteh.0...@gmail.com> wrote:

> Hey Tomas, thanks for getting back.
>
> I actually managed to get it working by using the following (too much?):
>
>     model_panels = []
>     focus_panel = cmds.getPanel(withFocus=True)
>     # Check if current panel is a modelPanel
>     if cmds.objectTypeUI(focus_panel) == "modelEditor":
>         cmds.modelEditor(focus_panel, edit=True, imagePlane=True)
>     else:
>         for panel in cmds.lsUI(editors=True):
>             if "modelPanel" in panel:
>                 model_panels.append(panel)
>
>         for model_panel in model_panels:
>             if cmds.modelEditor(model_panel, query=True, activeView=True):
>                 try:
>                     cmds.modelEditor(model_panel, edit=True,
> imagePlane=True)
>                 except Exception as e:
>                     pass
>
> Basically it checks if the current focus panel is of modelPanel. If it is
> not, it will query all modelPanels and sets the main viewport (not the tear
> off etc)
>
> If anyone has a better approach to this, do feel free to chip in :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/365fea6f-4a0a-4ad8-831b-dd80bb545243%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/365fea6f-4a0a-4ad8-831b-dd80bb545243%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CALKD2WokHE%3DQZDY_68Bi1peqmdEK%2BaT0UG8HovS2WnuXJpRZ%2Bw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to