' https://developer.rhino3d.com/api/rhinoscript/layer_state_methods/layer_state_methods.htm Option Explicit 'Call IsolateHiddenObjects() Sub IsolateHiddenObjects() ' turn off refresh 'Call Rhino.EnableRedraw(False) ' enable LayerTools Dim objPlugIn On Error Resume Next Set objPlugIn = Rhino.GetPluginObject("Rhino Bonus Tools") If Err Then MsgBox Err.Description Exit Sub End If ' save current layer state Call objPlugIn.SaveLayerState("temp") ' turn all layers on Dim strLayer Dim arrLayers: arrLayers = Rhino.LayerNames If IsArray(arrLayers) Then For Each strLayer In arrLayers If Rhino.LayerVisible(strLayer) = False Then Rhino.LayerVisible strLayer, True End If Next End If ' check for hidden Dim aHid : aHid = Rhino.HiddenObjects If Not IsArray(aHid) Then Rhino.Print "There are no hidden objects in this file." Rhino.EnableRedraw(True) Exit Sub End If ' prepare for dialog display Dim sHid, n Dim aLayers() n = 0 For Each sHid In aHid ReDim Preserve aLayers(n) aLayers(n) = Rhino.ObjectLayer(sHid) n = n + 1 Next Dim aCull: aCull = Rhino.CullDuplicateStrings(aLayers) n = 0 Dim sLayer For Each slayer In aCull: ReDim Preserve aStates(n) aStates(n) = False n = n + 1 Next ' display checklist Dim ShowLayers : Showlayers = Rhino.CheckListBox(aCull, aStates, "Select layers to show objects", "Layers with hidden objects") If Not IsArray(ShowLayers) Then Exit Sub Dim Id For n = 0 To UBound(aCull) If ShowLayers(n) = True Then For Each ID In Rhino.ObjectsByLayer(aCull(n)) Rhino.ShowObject(Id) Next End If Next ' display results Call Rhino.SelectObjects(aHid) Dim hObjects : hObjects = rhino.UnselectedObjects Call rhino.HideObjects(hObjects) Call rhino.UnselectObjects(aHid) ' turn refresh back on 'Call rhino.EnableRedraw(True) ' restore or not? Dim question : question = Rhino.MessageBox("Restore previous state?", 1) If (question = 1) Then ' restore to pre command Call rhino.HideObjects(aHid) Call objPlugIn.RestoreLayerState("temp", 2) Call rhino.ShowObjects(hObjects) Call objPlugIn.DeleteLayerState("temp") Exit Sub End If Call objPlugIn.DeleteLayerState("temp") End Sub