Jump to content

Recommended Posts

Posted

I've found other routines on the forum that somewhat do what I want to do...but not exactly.

 

I would like to type 'ara' and be able to pick a closed polyline and have the following happen:

 

- command prompt ask for insertion point to insert text showing the area in square feet for the polyline (1234 sf)

- I would like the text to come in on the same layer as the selected polyline

 

Thanks in advance! :D

Posted

This topic has been touched on countless times. I'm sure what you want exists or close enough to tweak to fit your needs. Have you tried coding it yourself? Wouldn't be too terribly difficult.

Posted (edited)

This ... ? :D

 

(defun c:TesT (/ ss p)
 ;; Tharwat 18. Nov. 2011 ;;
 (if (and (setq ss (car (entsel "\n Select a closed polyline :")))
          (vlax-curve-IsClosed ss)
          (setq p (getpoint "\n Specify Text loacation :"))
     )
   (entmakex
     (list
       '(0 . "TEXT")
       (cons 10 (trans p 1 0))
       (cons 40 (getvar 'textsize))
       (assoc 8 (entget ss))
       (cons 1
             (strcat
               (rtos (cvunit (vla-get-area (vlax-ename->vla-object ss)) "inch" "ft")
                                           2 2
               )
               "sf"
             )
       )
     )
   )
   (princ)
 )
 (princ)
)

Edited by Tharwat
Posted

One minor problem...and this might not be with the lisp...but...the square footage comes up wrong.

ie: I make a 10' x 10' box. The area should be 100 but when I use the routine...the area comes out as 47.2441 sf. Help please. :?

Posted
One minor problem...and this might not be with the lisp...but...the square footage comes up wrong.

ie: I make a 10' x 10' box. The area should be 100 but when I use the routine...the area comes out as 47.2441 sf. Help please. :?

 

No problem , codes updated .

Posted

Works...but it lists the sq inches instead of sf...so the 10' x 10' box comes up as 14400.000000sf.

Also...how do I get it to round off to the nearst sf?

 

Sorry...I'm new to this programming thing.

Posted

Still not working...not sure if I'm just doing something wrong. I draw the same 10' x 10' box and now the area comes up as "1200.00sf"

Posted

To see the text when it is placed...

(better CMDECHO = 0)

 

(defun c:TesT (/ ss p)
;; Tharwat 18. Nov. 2011 ;;
   (if (and (setq ss (car (entsel "\n Select a closed polyline :")))
            (vlax-curve-IsClosed ss)
       )
       (progn
           (entmake '((0 . "BLOCK")(2 . "_area_")(70 . 0)(10 0.0 0.0 0.0)))
           (entmake
               (list
                   '(0 . "TEXT")
                   '(10 0.0 0.0 0.0)
                   (cons 40 (getvar 'textsize))
                   (assoc 8 (entget ss))
                   (cons 1
                       (strcat
                           (rtos (cvunit (vla-get-area (vlax-ename->vla-object ss)) "inch" "ft")
                                        2 2
                           )
                           "sf"
                       )
                   )
               )
           )  
           (entmake '((0 . "ENDBLK")))
           (prompt "\n ")
           (prompt "\n Specify Text location : ")
           (command "_-insert" "_area_" pause "1" "1" "0")
           (command "_explode" "_L")     
       )
   )
   (princ)
)

Posted

Still not working...area of my 10'x10' box is coming up as 1200.00sf...

Posted

Quickly written,

 

(defun c:test ( / area en nm pt )
   (while
       (progn (setvar 'ERRNO 0) (setq en (car (entsel)))
           (cond
               (   (= 7 (getvar 'ERRNO))
                   (princ "\nMissed, try again.")
               )
               (   (eq 'ENAME (type en))
                   (if (vl-catch-all-error-p
                           (setq area (vl-catch-all-apply 'vlax-curve-getarea (list en)))
                       )
                       (princ "\nInvalid Object.")
                   )
               )
               (   (setq area nil)   )
           )
       )
   )
   (if (and area (setq pt (getpoint "\nPoint for Text: ")))
       (entmake
           (list
              '(0 . "TEXT")
               (cons 210 (setq nm (trans '(0.0 0.0 1.0) 1 0 t)))
               (cons  10 (trans pt 1 nm))
               (cons  40 (getvar 'TEXTSIZE))
               (assoc  8 (entget en))
               (cons  50 (angle '(0.0 0.0 0.0) (trans (getvar 'UCSXDIR) 0 nm t)))
               (cons   1 (rtos (/ area 144.0) 2))
           )
       )
   )
   (princ)
)
(vl-load-com) (princ)

Posted
Still not working...not sure if I'm just doing something wrong. I draw the same 10' x 10' box and now the area comes up as "1200.00sf"

 

You're right , I shouldn't have used the conversion as I did in the routine , I should've use it like Lee did (/ area 144.).

 

If you interested to use my routine , just replace this .

 

(rtos (cvunit (vla-get-area (vlax-ename->vla-object ss)) "inch" "ft") 2 2 )

 

With this ..

 

(rtos (/ (vla-get-area (vlax-ename->vla-object ss)) 144.) 2 2 ) 

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