Skip to content

Instantly share code, notes, and snippets.

@cfobel
Created July 20, 2017 14:01
Show Gist options
  • Select an option

  • Save cfobel/a74526d1762a22094e01cb18945103a2 to your computer and use it in GitHub Desktop.

Select an option

Save cfobel/a74526d1762a22094e01cb18945103a2 to your computer and use it in GitHub Desktop.

Revisions

  1. cfobel created this gist Jul 20, 2017.
    11 changes: 11 additions & 0 deletions isolate_selected_objects.FCMacro
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    # Isolate selected item(s):
    # - Save list of selected items
    # - Save list of visible items
    # - Hide non-selected items that are currently visible
    import FreeCAD

    selected_objects = set(object_i.Label for object_i in Gui.Selection.getSelection())
    objects_by_label = {object_i.Label: object_i for object_i in Gui.ActiveDocument.Document.Objects if object_i.ViewObject.Visibility}
    [setattr(object_i.ViewObject, 'Visibility', False) for label_i, object_i in objects_by_label.iteritems()]
    [setattr(object_i.ViewObject, 'Visibility', True) for object_i in Gui.ActiveDocument.Document.Objects if object_i.Label in selected_objects]
    FreeCAD._isolated__objects_to_restore = objects_by_label
    10 changes: 10 additions & 0 deletions isolote_restore_objects.FCMacro
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    # Restore original visibility of each item.
    # Isolate selected item(s):
    # - Save list of selected items
    # - Save list of visible items
    # - Hide non-selected items that are currently visible
    import FreeCAD

    objects_by_label = FreeCAD._isolated__objects_to_restore
    [setattr(object_i.ViewObject, 'Visibility', True) for object_i in Gui.ActiveDocument.Document.Objects if object_i.Label in objects_by_label]
    [setattr(object_i.ViewObject, 'Visibility', False) for object_i in Gui.ActiveDocument.Document.Objects if object_i.Label not in objects_by_label]
    9 changes: 9 additions & 0 deletions show_all_parts.FCMacro
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,9 @@
    # Hide:
    # - All sketches
    # - All objects that end with `- Draft`
    #
    # Show:
    # - All objects that end with `- Part`
    objects_by_label = {object_i.Label: object_i for object_i in Gui.ActiveDocument.Document.Objects}
    [setattr(object_i.ViewObject, 'Visibility', True) for label_i, object_i in objects_by_label.iteritems() if label_i.endswith('- Part')]
    [setattr(object_i.ViewObject, 'Visibility', False) for label_i, object_i in objects_by_label.iteritems() if (label_i.endswith('- Draft') or 'sketch' in object_i.TypeId.lower())]