Wishlist Item: "DeSelNonVisible"

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

1 Like

Hello - this might help for now-

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.

-Pascal

1 Like

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 )
1 Like

I might have worded my question badly. I am only looking to Deselect all objects outside the active view, including 3D views ideally.

(Not so worried about layers necessarily)

Thanks for this solution. This worked well in 2D views but not so much with 3D (parallel projection) views

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.

-Pascal