Draft is not showing the correct angle dimension

A forum dedicated to the Draft, Arch and BIM workbenches development.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Draft is not showing the correct angle dimension

Post by jfc4120 »

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.2.29177 +426 (Git)
Build type: Release
Branch: (HEAD detached from 0.20.2)
Hash: 930dd9a76203a3260b1e6256c70c1c3cad8c5cb8
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods: 
  * Help 1.0.3

I was just testing out some geometry, and ran across this:

I used the macro: Align_View_to_Face.FCMacro

I also had a sketch where I bisected an angle.

The sketch shows the correct angle of 62.63 degrees.

@edwilliams16 python script he helped me with also show the correct, here is script:

Code: Select all

import FreeCAD, FreeCADGui
# -*- coding: utf-8 -*-
import FreeCAD, FreeCADGui
import Draft
import math
# from math import cos, sin, radians
from PySide import QtGui

convert = 25.4
TOTAL = 0
getDouble = QtGui.QInputDialog.getDouble
Vector, Placement = App.Vector, App.Placement
doc = App.ActiveDocument

start_point = Vector(0, 0, 0)
selX = FreeCADGui.Selection.getSelectionEx()
PrintMsg = FreeCAD.Console.PrintMessage
PrintMsg("Objects selected:\n")
KOUNT = 0
# added
for sel in selX:
    KOUNT = KOUNT + 1
    v = sel.Object.Shape
    X = v.Point.x * .039370078
    Y = v.Point.y * .039370078
    Z = v.Point.z * .039370078


    if KOUNT == 1:
        multlist = [[X, Y, Z]]
    if KOUNT > 1:
        multlist.append([X, Y, Z])

# added new


p1 = App.Vector(multlist[0][0], multlist[0][1], multlist[0][2])
p2 = App.Vector(multlist[1][0], multlist[1][1], multlist[1][2])
p3 = App.Vector(multlist[2][0], multlist[2][1], multlist[2][2])
#p = App.Vector(multlist[3][0], multlist[3][1], multlist[3][2])
#q = App.Vector(multlist[4][0], multlist[4][1], multlist[4][2])

#=========================================================================
#===============================================================================================

ang1 = math.degrees((p2 - p1).getAngle(p3 - p1))
print(ang1)
#good ang2 = math.degrees((p3 - p2).getAngle(p1 - p2))
#ang2 = math.degrees((p1 - p2).getAngle(p3 - p2))
#print(ang2)
#ang3 = degrees((p1 - p3).getAngle(p2 - p3))

#The side lengths are:

#Code: Select all

#L12 = (p1 - p2).Length
L12 = (p2 - p1).Length
print(L12)
#L23 = (p2 - p3).Length
#L31 = (p3 - p1).Length

Yet if I dimension the angle in draft mode, it shows the wrong angle, any ideas as of why?

Drawing and images attached:
Attachments
s3.png
s3.png (12.49 KiB) Viewed 1101 times
s2.png
s2.png (31.14 KiB) Viewed 1101 times
s1.png
s1.png (13.62 KiB) Viewed 1101 times
angle_test2.FCStd
(14.11 KiB) Downloaded 29 times
User avatar
onekk
Veteran
Posts: 6202
Joined: Sat Jan 17, 2015 7:48 am
Contact:

Re: Draft is not showing the correct angle dimension

Post by onekk »

From what I know in Sketch you have has no problems as you are working on a 2d plane so no ambiguity here.

Now the rough explanation of weird results.

In 3d you could not get an Angle if you are not specifying a reference axis, probably what you get are differences between normals. I use this to orient shapes using normals of surfaces, but they are normals and should be used incorporating the "object orientation" to obtain a value to correctly pass to a Placement.

Not saying that again relevant code was supplied by @edwilliams16 he and few others are 3d math experts here. :D

Sadly I'm not skilled enough to explain the math and relevant concepts behind.

Regards

Carlo D.
GitHub page: https://github.com/onekk/freecad-doc.
- In deep articles on FreeCAD.
- Learning how to model with scripting.
- Various other stuffs.

Blog: https://okkmkblog.wordpress.com/
User avatar
Roy_043
Veteran
Posts: 8544
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft is not showing the correct angle dimension

Post by Roy_043 »

Confirmed. I'll move this to the Draft forum.

Code: Select all

OS: Windows 8.1 Version 6.3 (Build 9600)
Word size of FreeCAD: 64-bit
Version: 0.21.0.31641 (Git)
Build type: Release
Branch: master
Hash: d28d63b87b60161419c6c0c532fbbfaed96926b8
Python 3.10.8, Qt 5.15.6, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: Dutch/Netherlands (nl_NL)
Installed mods: 
User avatar
Roy_043
Veteran
Posts: 8544
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft is not showing the correct angle dimension

Post by Roy_043 »

The problem is caused by the wrong calculation of the center of the angle. DraftGeomUtils.findIntersection() fails due to tolerance issues. Normal vectors that have an almost zero length because of rounding errors are used.

Code: Select all

import DraftGeomUtils
from FreeCAD import Vector

DraftGeomUtils.findIntersection(Vector(459.0638313293458, 5.684341886080802e-14, -16.121107101440856),
                                Vector(967.0638313293464, 508.0000000000001, 491.87889289855923),
                                Vector(459.0638313293458, 6.927791673660977e-14, -16.121107101440902),
                                Vector(27.052353974566813, 590.1940314391262, 574.0729243376869),
                                True,
                                True)
User avatar
thomas-neemann
Veteran
Posts: 11903
Joined: Wed Jan 22, 2020 6:03 pm
Location: Osnabrück DE 🇩🇪
Contact:

Re: Draft is not showing the correct angle dimension

Post by thomas-neemann »

jfc4120 wrote: Sun Jan 29, 2023 7:41 am ...
it is also wrong here, but with a different value
angle_test2-tn.FCStd
(13.88 KiB) Downloaded 24 times

Code: Select all

OS: Ubuntu 20.04.1 LTS (XFCE/xubuntu)
Word size of FreeCAD: 64-bit
Version: 0.21.0.31709 (Git) AppImage
Build type: Release
Branch: master
Hash: e188802ca6997d2564e7570ab648462e6a059f87
Python 3.10.8, Qt 5.15.6, Coin 4.0.0, Vtk 9.1.0, OCC 7.6.3
Locale: German/Germany (de_DE)
Installed mods: 
  * Curves 0.6.5
Gruß Dipl.-Ing. (FH) Thomas Neemann

https://www.youtube.com/@thomasneemann5 ... ry=freecad
User avatar
Roy_043
Veteran
Posts: 8544
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft is not showing the correct angle dimension

Post by Roy_043 »

Roy_043 wrote: Sun Jan 29, 2023 12:45 pmDraftGeomUtils.findIntersection() fails due to tolerance issues.
It not (just?) a tolerance issue. Even if I move the points so that there is no longer a coincident point there is a problem.

Code: Select all

import DraftGeomUtils
from FreeCAD import Vector


pt1 = Vector(459.0638313293458, 5.684341886080802e-14, -16.121107101440856)
pt2 = Vector(967.0638313293464, 508.0000000000001, 491.87889289855923)
pt3 = Vector(459.0638313293458, 6.927791673660977e-14, -16.121107101440902)
pt4 = Vector(27.052353974566813, 590.1940314391262, 574.0729243376869)

delta12 = pt2 - pt1
delta34 = pt4 - pt3

pta = pt2
ptb = delta12 + pt2
ptc = pt4
ptd = delta34 + pt4

print(DraftGeomUtils.findIntersection(pt1, pt2, pt3, pt4, True, True)) # Wrong intersection.
print(DraftGeomUtils.findIntersection(pta, ptb, ptc, ptd, True, True)) # No intersection found.
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Re: Draft is not showing the correct angle dimension

Post by jfc4120 »

I tried this:

Made a wire on 1-2-3, moved the wire over to the right, and it gives the correct angle. For some reason it doesn't give the correct angle on the sketch line in draft, but in sketcher it does. Attached:
Attachments
s4.png
s4.png (44.75 KiB) Viewed 824 times
angle_test3.FCStd
(15.73 KiB) Downloaded 22 times
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Re: Draft is not showing the correct angle dimension

Post by jfc4120 »

Okay this is weird, I duplicated the same in the previous version and got correct results, attached:

Code: Select all

OS: Windows 10 Version 2009
Word size of FreeCAD: 64-bit
Version: 0.20.1.29410 (Git)
Build type: Release
Branch: releases/FreeCAD-0-20
Hash: f5d13554ecc7a456fb6e970568ae5c74ba727563
Python 3.8.10, Qt 5.15.2, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: English/United States (en_US)
Do I need to install the previous version for now?
Attachments
line_a5.png
line_a5.png (24 KiB) Viewed 792 times
line_angle5.FCStd
(8.92 KiB) Downloaded 21 times
User avatar
Roy_043
Veteran
Posts: 8544
Joined: Thu Dec 27, 2018 12:28 pm

Re: Draft is not showing the correct angle dimension

Post by Roy_043 »

jfc4120 wrote: Sun Jan 29, 2023 7:52 pm I duplicated the same
I would say the files are similar but different. Your 3rd file does not show the problem in V0.20.2 either. Installing the previous version is not called for I think.
jfc4120
Posts: 448
Joined: Sat Jul 02, 2022 11:16 pm

Re: Draft is not showing the correct angle dimension

Post by jfc4120 »

@Roy_043 In the previous version I used the same geometry and made a sketch. However the angles in the previous version was correct in draft mode. The only slight difference is I make the line in the sketch a little longer, otherwise all is the same. I did try again in current version with a longer line, but still get wrong results i draft mode.

The thing is: The angle is correct, but draft mode puts the wrong angle.
Post Reply