Author Topic: Is AutoCAD LYING to me about start/end points?  (Read 7078 times)

0 Members and 1 Guest are viewing this topic.

ArgV

  • Guest
Is AutoCAD LYING to me about start/end points?
« on: September 14, 2009, 08:43:24 PM »
So, it seems that if I draw a line exactly along the X axis at Z 0.0 and get the properties via active X, I get a normal response of, say:

  ;   StartPoint = (0.0 0.0 0.0)
;   EndPoint = (100.0 0.0 0.0)

Ok, so now I explode a solid, and it's regions down to lines. Make sure to align them to the X axis at Z 0.0, and I get:

;   StartPoint = (0.0 0.0 0.0)
;   EndPoint = (61.6189 7.10543e-015 1.36592e-016)

? WTF ?

Then I just do a measurement of the same line:

Distance = 61.6189,  Angle in XY Plane = 0,  Angle from XY Plane = 0
Delta X = 61.6189,  Delta Y = 0.0000,   Delta Z = 0.0000

Here is an entget dump (of the same line):

Select object: ((-1 . <Entity name: 7efc3648>) (0 . "LINE") (330 . <Entity
name: 7efc1cf8>) (5 . "1B1") (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 .
"0") (100 . "AcDbLine") (10 0.0 0.0 0.0) (11 61.6189 7.10543e-015 1.36592e-016)
(210 0.0 0.0 1.0))

?? Is it just skewed a very,very,very miniscule amount?

Confused in Washington,

-ArgV

« Last Edit: September 14, 2009, 10:45:26 PM by ArgV »

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Is AutoCAD LYING to me about start/end points?
« Reply #1 on: September 14, 2009, 09:52:07 PM »

;   StartPoint = (0.0 0.0 0.0)
;   EndPoint = (100.0 0.0 0.0)

Ok, so now I explode a solid, and it's regions down to lines. Make sure to align them to the X axis at Z 0.0, and I get:

;   StartPoint = (0.0 0.0 0.0)
;   EndPoint = (61.6189 7.10543e-015 1.36592e-016)

 (11 61.6189 7.10543e-015 1.36592e-016)
-ArgV

Do you know how far the difference is ?

and do you know about rounding of doubles ??



ps: No, AutoCAD is NOT lying to you.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

ArgV

  • Guest
Re: Is AutoCAD LYING to me about start/end points?
« Reply #2 on: September 14, 2009, 10:43:33 PM »

;   StartPoint = (0.0 0.0 0.0)
;   EndPoint = (100.0 0.0 0.0)

Ok, so now I explode a solid, and it's regions down to lines. Make sure to align them to the X axis at Z 0.0, and I get:

;   StartPoint = (0.0 0.0 0.0)
;   EndPoint = (61.6189 7.10543e-015 1.36592e-016)

 (11 61.6189 7.10543e-015 1.36592e-016)
-ArgV

Do you know how far the difference is ?

and do you know about rounding of doubles ??



ps: No, AutoCAD is NOT lying to you.


The difference can't be much. If I replace the wierd numbers in the database with 0's, I can't even see them move, so it must be some astronomically small number
even though it looks like it's 7 inches and something. I know that rounding occurs with doubles, yes. What I don't get is why a part that is supposedly flat and aligned with the WCS comes out NOT strait?

So, I guess what I need to know is, how do I determine if the number is just a very minute and insignificant number, or if it's enough to notice? I know the "e" is a symbol that represents decimal places, but the number I got looks like, well it says: 7.10543e-015. How do I know that isn't 7.105.... inches? I know for a fact that the value is very close to 0 (zero).

Should I just test the number by saying (if (equal y 0 0.001) (yadda yadda)) or ??

Thanks.

-ArgV


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Is AutoCAD LYING to me about start/end points?
« Reply #3 on: September 14, 2009, 11:59:49 PM »

This may help
Code: [Select]
;;;---------------------------------------------------------------------------
;;;

(setq bigNumber 7.10543e-015
      zero 0.0
      )
(= zero bigNumber) ;-> nil
(>  bigNumber zero) - -> T

(setq fuzzfactor 0.00000000000001)
(equal zero bigNumber fuzzfactor) ;-> T

(setq fuzzfactor 1e-14)
(equal zero bigNumber fuzzfactor) ;-> T

(setq fuzzfactor 1e-15)
(equal zero bigNumber fuzzfactor) ;-> nil
;;;---------------------------------------------------------------------------
;;;

/// kdub
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Is AutoCAD LYING to me about start/end points?
« Reply #4 on: September 15, 2009, 03:26:15 AM »
So, I guess what I need to know is, how do I determine if the number is just a very minute and insignificant number, or if it's enough to notice? I know the "e" is a symbol that represents decimal places, but the number I got looks like, well it says: 7.10543e-015. How do I know that isn't 7.105.... inches? I know for a fact that the value is very close to 0 (zero).

Should I just test the number by saying (if (equal y 0 0.001) (yadda yadda)) or ??

Thanks.

-ArgV

The number after the "e" is how many multiples of ten bigger than 1 the number before the "e" is.  In your case it's -15, so 15 multiples of ten smaller than 1: 0.00000000000001 x 7.10543, which I suspect will be an acceptable tolerance, and far smaller than any of the accuract factors you can set your units to (hence it returning "0" in the properties box)

===
dJE

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Is AutoCAD LYING to me about start/end points?
« Reply #5 on: September 15, 2009, 03:27:45 AM »
Since you're dealing with exploded solids, I would guess that solids have to have a nominal thickness to exist, and that's where the discrepancy comes from.

dJE
===
dJE

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Is AutoCAD LYING to me about start/end points?
« Reply #6 on: September 15, 2009, 07:23:38 AM »
To explain to you about the use of "e":

10e2  =  10 x 102 = 1000

10e-2 = 10 x 10-2 = 0.1

This is a nice animation to look at:

http://micro.magnet.fsu.edu/primer/java/scienceopticsu/powersof10/

Or on powers of 10:

http://microcosm.web.cern.ch/microcosm/P10/english/P0.html

ArgV

  • Guest
Re: Is AutoCAD LYING to me about start/end points?
« Reply #7 on: September 15, 2009, 09:35:46 PM »
To explain to you about the use of "e":

10e2  =  10 x 102 = 1000

10e-2 = 10 x 10-2 = 0.1

This is a nice animation to look at:

http://micro.magnet.fsu.edu/primer/java/scienceopticsu/powersof10/

Or on powers of 10:

http://microcosm.web.cern.ch/microcosm/P10/english/P0.html

Sweet! According to the first link, my number is that of neutrons and quarks or something. Hmm.. I guess thats close enough. ;)

But what I don't understand is why it has a 7.10543e-015 which leads me to believe it would be 7.10543...... yadda yadda like some very irrational number.

If I see a decimal like that, AND an "e" do I just assume that it's some value that is very close to zero? :)

thanks!

-ArgV

-Not very smart, but that keeps me out of trouble. ;)

ArgV

  • Guest
Re: Is AutoCAD LYING to me about start/end points?
« Reply #8 on: September 15, 2009, 09:39:23 PM »
So, I guess what I need to know is, how do I determine if the number is just a very minute and insignificant number, or if it's enough to notice? I know the "e" is a symbol that represents decimal places, but the number I got looks like, well it says: 7.10543e-015. How do I know that isn't 7.105.... inches? I know for a fact that the value is very close to 0 (zero).

Should I just test the number by saying (if (equal y 0 0.001) (yadda yadda)) or ??

Thanks.

-ArgV


The number after the "e" is how many multiples of ten bigger than 1 the number before the "e" is.  In your case it's -15, so 15 multiples of ten smaller than 1: 0.00000000000001 x 7.10543, which I suspect will be an acceptable tolerance, and far smaller than any of the accuract factors you can set your units to (hence it returning "0" in the properties box)



Ok. So it's not lying, in fact it's being a little too truthful. ;)

thanks!

ArgV

  • Guest
Re: Is AutoCAD LYING to me about start/end points?
« Reply #9 on: September 15, 2009, 09:48:35 PM »

This may help
Code: [Select]
;;;---------------------------------------------------------------------------
;;;

(setq bigNumber 7.10543e-015
      zero 0.0
      )
(= zero bigNumber) ;-> nil
(>  bigNumber zero) - -> T

(setq fuzzfactor 0.00000000000001)
(equal zero bigNumber fuzzfactor) ;-> T

(setq fuzzfactor 1e-14)
(equal zero bigNumber fuzzfactor) ;-> T

(setq fuzzfactor 1e-15)
(equal zero bigNumber fuzzfactor) ;-> nil
;;;---------------------------------------------------------------------------
;;;

/// kdub

OIC! Very nice. Why would autocad divulge information that is outside of it's own tolerance limits? I suppose when I start modeling neutrons and at least DNA, that might come in handy.... Sheesh.

Well, now I gotta see what happens if I change ALL those numbers to zero. Does it make a difference? I mean, I don't think it'll screw it up, but I gotta make sure.

If anyone wants to see the code I have so far, perhaps give some critiquing, it's here:

This works for what I need at work, but I'd eventually like to make it work for a variety of things. It doesn't look like anyone here needs this though. ;)

Code: [Select]
;;******************************************************************************************
;; "Acis" by ArgV (WIP as usual)                                                           
;; Create a selection set around a solid object that is facing the Z direction. Program will
;; break down the solid and separate objects by layer. Anything facing the Z direction will
;; be on the "GOOD" layer, anything else will be on the "BAD" layer.                       
;;******************************************************************************************


(defun c:acis (/ *DOC *error* ss pt1 pt2 bigSolid centerList ssEnt subEntList temp cntr ssItem object volume object)
 
(vl-load-com)
(vla-startundomark (setq *DOC (vla-get-activedocument (vlax-get-acad-object))))

(defun *error* (msg)
  (princ msg)
  (setvar "qaflags" 0)
  (vla-endundomark *DOC)
  )

(command "ucs" "w")

;;------------------------------------------------------------
;; Make selection set                                         
;;------------------------------------------------------------
(setq ss (ssget "w"
           (setq pt1 (getpoint "\nPick first point"))
           (setq pt2 (getcorner "\nPick second point:" pt1))
           (list (cons 0 "3DSOLID")))
      )

;;------------------------------------------
;; If the selection set was successful,     
;; run these sub-routines..                 
;;------------------------------------------
 
(if ss
 
  (progn
    (addLayers)
    (setq largestSolid (move_edges ss))
    (processLargeSolid largestSolid)
    (blockBadStuff)
    )
 
  )

(vla-endundomark *DOC)

)

;;-----------------------------------------------------------------------------------------
;; This part takes the selection set of solids from the beginning, finds the LARGEST solid
;; moves anything that is smaller than the largest solid 200 units away in the Y direction
;;-----------------------------------------------------------------------------------------

(defun move_edges (ss / NN ssEnt subEntList object temp volume bigSolid cntr ssItem)

(setq cntr 0
      bigSolid 0)

;;--------------------------------------------------------
;; Find largest solid..                                   
;;--------------------------------------------------------
 
(while
  (< cntr (sslength ss))
  (setq ssItem (ssname ss cntr)
cntr (1+ cntr)
object (vlax-ename->vla-object ssItem)
        )
  (if
    (> (setq volume (vla-get-volume object)) bigSolid)
    (setq bigSolid volume)
    )
  )

;;--------------------------------------------------------
;; Now, with the largest solid, we move on to bigger and 
;; better things..                                       
;;--------------------------------------------------------
(setq cntr 0)

  (while
    (< cntr (sslength ss))

    (setq ssEnt (ssname ss cntr)
  subEntList (entget ssEnt)
          cntr (1+ cntr))
   
    (if
      (= (cdr (assoc 0 subEntList)) "3DSOLID")
      (progn

        (setq object (vlax-ename->vla-object ssEnt))
       
        ;;----------------------------------------------------------------------------------------------------------
        ;; if the layer has "EDGE" in it, or it's smaller than the largest solid in the selection set, move it up..
        ;;----------------------------------------------------------------------------------------------------------
       
(cond
  ((or
     (wcmatch (vla-get-layer object) "*EDGE*")
     (< (vla-get-volume object) bigSolid))(vla-move object (vlax-3d-point (list 0. 0. 0.)) (vlax-3d-point (list 0. 100. 0.))))
  ((= (vla-get-volume object) bigSolid)(setq temp object))
  )
)
      )
    )
  temp
)

;;-------------------------------------------------------------------
;; This routine takes the large solid from ealier and explodes it.. 
;; Then picks up the resulting regions and explodes them,           
;; leaving surfaces in tact for reference..                         
;;-------------------------------------------------------------------

(defun processLargeSolid (largestSolid / largestSolid ss)
 
;;---------------------------------------------------
;; Explode the large solid into regions and surfaces
;;---------------------------------------------------
 
(setvar "qaflags" 1)
(vl-cmdf "explode" (vlax-vla-object->ename largestSolid) "")
 
;;-----------------------------------------------------------------
;; Explode it again to convert regions to lines/arcs/circles/etc..
;;-----------------------------------------------------------------
 
(if
  (setq ss (ssget "w" pt1 pt2 (list (cons 0 "REGION"))))

  (progn

    (vl-cmdf "explode" ss "")
    (setvar "qaflags" 0)
    (setq ss (ssget "w" pt1 pt2))
    (if ss
      (sortObjects ss)
      )
    )
  )
)
   
;;---------------------------------------------------------------------------------------
;; Depending on object type and it's Z normal value, put it on either good or bad layer.
;;---------------------------------------------------------------------------------------

(defun sortObjects (ss / i)
(setq i 0)
 
(while
  (< i (sslength ss))

  (setq object (vlax-ename->vla-object (ssname ss i))
        i (1+ i))

(cond

  ;If the "Object" is a surface...
  ((or
     (= (vla-get-objectName object) "AcDbSurface")
     (= (vla-get-objectName object) "AcDbBody")
     )

   (vla-put-layer object "BAD")
   )
     
     
      ((and (= (vla-get-objectname object) "AcDbLine")
            (= (caddr (vlax-safearray->list (vlax-variant-value (vla-get-normal object)))) 1.0)) (vla-put-layer object "GOOD"))
 
       
      ((and (= (vla-get-objectname object) "AcDbLine")
            (/= (caddr (vlax-safearray->list (vlax-variant-value (vla-get-normal object)))) 1.0)) (vla-put-layer object "BAD"))
             
     
      ((and (= (vla-get-objectname object) "AcDbArc")
            (= (caddr (vlax-safearray->list (vlax-variant-value (vla-get-normal object)))) 1.0))
       (progn (vla-put-layer object "GOOD")
         (setq centerList (cons (arcs->circle object centerList) centerList))))
     
      ((and (= (vla-get-objectname object) "AcDbArc")
            (/= (caddr (vlax-safearray->list (vlax-variant-value (vla-get-normal object)))) 1.0)) (vla-put-layer object "BAD"))
  )
  )
  )
 
;;----------------------------------------------------------------------------------------
;; This goes through the arcs and replaces two arcs with one circle.                     
;;----------------------------------------------------------------------------------------

(defun arcs->circle (object centerList / arcSS center rad cntr newCircle objectList item)
 
(setq center (vla-get-center object))

  (if
    (not
      (member
        (vlax-safearray->list (vlax-variant-value (vla-get-center object))) centerList))
    (progn
      (setq newCircle (vla-addcircle (vla-get-modelspace *DOC) center (setq rad (vla-get-radius object))))

      (if
        (< rad 0.01)
        (vla-put-radius newCircle 0.5))
      )
    )
 

;;--------------------------------------------------------------------------------------------------
;;If there is one of those stupid little corner radiuses, make a bigger circle to make it obvious. 
;;--------------------------------------------------------------------------------------------------

 (vla-erase object)
 (setq alist (vlax-safearray->list (vlax-variant-value center))  )
  )

;;----------------------------------------------------------------------------------------------------------------
;;******blockBadStuff*********************************************************************************************
;;----------------------------------------------------------------------------------------------------------------

(defun blockBadStuff (/ ss)
  (command "-block" "BADSTUFF" (list 0. 0. 0.) (setq ss (ssget "x" (list (cons 8 "BAD")(cons 410 "MODEL")))) "")
  (command "-insert" "BADSTUFF" (list 0. 0. 0.) "" "" "")
  )

;;----------------------------------------------------------------------------------------------------------------
;;******addLayers*************************************************************************************************
;;----------------------------------------------------------------------------------------------------------------

(defun addLayers ()
  (if
    (not
      (tblsearch "layer" "BAD"))
    (vla-put-color (vla-add (vla-get-layers *DOC) "BAD") 80)
    )

  (if
    (not
      (tblsearch "layer" "GOOD"))
    (vla-put-color (vla-add (vla-get-layers *DOC) "GOOD") 10)
    )
  )

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Is AutoCAD LYING to me about start/end points?
« Reply #10 on: September 15, 2009, 10:25:39 PM »

rushed .. lunchtime ..

see if this gives you some ideas

Code: [Select]
(setq testpoint1 (list 0 3e-12 0)
      TestPoint2 (list 0 0.5 0)
)

(Setq Point1TestedForZezo (mapcar (function(lambda(x)  (if (equal x 0 1e-8) 0 x))) TestPoint1) )
(Setq Point2TestedForZezo (mapcar (function(lambda(x)  (if (equal x 0 1e-8) 0 x))) TestPoint2) )

/// kdub
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

uncoolperson

  • Guest
Re: Is AutoCAD LYING to me about start/end points?
« Reply #11 on: September 15, 2009, 10:26:02 PM »
http://www.youtube.com/watch?v=A2cmlhfdxuY

saw that in high school, thought it was freakin rad

Daniel J. Ellis

  • Swamp Rat
  • Posts: 811
Re: Is AutoCAD LYING to me about start/end points?
« Reply #12 on: September 16, 2009, 03:23:42 AM »

If I see a decimal like that, AND an "e" do I just assume that it's some value that is very close to zero? :)


If the number after the "e" is above 0, then the number is very big, is the number after the "e" is below 0,then the actual number is very small (tendingtowards zero)

===
dJE

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Is AutoCAD LYING to me about start/end points?
« Reply #13 on: September 16, 2009, 05:47:06 AM »
See this GCSE site, its Standard Form you want to learn  :-)

http://www.mathsrevision.net/gcse/pages.php?page=43

ArgV

  • Guest
Re: Is AutoCAD LYING to me about start/end points?
« Reply #14 on: September 16, 2009, 08:29:41 PM »

rushed .. lunchtime ..

see if this gives you some ideas

Code: [Select]
(setq testpoint1 (list 0 3e-12 0)
      TestPoint2 (list 0 0.5 0)
)

(Setq Point1TestedForZezo (mapcar (function(lambda(x)  (if (equal x 0 1e-8) 0 x))) TestPoint1) )
(Setq Point2TestedForZezo (mapcar (function(lambda(x)  (if (equal x 0 1e-8) 0 x))) TestPoint2) )

/// kdub

Ok, I'll have to get back to that. mY brain is fried from work. I don't even want to think about thinking. :) Thank you for you help!

ArgV

  • Guest
Re: Is AutoCAD LYING to me about start/end points?
« Reply #15 on: September 16, 2009, 08:38:06 PM »

If I see a decimal like that, AND an "e" do I just assume that it's some value that is very close to zero? :)


If the number after the "e" is above 0, then the number is very big, is the number after the "e" is below 0,then the actual number is very small (tendingtowards zero)



Perfect. Thats what I was basically wondering.. is this number HUGE or small? OK, so this number is very small. cool.


ArgV

  • Guest
Re: Is AutoCAD LYING to me about start/end points?
« Reply #16 on: September 16, 2009, 08:39:42 PM »
See this GCSE site, its Standard Form you want to learn  :-)

http://www.mathsrevision.net/gcse/pages.php?page=43

Cool. I only browsed through it cause my head hurts. I didn't see anything with the "e" exponent anywhere, but it looks like a good site to have on my favorites for some other stuff. thank you!


Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: Is AutoCAD LYING to me about start/end points?
« Reply #17 on: September 16, 2009, 09:36:54 PM »

rushed .. lunchtime ..

see if this gives you some ideas

Code: [Select]
(setq testpoint1 (list 0 3e-12 0)
      TestPoint2 (list 0 0.5 0)
)

(Setq Point1TestedForZezo (mapcar (function(lambda(x)  (if (equal x 0 1e-8) 0 x))) TestPoint1) )
(Setq Point2TestedForZezo (mapcar (function(lambda(x)  (if (equal x 0 1e-8) 0 x))) TestPoint2) )

/// kdub

Ok, I'll have to get back to that. mY brain is fried from work. I don't even want to think about thinking. :) Thank you for you help!


Sure, but based on your question :
Quote
Well, now I gotta see what happens if I change ALL those numbers to zero. Does it make a difference? I mean, I don't think it'll screw it up, but I gotta make sure.
.. you may find your answer in the grocking of that code.

kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Lee Mac

  • Seagull
  • Posts: 12915
  • London, England
Re: Is AutoCAD LYING to me about start/end points?
« Reply #18 on: September 17, 2009, 05:38:28 AM »
See this GCSE site, its Standard Form you want to learn  :-)

http://www.mathsrevision.net/gcse/pages.php?page=43

Cool. I only browsed through it cause my head hurts. I didn't see anything with the "e" exponent anywhere, but it looks like a good site to have on my favorites for some other stuff. thank you!



The e is standard notation to replace the "x 10y"

See here:

http://www.gcse.com/maths/writing_standard_form.htm
« Last Edit: September 17, 2009, 06:02:18 AM by Lee Mac »