Macro Toggle Visibility2 1-2: Difference between revisions

From FreeCAD Documentation
m (__author__ = "openfablab")
(Use {{MacroCode}})
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
<languages/>
<translate>
<translate>
<!--T:11-->
<!--T:11-->
{{Macro
{{Macro|Icon=Macro SelectVisible2|Name=Toggle Visibility|Description=Hidden all objects not selected.|Author=openfablab|Version=00.02b (27/07/2017)}}
|Name=Macro Toggle Visibility2 1-2
</translate>
|Icon=Macro SelectVisible2.png
|Description={{ColoredParagraph|DarkRed|Yellow|This macro must be used with '''Macro Toggle Visibility2 2-2'''}}<br/>This is a set of four related macros for managing the visibility of objects in the Object Model (return on original visibility):<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<br/># make all objects visible
|Author=openfablab
|Version=00.02b
|Date=2017-07-27
|FCVersion=All
|Download=[https://www.freecadweb.org/wiki/images/d/d7/Macro_SelectVisible2.png ToolBar Icon]
|SeeAlso=[[Macro_Toggle_Visibility2_2-2|Macro Toggle Visibility2 2-2]]<br/>[[Macro_Toggle_Visibility|Macro_Toggle_Visibility]]
}}


<translate>
==Description== <!--T:1-->
==Description== <!--T:1-->
{{ColoredText|This macro work with [[Macro_Toggle_Visibility2_2-2|Macro Toggle Visibility2 2-2]]}}

<!--T:14-->
This is a set of four related macros for managing the visibility of objects in the Object Model:
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
# objects that are selected in a document are made visible while objects that are not selected are made invisible
Line 11: Line 23:
#*if all objects are selected then all objects are made visible
#*if all objects are selected then all objects are made visible
# make all objects visible
# make all objects visible
</translate>
<translate>


==How To Use== <!--T:2-->
==How To Use== <!--T:2-->
Line 26: Line 36:
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:5-->
==Script 1== <!--T:15-->

The code '''Macro_ToggleSelectedObjectVisibility2.FCMacro''' the icon [[File:Macro SelectVisible2.png|48px]]
</translate>
</translate>
ToolBar Icon [[File:Macro_SelectVisible2.png|64px]]


'''Macro_Toggle_Visibility2_1-2.FCMacro'''
{{Code|code=

{{MacroCode|code=


import FreeCAD
import FreeCAD
# "Macro_Toggle_Visibility2_1-2" associate with "Macro_Toggle_Visibility2_2-2"
# Macro_ToggleSelectedObjectVisibility2
__title__="Macro_ToggleSelectedObjectVisibility2"
__title__="Macro_Toggle_Visibility2_1-2"
__author__ = "openfablab"
__author__ = "openfablab"
__url__ = "http://www.freecadweb.org/index-fr.html"
__url__ = "http://www.freecadweb.org/index-fr.html"
Line 66: Line 79:
<translate>
<translate>


==DisplayAll== <!--T:6-->
==Script 2== <!--T:6-->
This macro makes all objects visible respecting the original visible and hidden objects after use the Macro_ToggleSelectedObjectVisibility macro.


<!--T:7-->
The code '''Macro_DisplayAllObjects2''' the icon [[File:Macro_VisibleAlls2.png|48px]]
</translate>
</translate>
ToolBar [[Image:Macro_VisibleAlls2.png|64px]]
<translate>


<!--T:7-->
{{Code|code=
Second macro [[Macro_Toggle_Visibility2_2-2|Macro Toggle Visibility2 2-2]]


import FreeCAD
#Macro_VisibleAlls
__title__="Macro_DisplayAllObjects2"
__author__ = "openfablab"
__url__ = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.00b"
__date__ = "27/07/2017"

try:
for ShapeNameObj in FreeCAD.actual: # displyed alls objects
#print ShapeNameObj
FreeCADGui.ActiveDocument.getObject(ShapeNameObj).Visibility = True
except Exception:
None }}

<translate>
==Link== <!--T:10-->
==Link== <!--T:10-->
The discussion on the forum [https://forum.freecadweb.org/viewtopic.php?f=8&t=13152&start=10#p184056 Re: Proposal: select one or more pieces, hide the others.]
The discussion on the forum [https://forum.freecadweb.org/viewtopic.php?f=8&t=13152&start=10#p184056 Re: Proposal: select one or more pieces, hide the others.]
Line 97: Line 94:
Original idea [https://www.freecadweb.org/wiki/index.php?title=Macro_Toggle_Visibility Macro_Toggle_Visibility]
Original idea [https://www.freecadweb.org/wiki/index.php?title=Macro_Toggle_Visibility Macro_Toggle_Visibility]
</translate>
</translate>

<languages/>

Latest revision as of 23:01, 7 May 2020

Other languages:

Macro Toggle Visibility2 1-2

Description
This macro must be used with Macro Toggle Visibility2 2-2

This is a set of four related macros for managing the visibility of objects in the Object Model (return on original visibility):
# 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

Macro version: 00.02b
Last modified: 2017-07-27
FreeCAD version: All
Download: ToolBar Icon
Author: openfablab
Author
openfablab
Download
ToolBar Icon
Links
Macro Version
00.02b
Date last modified
2017-07-27
FreeCAD Version(s)
All
Default shortcut
None
See also
Macro Toggle Visibility2 2-2
Macro_Toggle_Visibility

Description

This macro work with Macro Toggle Visibility2 2-2

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

  1. 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
  2. make all objects visible

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

Script 1

ToolBar Icon

Macro_Toggle_Visibility2_1-2.FCMacro

import FreeCAD
# "Macro_Toggle_Visibility2_1-2" associate with "Macro_Toggle_Visibility2_2-2"
__title__="Macro_Toggle_Visibility2_1-2"
__author__ = "openfablab"
__url__     = "http://www.freecadweb.org/index-fr.html"
__version__ = "00.02b"
__date__    = "27/07/2017"
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

Script 2

ToolBar

Second macro Macro Toggle Visibility2 2-2

Link

The discussion on the forum Re: Proposal: select one or more pieces, hide the others.

Original idea Macro_Toggle_Visibility