Macro Toggle Visibility

From FreeCAD Documentation
Revision as of 19:30, 11 November 2015 by Mario52 (talk | contribs) (Marked this version for translation)

File:Macro SelectVisible Macro_SelectVisible

Description
Hidden alls 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

Set of three macro :

  1. hidden the objects not selected
  2. displayed alls objects
  3. hidden alls objects

Uses

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

Macro SelectVisible

This macro hidden alls objects not selected if you selected one object hidden the hidden object are displayed and alls objects not selected are hidden

If not object selected alls objects are hidden

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.00"
__date__    = "11/11/2015"

try:
    for ShapeNameObj in FreeCAD.ActiveDocument.Objects:                               # hide 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)
            Gui.Selection.removeSelection(ShapeNameObj)
            #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 show all objects.

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 hidden 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.

Other languages: