Created
July 20, 2017 14:01
-
-
Save cfobel/a74526d1762a22094e01cb18945103a2 to your computer and use it in GitHub Desktop.
FreeCAD macros for showing all parts (not sketches or drafts); isolating view of selected objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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())] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment