Info about new community or project announcements, implemented features, classes, modules or APIs. Might get technical!
PLEASE DO NOT POST HELP REQUESTS OR OTHER DISCUSSIONS HERE!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
easyw-fc wrote: ↑Wed Sep 12, 2018 3:16 pm
very good addition!
Is there a way to expand the tree of the document through python command?
I don't think there is. The TreeWidget is not exposed into Python (AFAIK).
The whole feature relies on a new parameter Preferences->View->TreeViewDocument which takes an integer value 0/1/2 corresponding to the 3 different modes. I used an integer so it can be extended if somebody comes up with another mode. Anyhow, once the value is set there needs to be a trigger, the simplest way is calling App::setActiveDocument - although the Python version might check if there is a change and shortcut the logic if you're setting the same document (Gui::setActiveDocument does that for sure).
chrisb wrote: ↑Wed Sep 12, 2018 2:23 pm
I used the new default visibility to switch between two models in order to compare the properties of some objects. I realized that the properties are not cleared when switching between documents.
This is something I wasn't sure of. Currently the TreeWidget doesn't mess with the selection - it's probably not trivial and I wasn't brave enough to make a call on this behaviour. There are a few use cases which would not be possible in "Single Document" view. Also there is the question how "Collapse/Expand" should work. I figured maybe give everyone a little while to get used to this and figure out what works and what doesn't.
Wow - that is quite some code sorcery right there.
The top item (document) cannot be selected, which is why the script doesn't work to expand the document. I've added the bottom 4 lines which do expand the document - but, it expands the document regardless if the document is currently visible or not. So even if you are in "Single Document" mode, it will still expand the hidden documents as well (you'll see when you activate them):
# todo: * ActiveDocument > 1
# * encoding
import FreeCAD
from PySide import QtGui
def visi(item):
txt = item.text(0).encode('ascii', 'replace')
objs = FreeCAD.ActiveDocument.getObjectsByLabel(txt)
return objs and obj[0].ViewObject.Visibility
def expandAll(tree, item):
tree.expandItem(item)
for i in range(item.childCount()):
if visi(item.child(i)):
expandAll(tree, item.child(i))
mw=Gui.getMainWindow()
trees=mw.findChildren(QtGui.QTreeWidget)
for tree in trees:
item=tree.selectedItems()
for i in item:
if visi(i):
expandAll(tree, i)
root=tree.itemAt(0,0)
if root and tree.isActiveWindow():
for i in range(root.childCount()):
tree.expandItem(root.child(i))
mlampert wrote: ↑Wed Sep 12, 2018 10:00 pm
I figured maybe give everyone a little while to get used to this and figure out what works and what doesn't.
Of course! I guess restoring the old view is a considerable amount of work. If there is a chance to get this, there is no urgent need to do anything. Before it is postponed too far in t he future I would appreciate having the property panel cleared, because currently it is still possible to change a value in the not selected document.
mlampert wrote: ↑Tue Sep 11, 2018 6:31 pm
As of last night the Document Tree widget has 3 options for what is being displayed:
* Only the currently active document
* All documents as it used to be
* Expand the active document and collapse all others
Due to the challenges and confusion by novice users the default behaviour has changed to only show the currently active document. If you want to change the behaviour, go to the menu "View" -> "Document Tree".
mlampert wrote: ↑Wed Sep 12, 2018 10:00 pm
I figured maybe give everyone a little while to get used to this and figure out what works and what doesn't.
Of course! I guess restoring the old view is a considerable amount of work. If there is a chance to get this, there is no urgent need to do anything. Before it is postponed too far in t he future I would appreciate having the property panel cleared, because currently it is still possible to change a value in the not selected document.
Clearing the proper panel means messing with the selection. OTOH, editing the properties of a "Body" in the other document would have made my top 10 of annoying "I can't believe I just did that" list. So I thought about disabling the property panel (setting read-only), which should give us the best of both worlds.
pablogil wrote: ↑Tue Sep 11, 2018 9:36 pm
It’s really a nice feature for newbies
And for oldies as well.
Thanks!!
+1, although I'm not sure I like to identify myself as an oldie
Thanks for adding this. 90% of the time I prefer to see only the active document in the tree, but it is nice to know I can switch it back to the old behaviour for the other 10%.
This is one of the many little improvements that makes v0.18 worthwhile.
One thing I have noticed is the small indentation (by design) in the tree. When I have a Body expanded that runs half way down the page it's kind of hard to find where the next Body starts especially if the next Body is disabled. I have to visually scan down thru the features until I find the next Body in the list. Not sure if there's something simple to do, maybe a thin horizontal line between bodies as a thought or maybe some highlight.