Creating a selection set from 3 decimal place coordinates?

Creating a selection set from 3 decimal place coordinates?

camedge
Explorer Explorer
574 Views
3 Replies
Message 1 of 4

Creating a selection set from 3 decimal place coordinates?

camedge
Explorer
Explorer

I'm taking a set of coordinates from a .csv and then trying to create a selection set of lines that end at those coordinates.

 

Assuming these are the coordinates-

(setq x "321535.509" y "5807325.787" z "0.000")

 

Creating a selection set like this-
(setq coord (list (atof x) (atof y) (atof z)))
(setq 10ss (ssget "x" (list '(0 . "LINE") '(-4 . "=,=,*") (cons 11 coord) )))

 

I believe the problem I'm having is that, as I've read elsewhere "that the real precision (accuracy) of real numbers in AutoLISP is 16 digits". Therefore the coordinates that I have are only to 3 decimal places whereas in cad the lines (if I turn up the precision I can see) go to that much more detailed precision therefore my selection set is coming up with nil.

 

Does anyone have any suggestions of how I might be able to create that selection set with my 3 decimal place coordinates? 

 

 

 

 

 

0 Likes
Accepted solutions (1)
575 Views
3 Replies
Replies (3)
Message 2 of 4

hmsilva
Mentor
Mentor
Accepted solution

Hello camedge and welcome to the Autodesk Community!

 

_$ (setq x "321535.509" y "5807325.787" z "0.000")
"0.000"
_$ (setq coord (list (atof x) (atof y) (atof z)))
(321536.0 5.80733e+006 0.0)
_$ (setq 10ss (ssget "x" (list '(0 . "LINE") '(-4 . "=,=,*") (cons 11 coord) )))
<Selection set: 2a5c>
_$ (mapcar 'rtos coord)
("321535.509" "5807325.787" "0.000")
_$

 

AutoCAD displays the REAL numbers rounded, but the real value is unchanged.

Probably while creating the .csv file, the REAL numbers were rounded...

Try something like this:

 

(setq x "321535.509" y "5807325.787" z "0.000")
(setq coord (list (atof x) (atof y) (atof z))
      fuzz  0.001
)
(setq 10ss (ssget "_X"
                  (list (cons 0 "LINE")
                        (cons -4 "<and")
                        (cons -4 ">,>,*")
                        (cons 11 (list (- (car coord) fuzz) (- (cadr coord) fuzz) (caddr coord)))
                        (cons -4 "<,<,*")
                        (cons 11 (list (+ (car coord) fuzz) (+ (cadr coord) fuzz) (caddr coord)))
                        (cons -4 "and>")
                  )
           )
)

 

 

Hope this helps,
Henrique

EESignature

Message 3 of 4

camedge
Explorer
Explorer

Thanks Henrique, 

 

I can see how that would work. I'll give it a try tomorrow. (Although I'll also try to get better output from the surveyors, but they don't seem the most flexible bunch!)

 

Cheers 

Cameron

0 Likes
Message 4 of 4

hmsilva
Mentor
Mentor

You're welcome, Cameron!
Glad I could help

Henrique

EESignature

0 Likes