Hi!
If I understand your question correctly, you need a list of all dag objects that have both LOD Visibility and Visibility turned on and have no parents with either turned off. You could list them as follows:
import maya.cmds as mc
#getting visible List
vis = mc.ls(v= True, dag= True, tr = True, l= True)
#creating list to store truly visible objects
renderableList = []
#going through visible list
for vo in vis:
check = 1
#splitting the long name into each object
objects = vo.split("|")
objects.pop(0)
storedString = None
for o in objects:
#reformatting path to avoid problems with identical names
o = "|" + o
if storedString == None:
storedString = o
else:
o = storedString + o
storedString = o
#checking if each object in path has both LOD Visibility and Visibility turned on
v = mc.getAttr("{0}.visibility".format(o))
lv = mc.getAttr("{0}.lodVisibility".format(o))
#excluding objects that don't have both attributes set to True
if v == False or lv == False:
check = 0
break
#adding objects that are truly visible to list
if check == 1:
renderableList.append(vo)
print(renderableList)
Now, this script still isn't perfect, since it doesn't account for other ways to turn off an objects visibility. For example using a Layer with visibility turned off.
Another way to approach it could be to use the python API to select everything in view.
This script creates a new camera with the widest angle of view possible, sets it as the camera in the active view, then selects everything it sees. rotates the camera, selects again, rotates again, and so on:
import maya.OpenMaya as om
import maya.OpenMayaUI as omu
import maya.cmds as mc
initSel = mc.ls(sl = True)
cam = mc.camera(hfv = 160, vfv = 160, ar = 1)
mE = mc.getPanel(type = 'modelPanel')
for e in mE:
av = mc.modelEditor(e,q= True, av = True)
if av == True:
currentCam = mc.modelEditor(e,q= True, cam = True)
mc.modelEditor(e,e = True, cam = cam[0])
break
values = [90,180,-90,0]
channels =["rx","ry"]
renderableList = []
for c in channels:
for v in values:
mc.setAttr("{0}.{1}".format(cam[0], c), v)
view = omu.M3dView.active3dView()
om.MGlobal.selectFromScreen(0, 0, view.portWidth(), view.portHeight(), om.MGlobal.kReplaceList)
sel = mc.ls(sl= True)
renderableList = renderableList + sel
mc.select(initSel, r = True)
mc.delete(cam[0])
mc.modelEditor(e, e=True, cam = currentCam)
renderableList = list(set(renderableList))
print(renderableList)
Now this is quite hacky, since it needs to create a new cam and delete it after it is finished. Also it works using selection, which isn't optimal...
I have the feeling that there is a more elegant way to do this, but I couldn't find it...
Anyways, these two scripts should do what you want for now, maybe someone will post a more elegant way to do it.^^
I hope it helps!