Jump to content

Drop trailing zero when possible


Recommended Posts

Posted

Hello All,

 

I have a simple lisp that does some very simple math just to save time. It simply askes for a garage floor elevation and then the number of steps leading to the finish slab of a house. It then takes that elevation, adds 0.67' per step and returns two text strings. One being the garage with the number of steps and it's elevation, and the slab with its calculated elevation.

 

What I am trying to accomplish is for it to suppress any trailing zeros it might run into.

 

If the garage elevation is 778.66' with 2 steps, then the finish floor elevation would be 778.66'+.67'+.67' = 780'. My lisp will always return 780.00. 

 

I am trying to find a way to make it suppress any trailing zeros, so it would return 780.

 

Any help would be greatly appreciated. Code below.

 

(Defun c:SLAB ( / Elev steps ffe ipnt)
(setq name '("SLAB" "GARAGE"))
  (if (and
	(setq Elev (getdist "\nElevation: "))
	(setq Steps (getint "\nNumber of steps: "))
	(setq ffe ( + Elev (* 0.67 Steps)))
	)

    (foreach itm (list
		   (list (car name)
		       (strcat (car name) "\\PFFE=" (rtos ffe 2 2)"\\PFND=" (rtos ffe 2 2)))
		   (list (cadr name)
		       (strcat (cadr name)"\\P" (itoa steps) " STEPS\\PG=" (rtos Elev 2 2)))
		   )
      
      (if (setq ipnt (getpoint (strcat "\nPick text insertion point for " (Car itm))))
	(entmakex
	      (list
	        (cons 0 "MTEXT")
		(cons 100 "AcDbEntity")
	        (cons 100 "AcDbMText")
	        (cons 7 "CESO - Prop Arial")
	        (cons 8 "C-BLDG-TEXT")
	        (cons 40 2)
	        (cons 10 ipnt)
		'(71 . 5) 
		'(72 . 1) 
	        (cons 1 (cadr itm))
	              
	        )
	      )
	    )
      )
    )
(princ)
)

 

Posted

I was completely wrong. It's actually the opposite. I don't need it to suppress trailing zeros. I need it to add the trailing zeros.

 

Right now it WOULD return 780 and they want it to return 780.00. Sorry for the confusion.

Posted

This is one of those weird AutoCAD quirks. Check the value of the DIMZIN system variable. That seems to be the only way to unsuppress trailing zeroes.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...