Autolisp Variable does not display decimals

Autolisp Variable does not display decimals

Anonymous
Not applicable
3,301 Views
17 Replies
Message 1 of 18

Autolisp Variable does not display decimals

Anonymous
Not applicable

Hi,

 

This is something very weird, I have checked a point with Command-ID I get X = 306976.42997     Y = 2091370.49958

 

Now I use Get Point Function I get (306976.0 2.09137e+006 0.0) decimals are not displayed!

 

This seems very unusual, Need some help here!

0 Likes
3,302 Views
17 Replies
Replies (17)
Message 2 of 18

BeKirra
Advisor
Advisor

1st off all, -ID is not an AutoCAD native command. It may be a command alias or an add-on command.

2nd, try this: type units in command prompt to change drawing unit. Then in "Length" section, ensure to select "Decimal" in Type and 0.00000 in Precision".

 

HTH

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
Message 3 of 18

Satish_Rajdev
Advocate
Advocate

Hello,

 

Getpoint function doesn't show decimals but it's there in the memory, you can check those decimals by rtos

For example :

_$ (setq p (getpoint))
(306976.0 2.09137e+006 0.0)
_$ (rtos (car p) 2 5)
"306976.42997"
_$ (rtos (cadr p) 2 5)
"2091370.49958"

Best Regards,
Satish Rajdev


REY Technologies | Linked IN | YouTube Channel


 

0 Likes
Message 4 of 18

Anonymous
Not applicable

@BeKirra wrote:

1st off all, -ID is not an AutoCAD native command. It may be a command alias or an add-on command.

2nd, try this: type units in command prompt to change drawing unit. Then in "Length" section, ensure to select "Decimal" in Type and 0.00000 in Precision".

 

HTH


Hi

 

Thanks, the question was displaying the data output of Lisp Function, I would like to see the Point decimals as it is, rather than adding additional function to derive value. Is there any setting to change the lisp displayed data?



0 Likes
Message 5 of 18

Anonymous
Not applicable

@Satish_Rajdev wrote:

Hello,

 

Getpoint function doesn't show decimals but it's there in the memory, you can check those decimals by rtos

For example :

_$ (setq p (getpoint))
(306976.0 2.09137e+006 0.0)
_$ (rtos (car p) 2 5)
"306976.42997"
_$ (rtos (cadr p) 2 5)
"2091370.49958"

Hi

 

Thanks, the question was displaying the data output of Lisp Function, I would like to see the Point decimals as it is, rather than adding additional function to derive value. As mentioned correctly it is in the memory, we can use the same values as it is in the memory?

Is there any setting to change the lisp displayed data? It seems a change from earlier versions!

Thanks once again

0 Likes
Message 6 of 18

Satish_Rajdev
Advocate
Advocate

Yes, you can use same decimal values from memory as I’ve shown by rtos function. As per my knowledge there is no such setting to change display data.

 

Best Regards,
Satish Rajdev


REY Technologies | Linked IN | YouTube Channel


 

0 Likes
Message 7 of 18

john.uhden
Mentor
Mentor

Without intervening with functions like RTOS, AutoCAD has its own rules about displaying precision, usually only to about 4 or 5 places after the decimal.

If your eyes were going to process the values, your solutions would be a bit off, but (setq P (getpoint)) stores the exact coordinates in memory in the symbol P.  With that, your code can process the values with full precision.

 

For example:

Command: !pi 3.14159

Command: (rtos pi 2 2) "3.14"

Command: (rtos pi 2 8) "3.14159265"

John F. Uhden

0 Likes
Message 8 of 18

cadffm
Consultant
Consultant
Lisp or not, in autocad the DISPLAY precision is set by Luprec(and auprec) and DIMZIN.
Dimzin is also important for rtos and luprec too, if your second argument for rtos is nil)

Maximum 8 (command UNITS is the normal user way to set these things)

If you want to see more, only in Lisp, Rtos.
You can go up to 18, but for 15 is the maximum for the real precision if you have numbers between -10 and 10.

Hey at all, please check for me if i found the right link for that in english,thx.
https://en.m.wikipedia.org/wiki/Double-precision_floating-point_format

Sebastian

0 Likes
Message 9 of 18

BeKirra
Advisor
Advisor

@Anonymous wrote:

 


Hi

 

Thanks, the question was displaying the data output of Lisp Function, I would like to see the Point decimals as it is, rather than adding additional function to derive value. Is there any setting to change the lisp displayed data?


Sorry, when dropping in from work, I thought I was reading threads in "AutoCAD Forum".

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
Message 10 of 18

john.uhden
Mentor
Mentor
Your point is made well, but not entirely true.
Neither LUPREC nor DIMZIN controls how AutoCAD displays values on its own.

Command: luprec
Enter new value for LUPREC <8>: 2
Command: !pi 3.14159

Command: luprec
Enter new value for LUPREC <2>: 6
Command: !pi 3.14159

Try it yourself.
But the programmer can control the display [of values in the program] by
using RTOS, and ANGTOS, and DIMZIN.

John F. Uhden

Message 11 of 18

john.uhden
Mentor
Mentor
You've got the right spot.
Check out my reply to @cadffm.

John F. Uhden

0 Likes
Message 12 of 18

BeKirra
Advisor
Advisor

Yes, all others are right but they may not answer your question.

Using rtos function you can get decimal display.

@Satish_Rajdev shows an example

(rtos (car p) 2 5)

2 is the linear unit mode value which is set to "decimal"

5 is the precision value. These were also explained by @john.uhden

 

Again, -ID probably is a command alias or your add-on command.

You need to clarify this before we can go further.

If it an add-on coomand, please show us the code.

By using getpoint function, I don't think it can display decimal when the coordinate vaule reached to 1000000. In this case you may have to use rtos function.

 

HTH

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
Message 13 of 18

cadffm
Consultant
Consultant

thx John and sorry @Anonymous for the fail with luprec (and lisp),

But John, DIMZIN is extremly important if you handle with rtos and angtos (for example you will display or compare)

 

Befehl: (rtos 2.10 2 5)
"2.1"

Befehl: DIMZIN

Neuen Wert für DIMZIN eingeben <8>: 0

Befehl: (rtos 2.10 2 5)
"2.10000"

 

 

See also F1 for rtos angtos and dimzin.

 

I also remember how this thing confused me
Really values vs. displayed values. Since I understand every user of it initially stumbles.

 

Sebastian

0 Likes
Message 14 of 18

phanaem
Collaborator
Collaborator

Hi John

LUPREC does make a difference. Look into the properties cassette or try DIST, ID and LIST with different luprec values.

!pi is a lisp expression and maybe this is why is not affected by luprec.

Command: LUPREC
Enter new value for LUPREC <1>: 3
Command: id Specify point:  X = 428677.296     Y = 667129.117     Z = 0.000

Command: LUPREC
Enter new value for LUPREC <3>: 4
Command: ID Specify point:  X = 428677.2958     Y = 667129.1167     Z = 0.0000

Command: LUPREC
Enter new value for LUPREC <7>: 8
Command: ID Specify point:  X = 4.28677296E+05     Y = 6.67129117E+05     Z = 0.00000000

@ OP, it seems that any LUPREC value works, except 8. Of course, length units must be set to Decimal (LUNITS = 2)

0 Likes
Message 15 of 18

john.uhden
Mentor
Mentor

No arguments there.  You are too sharp.

John F. Uhden

0 Likes
Message 16 of 18

BeKirra
Advisor
Advisor

@Anonymous wrote:

Hi,

This is something very weird, I have checked a point with Command-ID I get X = 306976.42997     Y = 2091370.49958

Now I use Get Point Function I get (306976.0 2.09137e+006 0.0) decimals are not displayed!

This seems very unusual, Need some help here!


 

Just a side note.

I am not saying that what you guy's disussions here are woung. But it seems you are driving away from OP's question.

Smiley Surprised

What OP asks is how to get point coordinates displayed in decimals when using "getpoint" function.

And probably OP doesn't know how to respond your posts because he/she has not dropped in with any comments since.

 

 

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes
Message 17 of 18

Ajilal.Vijayan
Advisor
Advisor

Hello,

The getpoint function will return a 3D point. The 3D point contains the full precision.

Note that AutoLISP does not show you all the significant digits.

The ID command shows the decimals based on LUPREC variable.

For large values getpoint may not display the full precision. To display the decimal points you have to use rtos function.

see the image below, Drawing2 coordinates value is small compared to Drawing1 coordinates.

 

getpoint.gif

Message 18 of 18

BeKirra
Advisor
Advisor

Yes, this is the point - "For large values getpoint may not display the full precision."

Large values of "getpoint" >= 1000000, which is mentioned in reply #12.

You are right.

 

BTW Correction to my posts: ID is command while -ID may be a user customised alias.

Please mark "Accept as Solution" and "Like" if my reply resolves the issue and it will help when others need helps.
= ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ = ♪ = ♫ =
A circle is the locus of a cursor, starting and ending at the same point on a plane in model space or in layout such that its distance from a given coordinates (X,Y) is always constant.
X² + Y² = C²
0 Likes