Dashboard_avatar
Jul 20, 2010
Post id: 304532 Report Item

hello guys!
is there any python command in maya which selects objects according to the camera view?

thanks a lot!

Dashboard_avatar
Jul 20, 2010
Post id: 304533 Report Item

dpends what your definition of camera view is. Is its just furstrum chekking or is it component selection etc.. Both are possible but the other is quite much work tough.

but in practical consideration no theres no one command you call.

Dashboard_avatar
Jul 29, 2010
Post id: 304662 Report Item

import maya.OpenMaya as om
import maya.OpenMayaUI as omu

view = omu.M3dView.active3dView()
om.MGlobal.selectFromScreen(0, 0, view.portWidth(), view.portHeight(), om.MGlobal.kReplaceList)


---  This code ll select all objects seen in the current camera view.
I 'm not sure this is the code you intended.

Avatar
Feb 01, 2012
Post id: 309558 Report Item

Cool!! Neat little code. i'll keep this snippet. Thanks

Avatar
Feb 07, 2012
Post id: 309598 Report Item

But, what if I just want to list the objects that the camera sees? instead of selecting them. Besides I think that the above code doesn't take into account the camera gates, just the viewport area? am I right? is it possible to take this into account? Thanks in advance.

Dashboard_avatar
Feb 07, 2012
Post id: 309600 Report Item

Well you can compute the gate size and use less than 0 to max size in each direction. and feed the numbers, assuming the gate fits  the view that is (and it dont get too small)

>> what if I just want to list the objects that the camera sees?

Select save selection reset back to what you had before. The api call is just doing the same thing as drawing a marque box in the screen. If you dont want to rasterize yourself then that's what you get the same raw function.

But obviously if time is no issue you can use a software render to sort this out (i used to do this back in the day when maya couldn't cull visibility properly*, the cool thing about thsi is that it can be affected by transparency factors in way that opengl  can not such as only select objects that are behind a second object. Plus its easy to say its the actual resolution of what the render is, a but slow tough.)

*and still for some ambient occlusion testing based selection, joint tweaking etc

Avatar
Feb 17, 2012
Post id: 309649 Report Item

Thanks for the reply Joojaa. About the thing of just listing instead of selecting, the fact is I don't mind losing my current selection as I can save it before and revert back at the end as you said. The issue is that I want to use this code to hide objects outside the view during a camera move, and reselect every visible object every frame is a bit slow. I toss the visible objects to a set every frame and hide the other geometries at the end. I wondered that maybe if I can get just the object names (with other code) to add them to my visible objects set it could run faster. Maybe I can hide the selection highlighting to avoid the drawing of the wireframe. I'll give it a try. And that's it. Thanks.

Avatar
Feb 17, 2012
Post id: 309650 Report Item

The selection highlighting thing didn't work.