Macro Toggle Visibility: Difference between revisions
(|SeeAlso=Macro_Toggle_Visibility2) |
No edit summary |
||
(13 intermediate revisions by 4 users not shown) | |||
Line 5: | Line 5: | ||
|Name=Toggle Visibility |
|Name=Toggle Visibility |
||
|Icon=Macro SelectVisible.png |
|Icon=Macro SelectVisible.png |
||
|Description=Toggling Hidden/Display all objects not selected.<br />objects that are selected in a document are made visible while objects that are not selected are made invisible.<br />if no objects are selected then all objects are hidden.<br />if all objects are selected then all objects are made visible. |
|||
|Description=Hidden all objects not selected. |
|||
|Author=Mario52 |
|Author=Mario52 |
||
|Version=00.02 |
|Version=00.02 |
||
|Date=2015-11-12 |
|Date=2015-11-12 |
||
|FCVersion=All |
|||
|SeeAlso=[[Macro_Toggle_Visibility2|Macro_Toggle_Visibility2]] |
|||
|Download=[https://www.freecadweb.org/wiki/images/4/42/Macro_SelectVisible.png ToolBar Icon] |
|||
|SeeAlso=[[Macro_Toggle_Visibility2_1-2|Macro Toggle Visibility2 1-2]]<br>[[Macro_Toggle_Visibility2_2-2|Macro Toggle Visibility2 2-2]]<br>[[Macro_VisibleAlls|Macro VisibleAlls]]<br>[[Macro_HiddenAlls|Macro HiddenAlls]]<br>[[Macro_If_Selected_Stay_If_Not_Then_Delete|Macro If Selected Stay If Not Then Delete]] |
|||
}} |
}} |
||
==Description== <!--T:1--> |
==Description== <!--T:1--> |
||
This is a set of four related macros for managing the visibility of objects in the Object Model: |
|||
<!--T:20--> |
|||
# objects that are selected in a document are made visible while objects that are not selected are made invisible |
|||
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 invisible |
|||
# the object(s) selected then stay , all objects not selected are deleted |
|||
==How To Use== <!--T:2--> |
==How To Use== <!--T:2--> |
||
Copy the macros and the icons in your folder macros and run (see [[How to install macros|How to install macros]]) |
|||
<!--T:21--> |
|||
Copy the macro and the icon in your folder macros and run (see [[How_to_install_macros|How to install macros]]) |
|||
==Toggle Visibility== <!--T:3--> |
|||
<!--T:22--> |
|||
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. |
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. |
||
<!--T:4--> |
<!--T:4--> |
||
If no object(s) are selected then all objects are hidden |
If no object(s) are selected then all objects are hidden. |
||
<!--T:12--> |
<!--T:12--> |
||
If all objects are hidden and there is no selection in ComboView then all object are made visible |
If all objects are hidden and there is no selection in ComboView then all object are made visible. |
||
<!--T:13--> |
<!--T:13--> |
||
This version new version (00.02) include the tree macro in one |
This version new version (00.02) include the tree macro in one. |
||
==Script== <!--T:18--> |
|||
<!--T:19--> |
|||
The macro icon [[File:Macro SelectVisible.png|48px]] |
|||
<!--T:5--> |
|||
The code '''Macro_ToggleSelectedObjectVisibility.FCMacro''' the icon [[File:Macro SelectVisible.png|48px]] |
|||
</translate> |
</translate> |
||
'''Macro_ToggleSelectedObjectVisibility.FCMacro''' |
|||
{{ |
{{MacroCode|code= |
||
import FreeCAD |
import FreeCAD |
||
Line 74: | Line 82: | ||
<translate> |
<translate> |
||
== |
==Link== <!--T:10--> |
||
This macro makes all objects visible. |
|||
<!--T: |
<!--T:23--> |
||
The discussion on the forum [http://forum.freecadweb.org/viewtopic.php?f=8&t=13152 Proposal: select one or more pieces, hide the others.] |
|||
The code '''Macro_DisplayAllObjects''' the icon [[File:Macro VisibleAlls.png|48px]] |
|||
</translate> |
|||
==Version== <!--T:14--> |
|||
{{Code|code= |
|||
<!--T:24--> |
|||
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 |
|||
}} |
|||
<translate> |
|||
==HideAll== <!--T:8--> |
|||
This macro hides all objects. |
|||
<!--T:9--> |
|||
The code '''Macro_HideAllObjects''' the icon [[File:Macro HiddenAlls.png|48px]] |
|||
</translate> |
|||
{{Code|code= |
|||
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 |
|||
}} |
|||
<translate> |
|||
==SelectedStay== <!--T:15--> |
|||
<!--T:16--> |
|||
This macro delete alls object not selected |
|||
<!--T:17--> |
|||
The icon for the tool bar [[File:Macro_If_Selected_Stay_If_Not_Then_Delete.png|48px]] |
|||
</translate> |
|||
{{Code|code= |
|||
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 |
|||
}} |
|||
<translate> |
|||
==Link== <!--T:10--> |
|||
The discussion on the forum [http://forum.freecadweb.org/viewtopic.php?f=8&t=13152 Proposal: select one or more pieces, hide the others.] |
|||
</translate> |
|||
<translate> |
|||
==Version== <!--T:14--> |
|||
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 |
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 |
||
</translate> |
</translate> |
Latest revision as of 19:57, 15 November 2021
Description |
---|
Toggling Hidden/Display all objects not selected. 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. Macro version: 00.02 Last modified: 2015-11-12 FreeCAD version: All Download: ToolBar Icon Author: Mario52 |
Author |
Mario52 |
Download |
ToolBar Icon |
Links |
Macros recipes How to install macros How to customize toolbars |
Macro Version |
00.02 |
Date last modified |
2015-11-12 |
FreeCAD Version(s) |
All |
Default shortcut |
None |
See also |
Macro Toggle Visibility2 1-2 Macro Toggle Visibility2 2-2 Macro VisibleAlls Macro HiddenAlls Macro If Selected Stay If Not Then Delete |
Description
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
How To Use
Copy the macro and the icon in your folder macros and run (see How to install macros)
Toggle Visibility
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.
Script
Macro_ToggleSelectedObjectVisibility.FCMacro
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
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