Author Topic: Wrong calculation using FIX and 2 points.  (Read 1823 times)

0 Members and 1 Guest are viewing this topic.

dubb

  • Swamp Rat
  • Posts: 1105
Wrong calculation using FIX and 2 points.
« on: February 10, 2017, 12:12:02 PM »
Using this snippet script to calculate the distance. The result is 1 unit less than what I expected :tickedoff:. The unexpected calculated results only occurs on parallel lines that are angled. Horizontal parallel lines seem to calculate as expected. Screenshot included.

Script used to pick points.
Code: [Select]
(setq pt1 (getpoint "\nSelect first point"))
(setq pt2 (getpoint pt1 "\nSelect second point"))


Script used to calculate the distance.
Code: [Select]
(fix (distance pt1 pt2))
Code: [Select]
Select first point
Select second point_per to
Command:
Command: (fix (distance pt1 pt2))
7



ronjonp

  • Needs a day job
  • Posts: 7526
Re: Wrong calculation using FIX and 2 points.
« Reply #1 on: February 10, 2017, 12:22:42 PM »
HERE is a thread with a similar problem.

Maybe try: (fix (+ 1e-8 (distance pt1 pt2)))

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

dubb

  • Swamp Rat
  • Posts: 1105
Re: Wrong calculation using FIX and 2 points.
« Reply #2 on: February 10, 2017, 12:37:01 PM »
Ahhh! Thanks Ron!  :smitten:
I kinda remember that post. I guess I was using the wrong search query. Though its weird we have to use scientific notation to obtain these results.

ronjonp

  • Needs a day job
  • Posts: 7526
Re: Wrong calculation using FIX and 2 points.
« Reply #3 on: February 10, 2017, 12:38:31 PM »
Ahhh! Thanks Ron!  :smitten:
I kinda remember that post. I guess I was using the wrong search query. Though its weird we have to use scientific notation to obtain these results.
Glad to help  :)

Windows 11 x64 - AutoCAD /C3D 2023

Custom Build PC

David Bethel

  • Swamp Rat
  • Posts: 656
Re: Wrong calculation using FIX and 2 points.
« Reply #4 on: February 11, 2017, 07:40:18 AM »
I would suggest using a rounding function in lieu of  ( fix ).  -David
R12 Dos - A2K

mailmaverick

  • Bull Frog
  • Posts: 494
Re: Wrong calculation using FIX and 2 points.
« Reply #5 on: February 14, 2017, 04:32:44 AM »
I would suggest using a rounding function in lieu of  ( fix ).  -David
Something like : http://www.lee-mac.com/round.html