Macro Toggle Visibility: Difference between revisions
m (date) |
m (DATE ISO 8601 YYYY-MM-DD) |
||
Line 1: | Line 1: | ||
<translate> |
<translate> |
||
<!--T:11--> |
<!--T:11--> |
||
{{Macro|Icon=Macro SelectVisible|Name=Toggle Visibility|Description=Hidden all objects not selected.|Author=Mario52|Version=00.02|Date= |
{{Macro|Icon=Macro SelectVisible|Name=Toggle Visibility|Description=Hidden all objects not selected.|Author=Mario52|Version=00.02|Date=2015-11-12}} |
||
</translate> |
</translate> |
||
Revision as of 17:04, 29 September 2017
File:Macro SelectVisible Toggle Visibility |
Description |
---|
Hidden all objects not selected. Macro version: 00.02 Last modified: 2015-11-12 Author: Mario52 |
Author |
Mario52 |
Download |
None |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
00.02 |
Date last modified |
2015-11-12 |
FreeCAD Version(s) |
None |
Default shortcut |
None |
See also |
None |
Description
This is a set of four related macros for managing the visibility of objects in the Object Model:
- objects that are selected in a document are made visible while objects that are not selected are made invisible
- if no objects are selected then all objects are hidden;
- if all objects are selected then all objects are made visible
- make all objects visible
- make all objects invisible
- the object(s) selected then stay , all objects not selected are deleted
How To Use
Copy the macros and the icons in your folder macros and run (see How to install macros)
ToggleVisibility
Using the selection of objects in the one of the FreeCAD views, this macro makes all selected objects visible and hides all objects which are not selected.
If no object(s) are selected then all objects are hidden
If all objects are hidden and there is no selection in ComboView then all object are made visible
This version new version (00.02) include the tree macro in one
The code Macro_ToggleSelectedObjectVisibility.FCMacro the icon
import FreeCAD
# Macro_ToggleSelectedObjectVisibility
__title__="Macro_ToggleSelectedObjectVisibility"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.02"
__date__ = "12/11/2015"
try:
compt = 0
for ShapeNameObj in FreeCAD.ActiveDocument.Objects: # list alls objet for test if alls hidden
if (FreeCADGui.ActiveDocument.getObject(ShapeNameObj.Name).Visibility == False) and (Gui.Selection.isSelected(ShapeNameObj) == False):
compt += 1 # if hidden : compt += 1
#print "False : ",ShapeNameObj.Name
if compt == len(FreeCAD.ActiveDocument.Objects): # if (compt = Alls objects hidden) then Visibility = True
for ShapeNameObj in FreeCAD.ActiveDocument.Objects:
FreeCADGui.ActiveDocument.getObject(ShapeNameObj.Name).Visibility = True # Visibility = True
#print "True : ",ShapeNameObj.Name
compt = 0
else :
for ShapeNameObj in FreeCAD.ActiveDocument.Objects: # hidde objects not selecteds
if Gui.Selection.isSelected(ShapeNameObj) == False:
FreeCADGui.ActiveDocument.getObject(ShapeNameObj.Name).Visibility = False # if objects is not selected then Visibility = False (Hidden)
#print "False : ",ShapeNameObj.Name
else:
FreeCADGui.ActiveDocument.getObject(ShapeNameObj.Name).Visibility = True # if objects are hidden and selected then Visibility = True and hidden alls objects visibles
#print "True : ",ShapeNameObj.Name
except Exception:
None
DisplayAll
This macro makes all objects visible.
The code Macro_DisplayAllObjects the icon
import FreeCAD
#Macro_VisibleAlls
__title__="Macro_DisplayAllObjects"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.00"
__date__ = "11/11/2015"
try:
for ShapeNameObj in FreeCAD.ActiveDocument.Objects: # displyed alls objects
#print ShapeNameObj.Name
FreeCADGui.ActiveDocument.getObject(ShapeNameObj.Name).Visibility = True
except Exception:
None
HideAll
This macro hides all objects.
The code Macro_HideAllObjects the icon
import FreeCAD
#Macro_HideAllObjects
__title__="Macro_HideAllObjects"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.00"
__date__ = "11/11/2015"
try:
for ShapeNameObj in FreeCAD.ActiveDocument.Objects: # hidden alls objects
#print ShapeNameObj.Name
FreeCADGui.ActiveDocument.getObject(ShapeNameObj.Name).Visibility = False
except Exception:
None
SelectedStay
This macro delete alls object not selected
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
Link
The discussion on the forum Proposal: select one or more pieces, hide the others.
Version
ver 00.02 12/11/2015 macro Macro_SelectVisible : hidden the objects not selected, if not object selected displayed all objects, hidden all objects. This version include the tree macro in one