[Bug Solved] Why using generated dot grid instead of grid plane? [for Thomas]

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
User avatar
thomas-neemann
Veteran
Posts: 11729
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Why using generated dot grid instead of grid plane? [for Thomas]

Post by thomas-neemann »

ragohix769 wrote: Sat Sep 18, 2021 10:15 am ....
There are a lot of Linux taste and distributions and that's good IMHO, but GNU-Linux it's a kernel (monolitic) and it's just one, and one only. ...
i can imagine that the master version will be something like the linux kernel and other surfaces, macro collections, specializations such as mechanical engineering, architecture, commercial support, etc. appear as distributions.
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
paullee
Veteran
Posts: 5092
Joined: Wed May 04, 2016 3:58 pm

Re: Why using generated dot grid instead of grid plane? [for Thomas]

Post by paullee »

ragohix769 wrote: Sat Sep 18, 2021 9:34 am Nope, the problem is that snap to grid just for now it's not working (in DraftWB) if you have an object or a face in front o you. See here:
I see :) So there is a serie of issues then, 1st is Snap to Grid fails at some cases, and it is not 3D, etc. etc.

There are developers working on Draft. Maybe other users can do is to suggest best practice, submit Feature Request, debugging etc. Unfortunately, these features in Draft is too advanced for me :D

Can you search if there is similar report / request / do some feature request in the Mantis Bugtracker ?

Hope the community would help the development of the Draft, Arch & BIM workbench.
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Why using generated dot grid instead of grid plane? [for Thomas]

Post by carlopav »

In my opinion it is a bug and it's caused here:
https://github.com/FreeCAD/FreeCAD/blob ... er.py#L485

Code: Select all

    def snapToObject(self, lastpoint, active, constrain,
                     eline, point, oldActive):
         [...]
        if not snaps:
            self.spoint = self.cstr(lastpoint, constrain, point)
            self.running = False
            if self.trackLine and lastpoint:
                self.trackLine.p2(self.spoint)
                self.trackLine.color.rgb = Gui.draftToolBar.getDefaultColor("line")
                self.trackLine.on()
            return self.spoint
self.spoint is the cursor position in the space.
But that's not correct: snapToObject should return None, and then the upper method snap() should handle the case, checking for extension and grid snaps before assuming the snapped point is self.spoint.

I'm attaching the modified version of Snapper.py to be substituted in \Mod\Draft\draftguitools

I would higly appreciate some extensive test before going for a PR (https://github.com/FreeCAD/FreeCAD/comp ... d?expand=1).
Attachments
gui_snapper.py
(73.13 KiB) Downloaded 44 times
follow my experiments on BIM modelling for architecture design
User avatar
thomas-neemann
Veteran
Posts: 11729
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Why using generated dot grid instead of grid plane? [for Thomas]

Post by thomas-neemann »

carlopav wrote: Sun Sep 19, 2021 12:05 pm
thank you for the effort.

if i paste it into the python window or create a macro from it, i can't see any effect. I guess I'm doing it wrong. I would like to test it, but need a little guide
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: Why using generated dot grid instead of grid plane? [for Thomas]

Post by carlopav »

thomas-neemann wrote: Sun Sep 19, 2021 1:15 pm if i paste it into the python window or create a macro from it, i can't see any effect. I guess I'm doing it wrong.
Yes, you are :)
To test it you should download the gui_snapper.py file that you find attached to the previous post and substitute to the one into your FreeCAD folder.
Mine is in C:\Users\myname\Documents\FreeCAD-Source\FreeCAD_compiled\Mod\Draft\draftguitools.
follow my experiments on BIM modelling for architecture design
User avatar
thomas-neemann
Veteran
Posts: 11729
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Why using generated dot grid instead of grid plane? [for Thomas]

Post by thomas-neemann »

carlopav wrote: Sun Sep 19, 2021 1:23 pm
thanks for the info, i can test it with my windows version, wonderful.
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
ragohix769
Posts: 555
Joined: Sat Jul 18, 2020 7:04 am
Location: Rome - Italy

Re: Why using generated dot grid instead of grid plane? [for Thomas]

Post by ragohix769 »

carlopav wrote: Sun Sep 19, 2021 12:05 pm In my opinion it is a bug and it's caused here:
https://github.com/FreeCAD/FreeCAD/blob ... er.py#L485

Code: Select all

    def snapToObject(self, lastpoint, active, constrain,
                     eline, point, oldActive):
         [...]
        if not snaps:
            self.spoint = self.cstr(lastpoint, constrain, point)
            self.running = False
            if self.trackLine and lastpoint:
                self.trackLine.p2(self.spoint)
                self.trackLine.color.rgb = Gui.draftToolBar.getDefaultColor("line")
                self.trackLine.on()
            return self.spoint
self.spoint is the cursor position in the space.
But that's not correct: snapToObject should return None, and then the upper method snap() should handle the case, checking for extension and grid snaps before assuming the snapped point is self.spoint.

I'm attaching the modified version of Snapper.py to be substituted in \Mod\Draft\draftguitools

I would higly appreciate some extensive test before going for a PR (https://github.com/FreeCAD/FreeCAD/comp ... d?expand=1).
I'm speachless: IT WORKS!!!!

(it appear to be working, at least, I'm with KDE on Linux)

I've tested too with an image imported to retrace lines over... It's working!

It was a bug so simple to solve, it's incredbile that till now noboby solved it. Really really BIG thank you!

GRAZIE, sei un grande!

[the only problem, if we can name it this way, it's that if you pass mouse over an object now he auto select it even without clicking changing his color, that's can be a problem with some color contrast so you cannot see sometimes snapping points]
After #ElonMuskBuyTwitter I'm no more on Twitter, that's really enough :-(
=> Now you can find me here on #Mastodon: https://mastodon.uno/@opensoul - I hope more people do the same :-)
User avatar
thomas-neemann
Veteran
Posts: 11729
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Why using generated dot grid instead of grid plane? [for Thomas]

Post by thomas-neemann »

carlopav wrote: Sun Sep 19, 2021 1:23 pm
it works here too, wonderful, 1000 thanks

1.png
1.png (16.37 KiB) Viewed 1823 times
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
ragohix769
Posts: 555
Joined: Sat Jul 18, 2020 7:04 am
Location: Rome - Italy

Re: Why using generated dot grid instead of grid plane? [for Thomas]

Post by ragohix769 »

thomas-neemann wrote: Sun Sep 19, 2021 5:49 pm
carlopav wrote: Sun Sep 19, 2021 1:23 pm
it works here too, wonderful, 1000 thanks

No more artificial generated dot grid to have the right snapping :-)
I'm very happy, thanks another time Carlo. And go on for PR
After #ElonMuskBuyTwitter I'm no more on Twitter, that's really enough :-(
=> Now you can find me here on #Mastodon: https://mastodon.uno/@opensoul - I hope more people do the same :-)
carlopav
Veteran
Posts: 2062
Joined: Mon Dec 31, 2018 1:49 pm
Location: Venice, Italy

Re: [Bug Solved] Why using generated dot grid instead of grid plane? [for Thomas]

Post by carlopav »

Great! thanks a lot for testing.
Here the PR
follow my experiments on BIM modelling for architecture design
Post Reply