entget coordinates extraction has no precision - all end ".0"

entget coordinates extraction has no precision - all end ".0"

robert.webster247M7
Contributor Contributor
863 Views
16 Replies
Message 1 of 17

entget coordinates extraction has no precision - all end ".0"

robert.webster247M7
Contributor
Contributor

Hello. i am using Autocad 2023 and am trying to write a routine that extracts X,Y & Z coordinates from a 3D polyline.

The x & y coordinates have no precision, the z is to 3 dp (for level purposes, this is acceptable). eg (10 260974.0 824336.0 255.344). 

I changed the units from mm to m and tried again without avail.

 

Has anyone else have this cause issues?

thanks

0 Likes
Accepted solutions (1)
864 Views
16 Replies
Replies (16)
Message 2 of 17

pbejse
Mentor
Mentor

What method did you use to extract the coordinates? I cannnot seem to replicate that result on AutoCAD 2023

 

0 Likes
Message 3 of 17

Moshe-A
Mentor
Mentor

@robert.webster247M7  hi,

 

Sounds like you are using convert format function [like (rtos)] check the XYZ value before the convertion

 

Moshe

 

Message 4 of 17

robert.webster247M7
Contributor
Contributor
Hi. Thanks for the reply.
I found some code online
"(setq obj (vlax-ename->vla-object (car (entsel "\nSelect a Polyline: "))))
(setq poly1 (vlax-get obj 'Coordinates))"
I have also checked manually at command prompt with the entget etc commands

0 Likes
Message 5 of 17

robert.webster247M7
Contributor
Contributor
Hi. Thanks for your reply.
I borrowed some code that I found on line
" (setq obj (vlax-ename->vla-object (car (entsel "\nSelect a Polyline: "))))
(setq poly1 (vlax-get obj 'Coordinates))"

But I have also checked manually at the command prompt using entget etc.
0 Likes
Message 6 of 17

pbejse
Mentor
Mentor

Maybe your coordinate is like this --> X is at 11.030 Y at 13.024 Z as 25.366 

with Luprec 1 it will show the same as you have 11.0 13.0 25.366

Try changing LUPREC variable to a higher number, say 3 then you will get to  "see" the other values

(10 11.03 13.024 25.366)

 

HTH

 

 

 

 

0 Likes
Message 7 of 17

robert.webster247M7
Contributor
Contributor
Hello. I've tried Luprec, which was initially 4, on 3, 8 (max) and 0 (min). it made no difference. I believe the problem lies in the no of digits it outputs. I scaled the plline by 1000 and achieved 3dp for x, y & z.
0 Likes
Message 8 of 17

Moshe-A
Mentor
Mentor

@robert.webster247M7 ,

 


@robert.webster247M7 wrote:
Hi. Thanks for your reply.
I borrowed some code that I found on line
" (setq obj (vlax-ename->vla-object (car (entsel "\nSelect a Polyline: "))))
(setq poly1 (vlax-get obj 'Coordinates))"

But I have also checked manually at the command prompt using entget etc.

create a new free polyline with snap off and report what is the result.

 

 

0 Likes
Message 9 of 17

pbejse
Mentor
Mentor

@robert.webster247M7 wrote:
Hello. I've tried Luprec, which was initially 4, on 3, 8 (max) and 0 (min). it made no difference. I believe the problem lies in the no of digits it outputs. I scaled the plline by 1000 and achieved 3dp for x, y & z.

I like to get my hands on that drawing, are you saying the same drawing when opened on a lower version doent have that issue? perhaps a "Reset Settings to Default" is in order.

 

Anyway, let us know hot it goes

 

0 Likes
Message 10 of 17

ВeekeeCZ
Consultant
Consultant

@robert.webster247M7 wrote:

Hello. i am using Autocad 2023 and am trying to write a routine that extracts X,Y & Z coordinates from a 3D polyline.

The x & y coordinates have no precision, the z is to 3 dp (for level purposes, this is acceptable). eg (10 260974.0 824336.0 255.344). 

I changed the units from mm to m and tried again without avail.

 

Has anyone else have this cause issues?

thanks


 

I too have the same. (10 -650057.0 -1.15296e+06 0.0). 

 

That's no issue. It is always like that, it shows just 6 digits. It's just a visual thing... the real precision is always 16 digits. Just convert it into a string and you'll see more. Use eg. this: (rtos (cadr (assoc 10 (entget (car (entsel))))) 2 12)

 

0 Likes
Message 11 of 17

robert.webster247M7
Contributor
Contributor

Attached is the 3dpolyline in dwg. it is showing the first vertice to 4dp in properties.

The start portion of the output at the bottom shows the output from the lisp

robertwebster247M7_0-1675859138858.png

robertwebster247M7_1-1675859298592.png

 

0 Likes
Message 12 of 17

ВeekeeCZ
Consultant
Consultant
Accepted solution

Here is your new line to use.

(mapcar '(lambda (x) (rtos x 2 12)) (vlax-get (vlax-ename->vla-object (car (entsel "\nSelect a Polyline: "))) 'Coordinates))

Message 13 of 17

robert.webster247M7
Contributor
Contributor

Thank you very much. that is brilliant

0 Likes
Message 14 of 17

ВeekeeCZ
Consultant
Consultant

Rather read my first reply, that's the real solution. 

Message 15 of 17

pbejse
Mentor
Mentor

RTOS ?I did not even consider that as an issue because that is what @Moshe-A  suggested at post # 3  😂 

I thought its more sinister than that

 

ROFL.png

 

0 Likes
Message 16 of 17

robert.webster247M7
Contributor
Contributor

A big thank you  to everyone, your help and time, much appreciated!! 

0 Likes
Message 17 of 17

pbejse
Mentor
Mentor

@robert.webster247M7 wrote:

A big thank you  to everyone, your help and time, much appreciated!! 


You are welcome, just know that you can trust the API regardless what you see or NOT see.

Cheers

 

0 Likes