### Author Topic: Coordinate based selection  (Read 1604 times)

0 Members and 1 Guest are viewing this topic.

#### vincent.r

• Newt
• Posts: 101
##### Coordinate based selection
« on: June 26, 2020, 05:23:41 AM »
Hi,

I trying to select a line based on given coordinates. Took help from Lee's website and modified code as -

(ssget '((0 . "LINE") (-4 . "=,=,=") (11 13.0767 17.0213 0.0)))

but not able get to select line. Don't know where am I mistaking. Drawing attached.

Tried this also -

(setq pt1 (list 13.0767 17.0213 0.0))
(SETQ A (ssget pt1 '((0 . "LINE") )))

Any help will be highly appreciable.

Thanks
« Last Edit: June 26, 2020, 06:08:36 AM by vincent.r »

#### ribarm

• Gator
• Posts: 3245
• Marko Ribar, architect
##### Re: Coordinate based selection
« Reply #1 on: June 26, 2020, 07:25:17 AM »
Coordinates of each point in ACAD are stored as real numbers with precision up to 15 decimal places... So to get LINE, you must specify exact coordinates with all decimals and I suggest that you use this variant :

Code: [Select]
`(ssget "_C" pt pt '((0 . "LINE")))`
Note you can get pt with exact coordinates by : (setq pt (cdr (assoc 11 (entget (car (entsel "\nPick LINE..."))))))

Now to check precision : (prompt "\nPOINT : ") (princ (rtos (car pt) 2 20)) (prompt ",") (princ (rtos (cadr pt) 2 20)) (prompt ",") (princ (rtos (caddr pt) 2 20))
If you have(get) those data with precision up to 15 decimal places, you can try :

Code: [Select]
`(ssget (list '(0 . "LINE") '(-4 . "=,=,=") '(11 Xcoord Ycoord Zcoord)))`
Marko Ribar, d.i.a. (graduated engineer of architecture)

#### vincent.r

• Newt
• Posts: 101
##### Re: Coordinate based selection
« Reply #2 on: June 26, 2020, 07:46:35 AM »
Coordinates of each point in ACAD are stored as real numbers with precision up to 15 decimal places... So to get LINE, you must specify exact coordinates with all decimals and I suggest that you use this variant :

Code: [Select]
`(ssget "_C" pt pt '((0 . "LINE")))`
Note you can get pt with exact coordinates by : (setq pt (cdr (assoc 11 (entget (car (entsel "\nPick LINE..."))))))

Now to check precision : (prompt "\nPOINT : ") (princ (rtos (car pt) 2 20)) (prompt ",") (princ (rtos (cadr pt) 2 20)) (prompt ",") (princ (rtos (caddr pt) 2 20))
If you have(get) those data with precision up to 15 decimal places, you can try :

Code: [Select]
`(ssget (list '(0 . "LINE") '(-4 . "=,=,=") '(11 Xcoord Ycoord Zcoord)))`

It works ribarm! I was not aware of precision system.

Thank you very much. You made my day.

Cheers.

#### Lee Mac

• Seagull
• Posts: 12910
• London, England
##### Re: Coordinate based selection
« Reply #3 on: June 26, 2020, 01:13:10 PM »
An easier way to perform the selection, without needing to specify the coordinate values to the exact limit of double-floating-point precision is to use some tolerance around the values, e.g.:
Code - Auto/Visual Lisp: [Select]
1. (setq p '(13.0767 17.0213 0.0) ;; Approximate point
2.       f  1e-4 ;; Tolerance
3. )
4.     (list
5.        '(0 . "LINE")
6.        '(-4 . ">=,>=,>=")
7.         (cons 11 (mapcar '- p (list f f f)))
8.        '(-4 . "<=,<=,<=")
9.         (cons 11 (mapcar '+ p (list f f f)))
10.     )
11. )

#### vincent.r

• Newt
• Posts: 101
##### Re: Coordinate based selection
« Reply #4 on: July 14, 2020, 03:08:17 AM »
Thanks Lee !