Macro ExpandTreeItem/it: Difference between revisions

From FreeCAD Documentation
(Updating to match new version of source page)
No edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<languages/>
<languages/>

{{Macro/it
{{Macro/it
|Name=Macro ExpandTreeItem
|Name=Macro ExpandTreeItem
|Icon=Macro_ExpandTreeItem.svg
|Translate=Macro ExpandTreeItem
|Description=Nella vista della struttura espande l'albero selezionato e tutti gli alberi secondari.
|Description=Questa macro espande l'albero selezionato e tutti i sottoalberi nella visualizzazione ad albero.<br/>Se non c'è alcuna selezione, tutti gli alberi vengono espansi.
|Author=wmayer, UR_
|Author=wmayer, UR_
|Version=00.00
|Version=00.02
|Date=2018-07-11
|Date=2019-07-25
|FCVersion=All
|FCVersion=All
|Download=[https://www.freecadweb.org/wiki/images/9/94/Macro_ExpandTreeItem.svg ToolBar Icon]
|Download=[https://www.freecadweb.org/wiki/images/9/94/Macro_ExpandTreeItem.svg ToolBar Icon]
}}
}}


<span id="Description"></span>
==Descrizione==
==Descrizione==


Espande l'albero selezionato e tutti i sottoalberi nella vista ad albero.
Espande l'albero selezionato e tutti i sottoalberi nella vista ad albero.


se l'albero selezionato è già espanso, questo albero e tutti gli alberi secondari vengono compressi
se l'albero selezionato è già espanso, questo albero e tutti gli alberi secondari verranno compressi.


se non ci sono selezioni vengono compressi
se non ci sono selezioni, tutti gli alberi vengono espansi.


[[File:Collapsed00.gif]]
[[File:Collapsed00.gif]]


<span id="Usage"></span>
<div class="mw-translate-fuzzy">
==Uso==
==Utilizzo==
</div>


Copiare la macro nella directory macro, creare la barra degli strumenti e avviare la macro.
Copiare la macro nella directory macro, creare la barra degli strumenti e avviare la macro.
Line 29: Line 30:
==Script==
==Script==


ToolBar Icon .PNG [[File:Macro ExpandTreeItem.png]] and the .SVG [[File:Macro ExpandTreeItem.svg]]
Icona della barra degli strumenti .PNG [[File:Macro ExpandTreeItem.png]] e .SVG [[File:Macro ExpandTreeItem.svg]]


'''Macro_ExpandTreeItem.FCMacro'''
'''Macro_ExpandTreeItem.FCMacro'''
Line 38: Line 39:
# Expands selected tree and all sub trees in the tree view.
# Expands selected tree and all sub trees in the tree view.
# if selected tree is already expanded this tree and all sub trees are collapsed True/False
# if selected tree is already expanded this tree and all sub trees are collapsed True/False
# if there is no selection all trees are collapse False
# if there is no selection all trees are expanded
#
#
__Title__ = "Macro ExpandTreeItem"
__Title__ = "Macro ExpandTreeItem"

Latest revision as of 21:04, 26 January 2024

Other languages:

Macro ExpandTreeItem

Descrizione
Questa macro espande l'albero selezionato e tutti i sottoalberi nella visualizzazione ad albero.
Se non c'è alcuna selezione, tutti gli alberi vengono espansi.

Versione macro: 00.02
Ultima modifica: 2019-07-25
Versione FreeCAD: All
Download: ToolBar Icon
Autore: wmayer, UR_
Autore
wmayer, UR_
Download
ToolBar Icon
Link
Versione macro
00.02
Data ultima modifica
2019-07-25
Versioni di FreeCAD
All
Scorciatoia
Nessuna
Vedere anche
Nessuno

Descrizione

Espande l'albero selezionato e tutti i sottoalberi nella vista ad albero.

se l'albero selezionato è già espanso, questo albero e tutti gli alberi secondari verranno compressi.

se non ci sono selezioni, tutti gli alberi vengono espansi.

Utilizzo

Copiare la macro nella directory macro, creare la barra degli strumenti e avviare la macro.

Script

Icona della barra degli strumenti .PNG e .SVG

Macro_ExpandTreeItem.FCMacro

# -*- coding: utf-8 -*-
#
# Expands selected tree and all sub trees in the tree view.
# if selected tree is already expanded this tree and all sub trees are collapsed True/False
# if there is no selection all trees are expanded
#
__Title__    = "Macro ExpandTreeItem"
__Author__   = "wmayer, UR_"
__Version__  = "00.02"
__Date__     = "2019-07-25"

import PySide
from PySide import QtGui ,QtCore
from PySide.QtGui import *
from PySide.QtCore import *

def toggleAll(tree, item, collapse):
    if collapse == False:
        tree.expandItem(item)
    elif collapse == True:  
        tree.collapseItem(item)

    for i in range(item.childCount()):
        toggleAll(tree, item.child(i), collapse)

mw = Gui.getMainWindow()
trees = mw.findChildren(QtGui.QTreeWidget)

for tree in trees:
    items = tree.selectedItems()

    try:
        if items == []:
            #tree.selectAll()                          # select all object
            for obj in FreeCAD.ActiveDocument.Objects: # select obj.OutList
                if len(obj.OutList) != 0:
                    Gui.Selection.addSelection(obj)
                    items = tree.selectedItems()
            for item in items:
                toggleAll(tree, item, False)
    except Exception:
        None

    for item in items:
            if item.isExpanded() == True:
                toggleAll(tree, item, True)
        #            print ("collapsing")
            else:
                toggleAll(tree, item, False)
        #            print ("expanding")

Link

Objektbaum mit einem Klick komplett aufklappen?