Jump to content

simple area


bogeymen77

Recommended Posts

i'm looking for a simple area routine base on the dimension not the line.

i want to be able to click on 2 cotation that i got from the dimlinear command and have the area "print" in a text format where i want to.

I know a routine with a lot of visual lisp routine in it, but i'm looking a version with a standard/ basic lisp.

 

thank you.

Link to comment
Share on other sites

Hi,

 

Is it something like select the 1st dimlinear then the 2nd one then specify a point to place the area as a text object which supposed to be produced from multiplying of dim text1 and dim text2 ?

Link to comment
Share on other sites

This?

(defun c:Test ( / dm1 dm2 en1 en2 obj get hgt ins )
 (and
   (setq dm1 (car (entsel "\nSelect 1st dimlineaer :")))
   (or (member '(100 . "AcDbAlignedDimension") (setq en1 (entget dm1)))
       (alert "Invalid object.<!>")
       )
   (setq dm2 (car (entsel "\nSelect 2nd dimlineaer :")))
   (or (member '(100 . "AcDbAlignedDimension") (setq en2 (entget dm2)))
       (alert "Invalid object.<!>")
       )
   (setq obj (tblobjname "BLOCK" (cdr (assoc 2 en1))))
   (while (and (not hgt) (setq obj (entnext obj)))
     (and (= (cdr (assoc 0 (setq get (entget obj)))) "MTEXT")
          (setq hgt (assoc 40 get))
          )
     )
   (setq ins (getpoint "\nSpecify location of text area :"))
   (entmake (list '(0 . "TEXT") (cons 10 (trans ins 0 1)) (cons 11 (trans ins 0 1)) hgt
                  (cons 1 (rtos (* (cdr (assoc 42 en1)) (cdr (assoc 42 en2))) 2))
                  )
            )
   )
 (princ)
 )

Link to comment
Share on other sites

work perfectly thank...

 

If i can ask you an other issue.

if i have a few area measurement and i want to have the total, what would be the routine/formula?

 

thank

Link to comment
Share on other sites

You're welcome.

 

if i have a few area measurement and i want to have the total, what would be the routine/formula?

 

Do you mean that you would like to sum texts with numerical values to new text as total areas?

Link to comment
Share on other sites

yes. for exemple i got 4 piece of counter top ,i got the area for each one. After i would like to have the sum of all 4 pieces.

 

thank you

Link to comment
Share on other sites

I am sure Tharwat will continue to answer there are a few different ways to do this.

 

1 Pick text and add up.

2 Select text on one layer, your dwg its on layer 0 needs to be something different, like table-area.

3 Make a block and have an attribute then just total all attributes.

4 like 3 but make an Autocad table of the areas with common table top styles.

 

It would be good at this point to suggest which method you want so its not a case of multiple changes.

 

Could not resist suggestion 1, this is real basic no error checking.

(defun c:test ( / tot ent obj)
(setq tot 0.0)
(while (setq ent (entsel "\nPick text Enter to stop"))
(setq obj (vlax-ename->vla-object (car ent)))
(setq tot (+ (atof (vla-get-textstring obj)) tot))
)
(alert (strcat "The total area is = " (rtos tot 2 3 )))
)

Link to comment
Share on other sites

(defun c:sum (/ int tot sel ent int val ins)
 ;; Tharwat -  Date: 09.Jun.2018	;;
 (princ "\nSelect text areas to sum :")
 (and (setq int -1
            tot 0.0
            sel (ssget "_:L" '((0 . "TEXT")))
      )
      (progn
        (while (setq ent (ssname sel (setq int (1+ int))))
          (and (numberp (setq val (read (cdr (assoc 1 (entget ent))))))
               (setq tot (+ tot val))
          )
        )
        (< 0.0 tot)
      )
      (setq ins (getpoint "\n Specify text location :"))
      (entmake (list '(0 . "TEXT")
                     (cons 10 (trans ins 0 1))
                     (cons 11 (trans ins 0 1))
                     (cons 40 (getvar 'TEXTSIZE))
                     (cons 1 (rtos tot 2))
               )
      )
 )
 (princ)
)

Link to comment
Share on other sites

Nicely done Tharwat.

 

Thank you BIGAL. :)

 

Maybe 1 little suggestion.

(cons 1 (strcat "Area = " (rtos tot 2)))

Yes indeed it is a very good suggestion and make sense.

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