Lisp For Getting Length Info In Multiple Units

Lisp For Getting Length Info In Multiple Units

timothy_crouse
Collaborator Collaborator
590 Views
6 Replies
Message 1 of 7

Lisp For Getting Length Info In Multiple Units

timothy_crouse
Collaborator
Collaborator

I needed a lisp to retrieve object length info in multiple units.

 

Note this has been used and tested with units set to Architectural and Decimal

 

Best Regards

-Tim C.

0 Likes
591 Views
6 Replies
Replies (6)
Message 2 of 7

CodeDing
Mentor
Mentor

@timothy_crouse ,

 

Nothing wrong with putting your lisp skills to work; It's good practice!

But for future reference, you can also use the (cvunit ...) function to save some heartache:

https://help.autodesk.com/view/OARX/2025/ENU/?guid=GUID-253E72F1-09B8-473E-A51B-B97BE2E29019 

 

Best,

~DD

0 Likes
Message 3 of 7

timothy_crouse
Collaborator
Collaborator

Nice, Thanks

0 Likes
Message 4 of 7

timothy_crouse
Collaborator
Collaborator

Is there a way to include commas in the results?

 

0 Likes
Message 5 of 7

Kent1Cooper
Consultant
Consultant

@timothy_crouse wrote:

Is there a way to include commas in the results?


[The same comments as for the other one apply, about the mode argument in (rtos) saving you the need to calculate feet and inches separately and put the string together with the foot & inch marks and hyphen.]

 

Do you mean comma as decimal separator, or comma as thousands/millions/etc. divider, or commas between the reports on each type of unit?  [Or something else?]

Kent Cooper, AIA
0 Likes
Message 6 of 7

ec-cad
Collaborator
Collaborator

Cvunits output / return is fixed in format, just a tool to convert.

Once converted, you can (rtos) and add "," as needed.

Here's a sample when cvunit returns a 'list

 

(setq lst (list 1 2 3))
(setq result (cvunit lst "ft" "in"))
(setq output "\nInches = ")
(foreach item result
 (setq output (strcat output (rtos item 2 2) ","))
); foreach
(setq output (substr output 1 (- (strlen output) 1)))
(alert output)

 

ECCAD

0 Likes
Message 7 of 7

jayhar
Advisor
Advisor

Hello,

Please check 

Please Subscribe YouTube Channel
https://www.youtube.com/channel/UCclj8v9vHQiFa8_DriuAk3w

Please Mark the Post or Posts as Solution(s) to help others find the answer quickly.
0 Likes