View Full Version : list objects in viewport

10 October 2010, 03:45 AM
is it possible to list objects in viewport through a camera with MEL?


Robert Bateman
10 October 2010, 05:07 PM
Whilst not an answer to your actual question, you can do this trivially in the API via these two lines:

M3dView view = M3dView::active3dView();
MGlobal::selectFromScreen( 0, 0, view.portWidth(), view.portHeight(), MGlobal::kReplaceList );

Not much help to you though (unless some kind forum user re-writes it in python for you....)

10 October 2010, 08:56 PM
which would look something like this (Rob's C++ code converted into python):

import maya.OpenMaya as om
import maya.OpenMayaUI as omUI
view = omUI.M3dView.active3dView()
om.MGlobal.selectFromScreen( 0, 0, view.portWidth(), view.portHeight(), om.MGlobal.kReplaceList)
actually very similar for something this simple. you could call this from MEL using the python command if necessary.

10 October 2010, 09:57 PM
Thanks guys! just what i needed, I am a python man anyway.

Where is the best place to get info on the API moduls for python? like the one's you listed?

Would be a great help for future reference.

Thanks Guys!

10 October 2010, 09:05 AM
well all the API documentation is in Maya's help:

Maya > Help (F1) > Developer Resources > API Guide


Maya > Help (F1) > Technical Documentation > API Reference

for the classes. Maya also ships with a load of python scripted plugins for working example code which you can find here:

C:\Program Files\Autodesk\Maya20XX\devkit\plug-ins\scripted\

(or wherever equivalent path you installed Maya to on your OS)

CGTalk Moderation
10 October 2010, 09:05 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.