Hello, mario52!
I have tried this macros and it works. But... when I call it to make all object visible, it makes visible all prevously hidden parent objects, sketches, etc. It is not convenient .
How can we upgrade this macro to make visible only objects that already were visible before hiding?
I assume there should be some list of "actual" objects. Should it be some variable inside macro or some mark in object properties?
This function is invaluable when one preparing complex dense metal assemblies for lasercut and need to do some laser-friendly post-procesing (fillets, dogbones, etc) after finishing rough design.
I have fixed it in this way. You can add similar change to original macro code (may be with more reasonable and safe variable names) if you find it useful:
But I leave some objects unhidden, of course, to modify them. And there is no need to make this selected objects visible again:
Code: Select all
import FreeCAD
# Macro_ToggleSelectedObjectVisibility
__title__="Macro_ToggleSelectedObjectVisibility"
__author__ = "Mario52"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.02"
__date__ = "12/11/2015"
FreeCAD.actual=[]
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
elif Gui.Selection.isSelected(ShapeNameObj) == False:
FreeCAD.actual.append(ShapeNameObj.Name)
#print "Actual : ",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
Code: Select all
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.actual: # displyed alls objects
#print ShapeNameObj
FreeCADGui.ActiveDocument.getObject(ShapeNameObj).Visibility = True
except Exception:
None