Who among us has not gone through the following workflow?
When you want to select several objects from a common layer from a tangle of other things
Right click the target object’s layer to “Select Objects” and then zoom out and manually deselect all the non-desired objects from that layer.
Instead I’d love to have a command that I can make a shortcut to immediately deselect all selected objects outside of the active viewport. Essentially this command would be the (double) inverse of SelVisible.
If things like SelBrush exist (which I use and love by the way), then we really should add DeSelNonVisible to our arsenal
import scriptcontext as sc
import rhinoscriptsyntax as rs
def deSel_OutOfView():
ids = rs.SelectedObjects()
if not ids: return
vp = sc.doc.Views.ActiveView.ActiveViewport
rs.EnableRedraw(False)
for id in ids:
geo = rs.coercegeometry(id)
bb = geo.GetBoundingBox(False)
pts = bb.GetCorners()
v = False
for pt in pts:
if vp.IsVisible(pt):
v=True
continue
if not v: rs.UnselectObject(id)
rs.EnableRedraw(True)
deSel_OutOfView()
It will deselect if none of the objects’ bounding box corners are visible in the current viewport.
I’ not sure at all of what this theme is about but this is working:
import rhinoscriptsyntax as rs
SelectedObjts=rs.SelectedObjects()
visibleObjs= rs.VisibleObjects()
for obj in SelectedObjts:
if not obj in visibleObjs:
rs.UnselectObject(obj )
Presumably you mean that some objects that are not visible are not deselected, correct? I’d guess that would be the most common error, using the functions that I did.