New macro; "Gui1_4", adding options to the Gui

Have some feature requests, feedback, cool stuff to share, or want to know where FreeCAD is going? This is the place.
Forum rules
Be nice to others! Read the FreeCAD code of conduct!
freedman
Veteran
Posts: 3472
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

New macro; "Gui1_4", adding options to the Gui

Post by freedman »

I tried to keep this simple, an addition to FreeCAD, no changing automation or changing properties, just an exercise in what could be added to the current GUI to improve performance. Many users feel that the GUI is fine the way it is, true, I made it better, but without changing anything that it did prior, all I did is add mouse click abilities. Run the macro and then almost everything in the tree can be clicked and then reclicked for some kind of view change. The current FreeCAD App has kind-of a dead end if you reclick a tree icon, I use that reclick (toggle click) to show visual info if I can or help do things.

Here is al list of what happens on a click/reclick of the same icon in the tree:

Part: Expand/collapse the tree to show all subs, no subs expanded
Body: Expand/collapse the tree to show all features
Pad-Pocket-Ect: Any feature with a sketch will Expand/collapse

Here is a list of tree features that toggle Show/hide on a click and then reclick:
Sketches, Datum Planes, Datum Points, Datum Lines, Origin, Origin axis, LCS, Shapebinders. I find this to be a huge time saver and fun. :)

These options could be added to the GUI with no degradation to the current usage, just additions to what is already there.

There is no dialog, when you start the macro it will report "running" and it will end with "bye". To exit, click 5 times on the same (Red/Blue balls ) document icon.

It works in Part and PartDesign but has more tree power in PartDesign.
Thanks


All feedback is welcome.
Last edited by freedman on Sat Jul 17, 2021 11:44 pm, edited 6 times in total.
chrisb
Veteran
Posts: 54277
Joined: Tue Mar 17, 2015 9:14 am

Re: New macro; "Toggle1", adding toggle options to the tree

Post by chrisb »

Not directly related, but as you worked on the tree you could be the expert we need: There are known issues with drag and drop in the tree which should be suppressed in some situations. I know of two:
1) dragging the operations in Path workbench
2) dragging views in TechDraw

Can you help there?
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
freedman
Veteran
Posts: 3472
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro; "Toggle1", adding toggle options to the tree

Post by freedman »

I found a small issue, the macro was not working while in Sketcher, I fixed that. Updating the name to Toggle1.1.
chrisb wrote
Can you help there?
Unfortunately this is the last thing I can work on until the end of summer. I will fix any issues with the macro but I can't take on any more. Good luck.
freedman
Veteran
Posts: 3472
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro; "Toggle1", adding toggle options to the tree

Post by freedman »

I don't have time to research how to highlight edges of features but if someone does and posts some code (or even get it started) I will crank the code into the Toggle macro. I noticed that realthunder did it in Linkstage.
What I would do with the code: When a reclick is done on a feature like Fillet, chamfer, draft, thick, mirror, pattern stuff, I would highlight the edges. Current I do nothing with features like these.

I did think of one additional option to add; On a collapsed Body for instance, one reclick will expand the Body, on the next reclick I would expand to show all the sketches of the features. The next reclick would collapse everything back to normal. This should really speed up object editing.

I have found that since I can change Origin axis so quickly I go in and set the Origin base axis to "XY for instance" and then with one click I can turn my model base axis ON/Off. Normally I didn't bother to do this because it takes so many Select, mouse click, Select, mouse click.....

I also noticed running the macro makes redundant the expand/collapse indicator next to the Tree object names, I would much rather click on the Name than focusing my mouse on the expand/collapse arrow, it's just easier. It might be better if the expand/collapse arrow changed to On/Off of visibility. I believe with a couple more steps with this concept the space bar usage could be replace by mouse clicks. I would enjoy not having to space bar because my desk is always a mess. :)
Thanks
freedman
Veteran
Posts: 3472
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro; "Toggle1", adding toggle options to the tree

Post by freedman »

I found another small issue; the macro has trouble finding deleted objects. Da!
Sorry for all the changes. Updated the macro (in first post) to Toggle1_2.
freedman
Veteran
Posts: 3472
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro; "Toggle", adding toggle options to the tree

Post by freedman »

For all that are following this topic; I noticed that sometimes I need to toggle a feature when I shouldn't need to, I will look at that this week. It has to do with detecting the double-click.

I am totally convinced this has increased my efficiency in PartDesign, being able to expand the Body, then the feature, then turn Sketches on/off so fast, all using the mouse in an very consistent behavior.

For any new users, set "Sync view" enabled so we can click on the object in 3D and the tree auto expands.

In the next month I will add a simple dialog. I would like to have options for PartDesign of auto expand/collapse and visible/hide for sketches. If anyone has any ideas for options, they are welcome.

Using the re-click scheme there could be options for a third and forth click or maybe a loop of the two. Maybe on a Body selection a third/forth click makes visible/hide in a loop, this could reduce the space-bar usage.
freedman
Veteran
Posts: 3472
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro; "Gui1_2", adding options to the Gui

Post by freedman »

This macro is all about optimizing the Gui tree selections. The existing Gui was making my hand/wrist tired and wearing me down by the end of the day because of the repetitive operations. So, I wrote this macro to bring the Gui tree usage to a new level of efficiency. I would only hope some of these changes get included in FreeCAD.

I added a dialog that can be opened by clicking twice on the document icon in the tree, it looks like this (see pic). Clicking twice again will hide the dialog or you can use the hide button.

First, the running defaults; click on just about anything in the tree and see an expand/collapse or a visibility change. All operations are toggle so clicking again will undo what was done. As a for-instance, click on a Sketch and it gets highlighted, click again and it's hidden; click on a feature and it expands, click again and it collapses. Just these two operations save probably a hundred mouse-clicks or space bars in a day.
Going down the dialog with descriptions.

Exit macro: This will close the macro.
Resolution: Set one of three resolutions (really just sets deviation), medium is the FreeCAD default. This will clean up those chunky circles. You might need to re-check this if new circles are created and it can take some time to do this operation on large models, be patient.
Flat lines: Toggle between "Flat lines" and "Shaded" mode (global).
Random color all: Click to randomize the color (of each object"). Every tenth click will give you the standard default Grey. This is a global operation.
Auto 3D view in sketcher: If enabled, every sketch will open in the current screen view. If disabled the sketch will open in the standard (Normal) view.
In Sketcher, 2D or 3D: Toggle between a 3D (prior view) and 2D(Normal) view.
Translucent in Sketcher: If enabled, when entering Sketcher the global transparency will be set to translucent. The view will return to the previous settings when sketcher exits, your transparencies are saved and restored.
Translucent or solid, Global: Click to see the model in translucent mode. This is very useful in Sketcher to see thru the model. While in translucent mode, click on a feature in a body and the object will be highlighted in the 3D, for both modeling and sketching.
Body toggle Tip/feature: When enabled, clicking on the same Body feature 3 and 4 times has an effect. Click #3 will highlight the current feature, click #4 will change the highlightlight to the Tip feature, this will toggle until a new feature is selected. This can be very useful walking thru a model to see how it was built or to identify features.
Expand/collapse Show/hide: When enabled, if a body is clicked on and it expands, all the child sketches will be visible, if the Body is collapsed then all the child sketches will be hidden. This is also true for selecting individual features, the child sketch/sketches will be follow suite.
Hide: This hides the dialog, this is just a hide not a Close.
------------------
Most all the dialog options also work while in Sketcher so there are some cool interactions, too many to list. One main tool is the Translucent or solid, global checkbox, it stands out bracketed because of the powerful nature of being able to switch visualization.

In the dialog design I use checkboxes for display options, some perfom an operation without changing the checkbox.

The macro has a built-in (start with running the FreeCAD app). If you place the macro file in the "Mod" directory and rename the file "InitGui.py" it will auto-start with FreeCAD. When it starts it writes out the version # to the report window.

I make these False: "HideDependent", "ShowSupport","EnableAnimation". This should be of little concern. I also create a new property for saving the transparencies of objects.

I have used this macro for hours, it is tight and the code is very stable. This macro is a huge step forward for using FreeCAD on a daily basis. Experts, please try this, if not to use but to see what is possible for the Gui.
I would say it works on anything 0.19 and newer, also Part and Part Design.
Have fun.
Attachments
Gui1_4.FCMacro
(25.72 KiB) Downloaded 22 times
gui1_3.JPG
gui1_3.JPG (83.33 KiB) Viewed 1066 times
Last edited by freedman on Mon Jul 19, 2021 11:47 pm, edited 7 times in total.
Syres
Veteran
Posts: 2901
Joined: Thu Aug 09, 2018 11:14 am

Re: New macro; "Gui1_2", adding options to the Gui

Post by Syres »

Some constructive feedback, I can't get the macro to start on either of my 0.19 or 0.20 Windows builds, here is the output from Report View:

Code: Select all

11:44:28  Running Gui1_2
11:44:28  Traceback (most recent call last):
11:44:28    File "E:/Data/FreeCAD/Macro/Gui1_2.FCMacro", line 489, in myfunc
11:44:28      visCB = cbToolBox()  
11:44:28    File "E:/Data/FreeCAD/Macro/Gui1_2.FCMacro", line 119, in __init__
11:44:28      tw = mw.findChild(QDock,twname).findChild(QTree) 
11:44:28  AttributeError: 'NoneType' object has no attribute 'findChild'
I subsequently got some debug info from around line 119:

Code: Select all

twname = Tree view
mw.findChild(QDock,twname) = None
mw = <PySide2.QtWidgets.QMainWindow(0x1fec40) at 0x0000000005FCD540>
I've tried different files which makes no difference so I'm guessing it's something to do with my config files or builds that is the root cause.

OS: Windows 7 Version 6.1 (Build 7601: SP 1)
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.19.24291 (Git)
Build type: Release
Branch: releases/FreeCAD-0-19
Hash: 7b5e18a0759de778b74d3a5c17eba9cb815035ac
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/United Kingdom (en_GB)

OS: Windows 7 Version 6.1 (Build 7601: SP 1)
Word size of FreeCAD: 64-bit
Version: 0.20.25065 (Git)
Build type: Release
Branch: master
Hash: 4de2ad46b2b9c78ac2721a0dbea7c19306261095
Python version: 3.8.6+
Qt version: 5.15.2
Coin version: 4.0.1
OCC version: 7.5.0
Locale: English/United Kingdom (en_GB)

Edit: Same error on Linux:

OS: Linux Mint 19.3 (X-Cinnamon/cinnamon)
Word size of FreeCAD: 64-bit
Version: 0.20.25285 (Git)
Build type: Release
Branch: master
Hash: 8b061cecc269c4ae0fb2637cf2a580d8a696a969
Python version: 3.6.9
Qt version: 5.9.5
Coin version: 4.0.0a
OCC version: 7.3.0
Locale: English/UnitedKingdom (en_GB)


May I ask for your version info?
Syres
Veteran
Posts: 2901
Joined: Thu Aug 09, 2018 11:14 am

Re: New macro; "Gui1_2", adding options to the Gui

Post by Syres »

Here's my version that works on my builds, I had to make a change to line 440 with regard to ShapeColor as well as the changes around line 119 to get the macro to start.

One other observation, the code for Expand/Collapse seems a bit slow to me, on a cylinder head made in PD, the PC went to sleep for a good minute or two. I use the EditMode macro for isolating an object in an assembly written by @paulo_cmv using the TreeWidget and the iteration seems a lot quicker, I've attached it for your observations.
Attachments
Gui1_2.FCMacro
(24.57 KiB) Downloaded 25 times
EditMode.FCMacro
(4.52 KiB) Downloaded 21 times
freedman
Veteran
Posts: 3472
Joined: Thu Mar 22, 2018 3:02 am
Location: Washington State, USA

Re: New macro; "Gui1_2", adding options to the Gui

Post by freedman »

There must something weird in the findChild area. Your version starts but the macro does not do anything, on my machine. I'm not sure what to do with that issue.

I updated the macro and fixed the color issue. I also added 3 different options for resolution. I forgot that on large models we need at least 3 levels to work with.

I work on some large models and see no speed issues with expand/collapse. I see Parts with 10 bodies expand in a flash. I'm on a Intel P5, 3.3 Ghz. with a medium range graphics card. It runs here on 0.19.235

I guess there are always going to be some differences between systems, I will look at Editmode, maybe I can make this faster.

Thanks

My info

Code: Select all

OS: Windows 10 (10.0)
Word size of FreeCAD: 64-bit
Version: 0.20.24910 (Git)
Build type: Release
Branch: master
Hash: 089b2ae47824232f649eb74ce1f97673cf77b78c
Python version: 3.8.10
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.2
Locale: English/United States (en_US)
Post Reply