TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: dubb on February 10, 2017, 12:12:02 PM

Title: Wrong calculation using FIX and 2 points.
Post by: dubb 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


Title: Re: Wrong calculation using FIX and 2 points.
Post by: ronjonp on February 10, 2017, 12:22:42 PM
HERE (https://www.theswamp.org/index.php?topic=52552.msg574643#msg574643) is a thread with a similar problem.

Maybe try: (fix (+ 1e-8 (distance pt1 pt2)))
Title: Re: Wrong calculation using FIX and 2 points.
Post by: dubb 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.
Title: Re: Wrong calculation using FIX and 2 points.
Post by: ronjonp 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  :)
Title: Re: Wrong calculation using FIX and 2 points.
Post by: David Bethel on February 11, 2017, 07:40:18 AM
I would suggest using a rounding function in lieu of  ( fix ).  -David
Title: Re: Wrong calculation using FIX and 2 points.
Post by: mailmaverick 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 (http://www.lee-mac.com/round.html)