Jump to content

"0" is not showing in this Area lisp


tive29

Recommended Posts

Found this area lisp somewhere & did some minor edit.

But there is a problem. if the area is example 0.11, the text ouput will be .11m2.

Can some tell me what to amend to have it show as 0.11m2

 

thanks

 

(defun drtxt (/ tx ls vl lt ht lb hb nr pt)
 (setq tx (strcat "";;;;add text between "";;;;
      (rtos (/ (getvar "area") 1000000) 2 2)
      "m²"
      )   
)
 (setq ls (list (cons 1 tx))
     vl (textbox ls)
     vl (cadr vl)
     lt (car vl)
     ht (cadr vl)
     vl (grread T)
     nr (car vl)
     pt (cadr vl)
 )
 (princ "\nInsert Point: ")
 (while (/= nr 3)
   (command "redraw")
   (grdraw pt (setq pt (polar pt 0 lt)) 7)
   (grdraw pt (setq pt (polar pt (* pi 0.5) ht)) 7)
   (grdraw pt (setq pt (polar pt pi lt)) 7)
   (grdraw pt (polar pt (* pi 1.5) ht) 7)
   (setq vl (grread T)
     nr (car vl)
     pt (cadr vl)
   )
   ) ;end while function
(command "-mtext" pt "w" 0 tx "")
(redraw)
) ; end drtxt function

(defun c:AA ()
 (setvar "cmdecho" 0)
 (while (setq et
      (car
            (entsel "\nSelect polyline: ")
        ) ;end car function
    ) ;end setq function
 (command "area" "o" et)
 (drtxt)
 ) ; wnd while funtion

(setvar "cmdecho" 1)
(princ)

) ; end c:pla function

Link to comment
Share on other sites

(defun drtxt (/ tx ls vl lt ht lb hb nr pt)
 (setq tx (strcat "";;;;add text between "";;;;
      (rtos (/ (getvar "area") 1000000) 2 2)  "m²" ) )
 (if (= (substr tx 1 1) ".")(setq tx (strcat "0" tx)))
)

Link to comment
Share on other sites

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...