Jump to content

Recommended Posts

bogeymen77

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.

Share this post


Link to post
Share on other sites
Tharwat

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 ?

Share this post


Link to post
Share on other sites
Tharwat

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

Share this post


Link to post
Share on other sites
bogeymen77

exactly. i'll try your code.

Share this post


Link to post
Share on other sites
bogeymen77

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

Share this post


Link to post
Share on other sites
Tharwat

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?

Share this post


Link to post
Share on other sites
bogeymen77

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

Share this post


Link to post
Share on other sites
Tharwat

What do you mean by counter top?

Can you upload a sample drawing showing the outcome of the process that you looking forward?

Share this post


Link to post
Share on other sites
bogeymen77

i'm drawing counter top. here'S an example

test counter top.dwg

Share this post


Link to post
Share on other sites
BIGAL

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

Share this post


Link to post
Share on other sites
Tharwat
(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)
)

Share this post


Link to post
Share on other sites
bogeymen77

works Perfectly !!! WOW thanks you all !!!

Share this post


Link to post
Share on other sites
Tharwat
works Perfectly !!! WOW thanks you all !!!

 

You're welcome.

Share this post


Link to post
Share on other sites
BIGAL

Nicely done Tharwat. Maybe 1 little suggestion.

 

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

Share this post


Link to post
Share on other sites
Tharwat
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×