Macro Toggle Visibility: Difference between revisions

From FreeCAD Documentation
mNo edit summary
(replace text corrected to "Piffpoof" thanks)
Line 5: Line 5:
<translate>
<translate>
==Description== <!--T:1-->
==Description== <!--T:1-->
This is a set of three related macros for managing the visibility of objects in the Object Model:
Set of three macro :
# hidden the objects not selected, if not object selected displayed all objects, hidden all objects
# hide all objects except those that are selected;
# displayed all objects
#*if no object are selected then hide all objects;
# hidden all objects
#*if no objects are selected then show all objects
# display all objects

# hide all objects
</translate>
</translate>
<translate>
<translate>

==Uses== <!--T:2-->
==How To Use== <!--T:2-->
Copy the macros and the icons in your folder macros and run
Copy the macros and the icons in your folder macros and run
</translate>
</translate>
Line 18: Line 20:


==Macro SelectVisible== <!--T:3-->
==Macro SelectVisible== <!--T:3-->
This macro hidden all objects not selected if you selected one object hidden the hidden object are displayed and all objects not selected are hidden
This macro hides all objects which are not selected. If an object or objects are selected then all unselected objects are hidden.


<!--T:4-->
<!--T:4-->
If not object selected 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 not selection in Comboview all object are visible
If all objects are hidden and there is no selection in ComboView then all object are made visible


<!--T:13-->
<!--T:13-->
Line 67: Line 69:


==Macro VisibleAlls== <!--T:6-->
==Macro VisibleAlls== <!--T:6-->
This macro show all objects.
This macro makes all objects visible.


<!--T:7-->
<!--T:7-->
Line 92: Line 94:


==Macro HiddenAlls== <!--T:8-->
==Macro HiddenAlls== <!--T:8-->
This macro hidden all objects.
This macro hides all objects.


<!--T:9-->
<!--T:9-->

Revision as of 19:54, 9 January 2016

File:Macro SelectVisible Macro_SelectVisible

Description
Hidden all object not selected.

Author: Mario52
Author
Mario52
Download
None
Links
Macro Version
1.0
Date last modified
None
FreeCAD Version(s)
None
Default shortcut
None
See also
None

Description

This is a set of three related macros for managing the visibility of objects in the Object Model:

  1. hide all objects except those that are selected;
    • if no object are selected then hide all objects;
    • if no objects are selected then show all objects
  2. display all objects
  3. hide all objects

How To Use

Copy the macros and the icons in your folder macros and run

Macro SelectVisible

This macro hides all objects which are not selected. If an object or objects are selected then all unselected objects are hidden.

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 SelectVisible.FCMacro the icon

import FreeCAD
# Macro_SelectVisible
__title__="Macro_SelectVisible"
__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

Macro VisibleAlls

This macro makes all objects visible.

The code Macro VisibleAlls.FCMacro the icon

import FreeCAD
#Macro_VisibleAlls
__title__="Macro_VisibleAlls"
__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

Macro HiddenAlls

This macro hides all objects.

The code Macro HiddenAlls.FCMacro the icon

import FreeCAD
#Macro_HiddenAlls
__title__="Macro_HiddenAlls"
__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

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


Other languages: