Macro If Selected Stay If Not Then Delete

From FreeCAD Documentation
Revision as of 18:32, 8 June 2019 by Mario52 (talk | contribs)
Other languages:

Macro If Selected Stay If Not Then Delete

Description
This macro delete all objects not selected.

Macro version: 00.01
Last modified: 2015-11-12
FreeCAD version: All
Download: ToolBar Icon
Author: Mario52
Author
Mario52
Download
ToolBar Icon
Links
Macro Version
00.01
Date last modified
2015-11-12
FreeCAD Version(s)
All
Default shortcut
None
See also
Macro_Toggle_Visibility2
Macro_Toggle_Visibility
Macro HiddenAlls
Macro_VisibleAlls

Description

This macro delete all objects not selected !!.

Script

Macro_If_Selected_Stay_If_Not_Then_Delete.FCMacro

import FreeCAD
# Macro_If_Selected_Stay_If_Not_Then_Delete
__title__="Macro_If_Selected_Stay_If_Not_Then_Delete"
__author__ = "Mario52"
__url__     = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.00"
__date__    = "16/06/2016"

App = FreeCAD
try:
    for ShapeNameObj in FreeCAD.ActiveDocument.Objects:
        if Gui.Selection.isSelected(ShapeNameObj) == True:
            None
        else:
            App.ActiveDocument.removeObject(ShapeNameObj.Name)        # remove objects not selecteds
except Exception:
    None