# Thread: Find exact insertion point

1. ## Find exact insertion point

Registered forum members do not see this ad.

Hi!

Does anyone know how to find the exact insertion point of a block with autolisp?
And with "exact" I mean with all decimals.

If a block is inserted with snap and then moved 0.0000001 to the left. Is it then possible to find that block with autolisp?

/ Thomas

2. contrary to what other people think, when you retrieve the insertion point of a block , it WILL give you the exact coordinate. You may not "see" it, but i tell you now. IT IS.

Try inserting a block at 0,0 coordinates. and move that block 0.0000001 then use
Code:
` (Cdr (assoc 10 (entget (Car (entsel)))))`
You will get something like (1.0e-007 0.0 0.0)

3. The code below will allow you to see the available number of decimals:
Code:
```(if (setq itemBlock (ssget ":S" '((0 . "INSERT"))))
(progn
(setq pointIns (cdr (assoc 10 (entget (ssname itemBlock 0)))))
(prompt (strcat "\Insertion point:"
"\n   X = " (rtos (car   pointIns) 2 18)
"\n   Y = " (rtos (cadr  pointIns) 2 18)
"\n   Z = " (rtos (caddr pointIns) 2 18)))
)
)```

4. @pBe: While the example shows correctly, I think it might be unclear about rounding off errors. If the insertion point is somewhere away from 0,0,0 and also ever so slightly off a full number (integer) then you might find that the display of the insertion point omits the decimals (this is due to the LUPREC setting).

@ripuz: Even if you set the precision as high as possible, it might still not display all the decimals. The returned value (as pBe's shown) is still the "exact" point though, it might just be difficult to display to absolute accuracy. All calculations on such point uses the double precision floating point value returned with entget, not the value you see on the command line in the list command. It's not "perfect" accuracy, but it's as good as it gets, since acad itself only uses double precision floating points internally. There are some small errors (called floating point errors), which might crop up - but they're generally to 16 decimal digits or less. http://en.wikipedia.org/wiki/Floating_point

5. Originally Posted by pBe
contrary to what other people think, when you retrieve the insertion point of a block , it WILL give you the exact coordinate. You may not "see" it, but i tell you now. IT IS.

Try inserting a block at 0,0 coordinates. and move that block 0.0000001 then use
Code:
` (Cdr (assoc 10 (entget (Car (entsel)))))`
You will get something like (1.0e-007 0.0 0.0)
Okey, I see... I did as you said and i got the same answer as you but only when x are close to zero.
If the block is located at 99.999999, 100 the answer will be (100.0 100.0 0.0).

I got your point though... That the coordinates is the right coordinates, it´s just not displayed exactly.
And to show it:
Code:
`(rtos (Cadr (assoc 10 (entget (Car (entsel))))) 2 8)`
Thanks for you quick reply pBe!

6. Originally Posted by irneb
@pBe: While the example shows correctly, I think it might be unclear about rounding off errors. If the insertion point is somewhere away from 0,0,0 and also ever so slightly off a full number (integer) then you might find that the display of the insertion point omits the decimals (this is due to the LUPREC setting).

@ripuz: Even if you set the precision as high as possible, it might still not display all the decimals. The returned value (as pBe's shown) is still the "exact" point though, it might just be difficult to display to absolute accuracy. All calculations on such point uses the double precision floating point value returned with entget, not the value you see on the command line in the list command. It's not "perfect" accuracy, but it's as good as it gets, since acad itself only uses double precision floating points internally. There are some small errors (called floating point errors), which might crop up - but they're generally to 16 decimal digits or less. http://en.wikipedia.org/wiki/Floating_point
Thanks irneb, now I´ll understand.

7. Also keep in mind that the precision is inverse proportional with the "size" of the number:
Code:
```(rtos 12.345678901234567 2 18)
;Return> "12.34567890123457"

(rtos 1234567.8901234567 2 18)
;Return> "1234567.890123457"

(rtos 12345678901234.567 2 18)
;Return> "12345678901234.57"```

8. Yes, the ~16 digits means 16 in total. Not 16 after the decimal point. So as Mircea's shown the rounding / floating point error becomes worse the further you are away from 0,0,0. For this reason I prefer drawing as close as possible to 0,0,0 and using UCS's for stuff like coordinate references.

9. Registered forum members do not see this ad.

Originally Posted by ripuz
I got your point though... That the coordinates is the right coordinates, it´s just not displayed exactly.
Thanks for you quick reply pBe!
Good for you

@Msasu/Irné
All bases covered

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts