Getting viewport dimension and laying image planes within

23 views
Skip to first unread message

kiteh

unread,
Jan 23, 2020, 8:30:23 PM1/23/20
to Python Programming for Autodesk Maya
I have a number of image planes (created using Free Image Plane), of varying sizes. By varying sizes, I mean to say that the image sources are of different dimensions. (No changes are made towards the scale attributes)

Even so, I am trying to create a script in which it will allows me to rearrange these image planes (spaced out nicely) if I choose a direction (see attached)

Currently, I was able to conjure up a script that allows me to grab all the image planes based on the modelPanels of a specified camera. However I have no clue on how should I query for the width or height of the viewport, or the way of how these varying image plane sizes will fit to one of the 5 directions (top, left, right, bottom, all)

Need some insights on how I should proceed or if this is even doable?

directions.png


Doktor Weeny

unread,
Jan 24, 2020, 3:39:12 PM1/24/20
to Python Programming for Autodesk Maya
I have two snippets that might help :

# First Snippet
import maya.OpenMayaUI as omui
view = omui.M3dView.active3dView()
x = view.portWidth()
y = view.portHeight()

# Second Snippet
import maya.OpenMayaUI as omui
mdag_path = om.MDagPath()
sel = om.MSelectionList()
sel.add(cam)
sel.getDagPath(0, mdag_path)

# Create frustum object with camera.
draw_traversal = omui.MDrawTraversal()
draw_traversal.setFrustum(mdag_path,
cmds.getAttr("defaultResolution.width"),
cmds.getAttr(
"defaultResolution.height")) # Use render's resolution.

Im not sure to understand what you are trying to do. Are you trying to do something like this : https://github.com/imageworks/spReticle

kiteh

unread,
Jan 24, 2020, 5:25:24 PM1/24/20
to Python Programming for Autodesk Maya
Hey Doktor,

I have attached a screenshot about what I am trying to achieve.

For example:
  • I have selected 3 imagePlane nodes as seen in my "front" camera viewport/ modelPanel, assuming the position of three planes are at origin point initially.
  • If I choose the `direction` to be `left` (if I am able to script it), the script will 're-arrange' the selected imagePlanes to the left-hand side of the said viewport and spaced them out evenly.. See attached for the expected result.
  • If I choose `top` as the direction, it will be on the top of the viewport, so on and forth as described in my first post.



screen_left.png

Reply all
Reply to author
Forward
0 new messages