Write text with limited decimal places

Write text with limited decimal places

Anonymous
Not applicable
1,128 Views
4 Replies
Message 1 of 5

Write text with limited decimal places

Anonymous
Not applicable

I am trying to put a bearing and distance on every line in a drawing with 3 decimal places on the distance.

I have got the routine to save the needed values but when I write them to text the distance has a bunch of trailing zeros. I need to limit the decimal places to 3.

 

(setq Dist (getpropertyvalue line "length"))  ;line is set to an entity from a defined selection set

(Dist+ (atof (rtos dist 2 3)))      ;This should round the value to 3 decimal places

(command "_.text" "s" "micro" "j" "m" Dpoint TxtHt AngDMS Dist+) ;Dpoint, TxtHt, AngDMS are all defined parameters

 

The printed text is rounded to 3 decimal places but still prints the trailing zeros.

How can I limit the zeros?

0 Likes
Accepted solutions (1)
1,129 Views
4 Replies
Replies (4)
Message 2 of 5

_gile
Consultant
Consultant

Hi,

 

Have a look at the DIMZIN system variable.



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

0 Likes
Message 3 of 5

dlanorh
Advisor
Advisor

Posting the complete lisp might help solve the issue your having.

I am not one of the robots you're looking for

0 Likes
Message 4 of 5

scot-65
Advisor
Advisor
Accepted solution
Text accepts a string input for the value.
I believe ATOF does not belong there [alpha to floating decimal].

(setq Dist (rtos (getpropertyvalue line "length") 2 3))

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 5 of 5

Anonymous
Not applicable

.

0 Likes