sketcher carbon copy

Post here for help on using FreeCAD's graphical user interface (GUI).
Forum rules
and Helpful information
IMPORTANT: Please click here and read this first, before asking for help

Also, be nice to others! Read the FreeCAD code of conduct!
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: sketcher carbon copy

Post by openBrain »

drmacro wrote: Mon Nov 22, 2021 2:36 pm
  • on the XY plane, no problem
  • on the YZ plane, no problem
  • on the XZ plane, doesn't work
Indeed looking at decimals shows that XZ sketches aren't perfectly mapped :

Code: Select all

>>> App.ActiveDocument.Sketch001.Placement.Matrix #XY
Matrix ((1,0,0,0),(0,1,0,0),(0,0,1,0),(0,0,0,1))
>>> App.ActiveDocument.Sketch002.Placement.Matrix #XZ
Matrix ((1,0,-0,0),(-0,2.22045e-16,-1,0),(0,1,2.22045e-16,0),(0,0,0,1))
>>> App.ActiveDocument.Sketch003.Placement.Matrix #YZ
Matrix ((0,0,1,0),(1,0,0,0),(0,1,0,0),(0,0,0,1))
However this doesn't explains why 2 XZ sketches are considered as being not parallel... :?
But at least it shows that there is something special with it.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: sketcher carbon copy

Post by openBrain »

I made another test creating a first sketch with random rotation. Then create a 2nd sketch mapped to XY plane of the 1st sketch.
Carbon Copy says both sketches haven't the same XY axis direction...
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: sketcher carbon copy

Post by TheMarkster »

Nice detective work. Perhaps some rounding to 15 digits (or so) in the sketcher algorithm that determines whether 2 sketches are on the same plane would solve the issue, or at least be a reasonable workaround.
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: sketcher carbon copy

Post by openBrain »

OK, as foreseeable it is some floating point comparison issue.
Can see here (and again several times in the lines below) : https://github.com/FreeCAD/FreeCAD/blob ... .cpp#L3438

Does one know if FreeCAD code already has a standard epsilon value for floating point comparison ? Eventually a custom comparison function ?
TheMarkster
Veteran
Posts: 5505
Joined: Thu Apr 05, 2018 1:53 am

Re: sketcher carbon copy

Post by TheMarkster »

Precision::Confusion() ?
CrashedAgain
Posts: 186
Joined: Wed Jan 15, 2020 8:39 pm

Re: sketcher carbon copy

Post by CrashedAgain »

Just checked this and found the same as @openBrain. x-y works, z-y works, but x-z has "issues".

A suggestion: since ctrl-alt works when the planes don't match, and it also works when the planes do match (I checked), why not just edit the procedure so that the ctrl-alt is the default procedure (without having to actually hold the ctrl-alt keys).

And - I just downloaded the current weekly build (26375), set permissions to run as a program, and started it. It also reports as a "Branch".

OS: Ubuntu 20.04.3 LTS (MATE/mate)
Word size of FreeCAD: 64-bit
Version: 0.20.26375 (Git) AppImage
Build type: Release
Branch: (HEAD detached at 8a6e3d1)
Hash: 8a6e3d1b766a34546806b22d750929c2d00e30a6
Python version: 3.9.7
Qt version: 5.12.9
Coin version: 4.0.0
OCC version: 7.5.3
Locale: English/Canada (en_CA)
chrisb
Veteran
Posts: 53921
Joined: Tue Mar 17, 2015 9:14 am

Re: sketcher carbon copy

Post by chrisb »

Having Ctrl+Alt as the default bears the danger of using it inadvertently. Of course it is easier, but for other reasons it is better to alert the user before he uses CarbonCopy of non coplanar sketches or from other bodies.
A Sketcher Lecture with in-depth information is available in English, auf Deutsch, en français, en español.
drmacro
Veteran
Posts: 8865
Joined: Sun Mar 02, 2014 4:35 pm

Re: sketcher carbon copy

Post by drmacro »

Seems like a real workaround that masks an issue that needs to be addressed.

Two sketches created on a given base plane should be at 0 of said plane. Certainly not just 2 out of 3 planes...FreeCAD should be able to attain a higher grade than 66.6%. :roll:

It also sounds like the pockets that don't get flat bottoms issue might have related routes... maybe.
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
drmacro
Veteran
Posts: 8865
Joined: Sun Mar 02, 2014 4:35 pm

Re: sketcher carbon copy

Post by drmacro »

In the attached file there are three Body objects.

Each Body has a Pad and a Pocket.

If you hover over the bottom face of the pocket in each, you will see that the in the Pad/Pocket created on the XY and YZ plane the coordinate of the bottom is 5.00mm over the face. But, in the one created on the XZ, the bottom face varies +- around 5mm.
Attachments
PlaneTest.FCStd
(54.62 KiB) Downloaded 20 times
Star Trek II: The Wrath of Khan: Spock: "...His pattern indicates two-dimensional thinking."
openBrain
Veteran
Posts: 9034
Joined: Fri Nov 09, 2018 5:38 pm
Contact:

Re: sketcher carbon copy

Post by openBrain »

There are 2 problems that got revealed in this thread:
1) The mapping to XZ plane isn't perfect as the working plane is very slightly flipped
2) 2 parallel (aligned) planes are not always detected as such

Both are probably due to floating point computation (didn't analyze 1, 2 for sure). Will try to tackle this in the coming days.
Post Reply