Macro ExpandTreeItem/it: Difference between revisions
mNo edit summary |
(Updating to match new version of source page) |
||
Line 1: | Line 1: | ||
<languages/> |
<languages/> |
||
<div class="mw-translate-fuzzy"> |
|||
{{Macro/it |
{{Macro/it |
||
|Name=Macro ExpandTreeItem |
|Name=Macro ExpandTreeItem |
||
Line 8: | Line 9: | ||
|Date=2018-07-11 |
|Date=2018-07-11 |
||
}} |
}} |
||
</div> |
|||
==Descrizione== |
==Descrizione== |
||
Line 15: | Line 17: | ||
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 vengono compressi |
||
<div class="mw-translate-fuzzy"> |
|||
se non ci sono selezioni vengono espansi tutti i rami (se sono già espansi vengono compressi) |
se non ci sono selezioni vengono espansi tutti i rami (se sono già espansi vengono compressi) |
||
</div> |
|||
[[File:Collapsed00.gif]] |
[[File:Collapsed00.gif]] |
||
Line 25: | Line 29: | ||
==Script== |
==Script== |
||
ToolBar Icon .PNG [[File:Macro ExpandTreeItem.png]] and the .SVG [[File:Macro ExpandTreeItem.svg]] |
|||
⚫ | |||
⚫ | |||
''' |
|||
{{Code|code= |
{{Code|code= |
||
# -*- coding: utf-8 -*- |
# -*- coding: utf-8 -*- |
||
# |
# |
||
# 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 |
# 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 |
# if there is no selection all trees are collapse False |
||
# |
# |
||
__Title__ = "Macro ExpandTreeItem" |
__Title__ = "Macro ExpandTreeItem" |
||
__Author__ = "wmayer, UR_" |
__Author__ = "wmayer, UR_" |
||
__Version__ = "00. |
__Version__ = "00.02" |
||
__Date__ = " |
__Date__ = "2019-07-25" |
||
import PySide |
import PySide |
||
Line 68: | Line 72: | ||
Gui.Selection.addSelection(obj) |
Gui.Selection.addSelection(obj) |
||
items = tree.selectedItems() |
items = tree.selectedItems() |
||
for item in items: |
|||
toggleAll(tree, item, False) |
|||
except Exception: |
except Exception: |
||
None |
None |
||
Line 78: | Line 84: | ||
toggleAll(tree, item, False) |
toggleAll(tree, item, False) |
||
# print ("expanding") |
# print ("expanding") |
||
}} |
}} |
||
==Link== |
==Link== |
Revision as of 14:33, 25 July 2019
Descrizione |
---|
Nella vista della struttura espande l'albero selezionato e tutti gli alberi secondari. Versione macro: 00.00 Ultima modifica: 2018-07-11 Autore: wmayer, UR_ |
Autore |
wmayer, UR_ |
Download |
None |
Link |
Raccolta di macro Come installare le macro Personalizzare la toolbar |
Versione macro |
00.00 |
Data ultima modifica |
2018-07-11 |
Versioni di FreeCAD |
None |
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 vengono compressi
se non ci sono selezioni vengono espansi tutti i rami (se sono già espansi vengono compressi)
Uso
Copiare la macro nella directory macro, creare la barra degli strumenti e avviare la macro.
Script
ToolBar Icon .PNG and the .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 collapse False
#
__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")