[Solved] 0.19pre, auto off Draft grid on Sketcher edit mode

A forum for research and development of the user interface of FreeCAD
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: 0.19pre UI suggestion, auto off Draft grid on Sketcher edit mode

Post by vocx »

Kunda1 wrote: Sat Mar 07, 2020 12:02 am ...
Edit: Also found in the code: https://github.com/FreeCAD/FreeCAD/blob ... and.h#L592
...
How could we annotate it better so it's clear while studying the API what it does. Is it just me or does that seem super generic and nondescript?
Join the club. The internals of FreeCAD have a ton of functionality but often nobody has documented them in a proper way. You essentially have to dig through the C++ code to see what else is available.

The proper way to document this is to see it in practice. The src/Mod/TemplatePyMod directory defines a workbench that is not installed but which has some example commands. This should be cleaned up and updated. Essentially, the developer documentation in the Power users hub is based on these examples. What would be ideal is to create a complete "example workbench" with many fake objects and Gui commands which can be used to demonstrate many things. And obviously, this workbench should be described fully in the wiki.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
fc_tofu
Posts: 653
Joined: Sun Jan 05, 2020 4:56 pm

Re: 0.19pre UI suggestion, auto off Draft grid on Sketcher edit mode

Post by fc_tofu »

triplus wrote: Fri Mar 06, 2020 11:41 pm Fair point: PR
Thank you, @triplus, I tried your fix, and it works well on my machine now.
Fortunately, the hotkey "G, R" also works now, there is no conflict with Sketcher hotkeys, even customizing toggle-draft-grid to Sketcher toolbar is not neccessary.
So, we finally got the easiest workaround for the "Double Grid" issue. And I think, in most cases, it is enough.
fsc_2020-03-07_164316.jpg
fsc_2020-03-07_164316.jpg (277.26 KiB) Viewed 2418 times
fsc_2020-03-07_164326.jpg
fsc_2020-03-07_164326.jpg (263.1 KiB) Viewed 2418 times
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: 0.19pre UI suggestion, auto off Draft grid on Sketcher edit mode

Post by vocx »

Kunda1 wrote: Fri Mar 06, 2020 11:50 pm ...

Code: Select all

'CmdType' : 'ForEdit'
What is this sorcery ?
https://github.com/FreeCAD/FreeCAD/comm ... #L586-L587

It seems it was introduced by realthunder during the LinkMerge. It is git commit b1c0de8da.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: [Solved] 0.19pre, auto off Draft grid on Sketcher edit mode

Post by vocx »

realthunder wrote: ping
How is the 'CmdType' : 'ForEdit' property supposed to work?

I tried it with some Draft tools and didn't seem to work. Is there something special about this?

Triplus submitted pull request #3137 to be able to use Draft_ToggleGrid when the sketcher is in edit mode, but I think this isn't necessary at all. The grid can be turned on and off currently without problem, even inside the Sketcher edit mode.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
realthunder
Veteran
Posts: 2190
Joined: Tue Jan 03, 2017 10:55 am

Re: [Solved] 0.19pre, auto off Draft grid on Sketcher edit mode

Post by realthunder »

vocx wrote: Thu Mar 12, 2020 5:00 am How is the 'CmdType' : 'ForEdit' property supposed to work?
I didn't add 'ForEdit', it is there before me. If the command has 'ForEdit' keyword inside its 'CmdType', then it will not be disable when editing some object, e.g. the sketch. If no 'ForEdit' is found, it will then check for other keywords, like AlterDoc, Alter3DView, etc, and disable the command according to current editing control restriction. See here.

A command by default has AlterDoc|Alter3DView|AlterSelection, so it will be disabled in most editing task.
Try Assembly3 with my custom build of FreeCAD at here.
And if you'd like to show your support, you can donate through patreon, liberapay, or paypal
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: [Solved] 0.19pre, auto off Draft grid on Sketcher edit mode

Post by vocx »

realthunder wrote: Thu Mar 12, 2020 7:14 am I didn't add 'ForEdit', it is there before me....
Really? I saw git commit b1c0de8da and it seems to be part of the LinkMerge. The "ForEdit" is added to src/Gui/Command.h.

Thanks for the information.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: 0.19pre UI suggestion, auto off Draft grid on Sketcher edit mode

Post by triplus »

fc_tofu wrote: Sat Mar 07, 2020 10:10 am Thank you, @triplus, I tried your fix, and it works well on my machine now.
You're welcome and thanks for testing and providing the feedback.

@vocx

It's not enough to be in the Sketcher workbench, you have to be in the Sketcher edit mode, to see the difference. Didn't check who, but the related code added way back.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: 0.19pre UI suggestion, auto off Draft grid on Sketcher edit mode

Post by vocx »

triplus wrote: Fri Mar 13, 2020 5:56 pm It's not enough to be in the Sketcher workbench, you have to be in the Sketcher edit mode...
I was in the Sketcher edit mode. You can use the Draft_ToggleGrid command with or without the CmdType that you added.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: 0.19pre UI suggestion, auto off Draft grid on Sketcher edit mode

Post by triplus »

vocx wrote: Fri Mar 13, 2020 6:08 pm I was in the Sketcher edit mode. You can use the Draft_ToggleGrid command with or without the CmdType that you added.
Try again with the official FreeCAD 0.18 AppImage. Likely you have overlooked some specific in your toolchain.
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: 0.19pre UI suggestion, auto off Draft grid on Sketcher edit mode

Post by vocx »

triplus wrote: Fri Mar 13, 2020 6:16 pm Try again with the official FreeCAD 0.18 AppImage...
I tried with the 0.19 version. I tried with 0.19 before your patch, hence why I said your patch is not necessary in the new version.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
Post Reply