Ibrahim Posted August 15, 2011 Posted August 15, 2011 Hi every body, i have a drawing (autocad 2011) ,which i have to measure the areas of the many rooms and i arrange these areas in a table! is there any fast way to do so? avoiding the boaring typical area measurements room by room? Many thanks, Quote
ReMark Posted August 15, 2011 Posted August 15, 2011 Sounds like a job for a custom lisp routine. There are several "area" lisp routines available from different AutoCAD websites. I'd suggest searching here and at The Swamp, the CADforum, and/or the Cadalyst magazine website under CAD Tips. Quote
Ibrahim Posted August 16, 2011 Author Posted August 16, 2011 Hi, Thanks Remark....Ur TIP leads to m lisp and i find that really helpful and interesting Quote
Tyke Posted August 16, 2011 Posted August 16, 2011 If you place a hatch (non associative) in the room and then click on the hatch you can see the area in the properties window. If the hatch is associative when you click the hatch the bounding polygon will automatically be selected too. It takes just one click to create the hatch. Quote
Ibrahim Posted August 16, 2011 Author Posted August 16, 2011 "m lisp"? What's that? Dear ReMark, I meant lisp routine,i found a useful one and i am using it....but i dont know how to change the text size that the lisp gives me (after calcualting the area)! and i wish to change the uints that lisp gives me with the area from SF (Square foot ) to (m²)...if u have an idea how to do that, will be very happy. Quote
Ibrahim Posted August 16, 2011 Author Posted August 16, 2011 Hi Tyke, No dear it is not so simple! i have to deal with so many rooms in each one i have to know the area and write that in the same area (room).....so having a look at properties every time and write it down will not be easy thig to do! thanks for sharing me with ur idea. Quote
ReMark Posted August 16, 2011 Posted August 16, 2011 Where did you find this lisp routine? Someone here could probably tell you how to change the text size if they knew where to find the routine. Quote
Tyke Posted August 16, 2011 Posted August 16, 2011 Hi Tyke, No dear it is not so simple! i have to deal with so many rooms in each one i have to know the area and write that in the same area (room).....so having a look at properties every time and write it down will not be easy thig to do! thanks for sharing me with ur idea. In the properties window for the hatch, if you click on its area you can open up the calculator and with Ctrl C you can copy the value to the clipboard and then paste it into your text input. But if you have a LISP routine that does the job stick with it. Quote
Ibrahim Posted August 16, 2011 Author Posted August 16, 2011 (edited) Hi, will be grateful for any help; Here is the link and the Lisp: http://cadtips.cadalyst.com/node/tiplisting?keywords=Tip1645a ;Tip1645a: DDAREA.LSP Label Areas (c)2000, Brian Strandberg ; Global Variables (setq BW_AREA_OBJ "Object: ") (setq ADDT 1) (setq BW_AREA_THEI (* 0.125 (getvar "dimscale"))) (setq BW_AREA_TROT 0) (setq BW_AREA_AREA 1) (setq BW_AREA_PERI 0) (setq BW_AREA_ID 1) (setq BW_AREA_LBL 1) (setq BW_AREA_AREAC 0) (setq BW_AREA_RBL 0) (setq BW_AREA_SOF 0) ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (setq BW_AREA_FD "c:/ddarea.cvs") ; edit this to change the default location of the output file (defun BW_AREA (/ A TEXT NUM LEN C D E F H TOTAL TOTALP) (setvar "hpbound" 1) (setvar "cmdecho" 0) (if (= 1 BW_AREA_SOF) (setq FD (open BW_AREA_FD "a")) () ) ;_ end of if (setq TOTAL 0) (setq TOTALP 0) ; Select objects or boundary ******************* (if (/= RET 2) (setq A (ssget)) (progn (BW_BOUND) (setq A BW_BOUND_SET)) ) ;_ end of if (setq TSH (cdr (assoc 40 (tblsearch "style" (getvar "textstyle"))))) (if (= TSH 0) (princ) (command "-style" "" "" "0" "" "" "" "" "") ) ;_ end of if (setq NUM 0) (setq LEN (sslength A)) (if (= 1 BW_AREA_SOF) (progn (princ "\n\n\n" FD) (if (= 1 BW_AREA_ID) (princ BW_AREA_OBJ FD) () ) ;_ end of if (if (= 1 BW_AREA_AREA) (princ ",Sq. Ft." FD) () ) ;_ end of if (if (= 1 BW_AREA_AREAC) (princ ",Acres" FD) () ) ;_ end of if (if (= 1 BW_AREA_PERI) (princ ",Perimeter" FD) () ) ;_ end of if ) ;_ end of progn () ) ;_ end of if (repeat LEN (setq C (ssname A NUM)) (setq D (entget C)) (setq E (cdr (assoc -1 D))) (command ".area" "O" E) (princ "\n") (if (= 1 BW_AREA_SOF) (progn (princ "\n " FD) (if (= 1 BW_AREA_ID) (if (not BW_AREA_SOF) (princ BW_AREA_OBJ FD) () ) ;_ end of if () ) ;_ end of if (setq QQ (+ ADDT NUM)) (if (= 1 BW_AREA_ID) (princ (strcat "" (itoa QQ)) FD) () ) ;_ end of if (if (= 1 BW_AREA_AREA) (progn (princ (strcat "," (rtos (getvar "area"))) FD)) () ) ;_ end of if (if (= 1 BW_AREA_AREAC) (progn (setq T1 (cvunit (getvar "area") "sq feet" "Acres")) (princ (strcat "," (rtos T1)) FD) ) ;_ end of progn () ) ;_ end of if (if (= 1 BW_AREA_PERI) (progn (princ (strcat "," (rtos (getvar "Perimeter"))) FD)) () ) ;_ end of if (setq TOTALP (+ TOTALP (getvar "perimeter"))) (setq TOTAL (+ TOTAL (getvar "AREA"))) ) ;_ end of progn () ) ;_ end of if (if (= 1 BW_AREA_LBL) (BW-LABEL) () ) ;_ end of if (setq NUM (+ 1 NUM)) ) ;_ end of repeat (if (and (= RET 2) (= BW_AREA_RBL 0)) (command ".erase" A "") () ) ;_ end of if (if (= 1 BW_AREA_SOF) (progn (if (= 1 BW_AREA_AREA) (progn (princ "\nThe total area(SF) is: " FD) (princ TOTAL FD)) () ) ;_ end of IF (if (= 1 BW_AREA_AREAC) (progn (princ "\nThe total area(Acres) is: " FD) (princ (cvunit TOTAL "Sq Feet" "Acres") FD) ) ;_ end of PROGN () ) ;_ end of IF (if (= 1 BW_AREA_PERI) (progn (princ "\nThe total perimeter is: " FD) (princ TOTALP FD)) () ) ;_ end of IF ) ;_ end of progn () ) ;_ end of if (if (/= TSH 0.0) (command "-style" "" "" TSH "" "" "" "" "") () ) ;_ end of if (setq ADDT (+ ADDT NUM)) ; prevent repeating numbers (if (= 0 BW_AREA_SOF) () (close FD) ) ;_ end of if (princ) ) ;_ end of defun (defun BW-LABEL (/ TINS) (redraw E 3) (setq TINS (getpoint "\nText insertion point: ")) (if (= 1 BW_AREA_ID) (progn (command ".text" "m" TINS BW_AREA_THEI BW_AREA_TROT (strcat BW_AREA_OBJ (itoa (+ ADDT NUM))) ) ;_ end of command ) ;_ end of progn (command ".text" "m" TINS BW_AREA_THEI BW_AREA_TROT "") ) ;_ end of if (if (= 1 BW_AREA_AREA) (progn (command ".text" "" (strcat (rtos (getvar "area")) " SF"))) () ) ;_ end of if (if (= 1 BW_AREA_AREAC) (progn (command ".text" "" (strcat (rtos (cvunit (getvar "area") "sq feet" "Acres")) " AC") ) ;_ end of command ) ;_ end of progn () ) ;_ end of if (if (= 1 BW_AREA_PERI) (progn (command ".text" "" (strcat (rtos (getvar "Perimeter")) " P"))) () ) ;_ end of if (setq BW_TEMP (cdr (assoc -1 (entget (entlast))))) (redraw E 4) ) ;close routine (defun BW_GF (/) (setq BW_FD (getfiled "Select an output File" BW_AREA_FD "TXT" (+ 1 2 4))) ) ;_ end of defun (defun BW_AREA_SETUP (/) (set_tile "obj" BW_AREA_OBJ) (set_tile "num" (itoa ADDT)) (set_tile "thei" (rtos BW_AREA_THEI)) (set_tile "trot" (rtos BW_AREA_TROT)) (set_tile "ID" (itoa BW_AREA_ID)) (set_tile "area" (itoa BW_AREA_AREA)) (set_tile "areac" (itoa BW_AREA_AREAC)) (set_tile "peri" (itoa BW_AREA_PERI)) (set_tile "lbl" (itoa BW_AREA_LBL)) (set_tile "rbl" (itoa BW_AREA_RBL)) (set_tile "sof" (itoa BW_AREA_SOF)) (if (= BW_AREA_LBL 0) (progn (mode_tile "thei" 1) (mode_tile "trot" 1)) () ) ;_ end of if ) ;_ end of defun (defun BW_LBL1 ($VAL /) (if (= $VAL "0") (progn (mode_tile "thei" 1) (mode_tile "trot" 1)) (progn (mode_tile "thei" 0) (mode_tile "trot" 0)) ) ;_ end of if (setq BW_AREA_LBL (atoi $VAL)) ) ;_ end of defun (defun C:DDAREA (/) (setq DH (load_dialog "ddarea")) (new_dialog "ddarea" DH) (BW_AREA_SETUP) (action_tile "accept" "(done_dialog 1)") (action_tile "acceptb" "(done_dialog 2)") (action_tile "cancel" "(exit)(exit)") (action_tile "obj" "(progn (setq bw_area_obj $value)(bw_area_setup))") (action_tile "num" "(progn (setq addt (atoi $value))(bw_area_setup))") (action_tile "thei" "(progn (setq bw_area_thei (atof $value))(bw_area_setup))") (action_tile "trot" "(progn (setq bw_area_trot (atof $value))(bw_area_setup))") (action_tile "ID" "(progn (setq bw_area_id (atoi $value))(bw_area_setup))") (action_tile "area" "(progn (setq bw_area_area (atoi $value))(bw_area_setup))") (action_tile "areac" "(progn (setq bw_area_areac (atoi $value))(bw_area_setup))") (action_tile "peri" "(progn (setq bw_area_peri (atoi $value))(bw_area_setup))") (action_tile "lbl" "(bw_lbl1 $value)") (action_tile "out" "(bw_gf)") (action_tile "rbl" "(progn (setq bw_area_rbl (atoi $value))(bw_area_setup))") (action_tile "sof" "(progn (setq bw_area_sof (atoi $value))(bw_area_setup))") (setq RET (start_dialog)) (BW_AREA) ) ;_ end of defun (defun BW_BOUND (/ A C DQ B1) (setq B1 1) (setq BW_BOUND_SET NIL) (setq DQ NIL) (setq A (entlast)) ;Selecting Entities Start********%%%%%%%% (princ "\nEnter Points For Boundary Selection, Return to End: ") (while (/= NIL B1) (setq B1 (getpoint)) (if (/= NIL B1) (command "-boundary" B1 "") () ) ;_ end of if (if (= BW_AREA_BV 1) (progn (setq KB (entlast)) (princ "\n") (initget "Yes No") (setq KBL (getkword "Keep Boundary Line? (Yes or No) ")) (if (= KBL "N") (command ".erase" KB "") () ) ;_ end of if ) ;close progn () ) ;close if ) ; end while (setq D (ssget "L")) (setq C (entnext A)) (while (/= NIL C) (setq DQ (ssadd C D)) (setq C (entnext C))) ;Selecting Entities End*********%%%%%%%%% (setq BW_BOUND_SET DQ) (if (= NIL BW_BOUND_SET) (progn (alert "Must indicate at least one valid\n\nBoundary set. Exiting Program") (exit) ) ;_ end of progn () ) ;_ end of if ) ;_ end of defun Edited August 31, 2011 by SLW210 Added CODE TAGS!!!!! Quote
Ibrahim Posted August 16, 2011 Author Posted August 16, 2011 In the properties window for the hatch, if you click on its area you can open up the calculator and with Ctrl C you can copy the value to the clipboard and then paste it into your text input. But if you have a LISP routine that does the job stick with it. did not know that thanks for this tip,,,maybe will use for another work. Quote
ReMark Posted August 16, 2011 Posted August 16, 2011 My guess is the lisp routine uses the last value that was input for text height. Quote
Tyke Posted August 16, 2011 Posted August 16, 2011 My guess is the lisp routine uses the last value that was input for text height. The value is saved in the system variable TEXTSIZE and you can input a new value. But it only has an effect when the text style text size is set to 0. Quote
SLW210 Posted August 16, 2011 Posted August 16, 2011 Ibrahim, Please read the CODE POSTING GUIDELINES. Quote
irneb Posted August 16, 2011 Posted August 16, 2011 I actually prefer having my areas as attributes of my room tags. That way I can then use Data Extract to create a room matrix quite easily - even through multiple DWG files in one go. For this reason I've made one which doesn't create a new text but allows you to store the value into an existing Text/MText/Attrib. Inside my DimUtils.LSP file there's a DimArea command. This links the text as a field to the area defining polyline / hatch / whatever else you use for areas. That way even after you stretch a room the area stays updated (after a regen). It's a bit strange though: It asks for the text where you want the result, then to select multiple object to add their areas together, then for another set of object to subtract from the total. You can still just select one, and press space/enter for the subtractions. I just did this so I don't need to go with hatches simply to calculate areas. Edit: I don't know how many times this has happened to me: The red a above didn't go through when I typed, and it didn't show up as a spelling mistake (obviously). It's because of these cheap electronic switching keyboards we get these days. They're not meant for "touch typing" ... I'm going to get myself a Razer BlackWidow next time! Once I've saved up enough of course! Quote
Srajcka Posted August 31, 2011 Posted August 31, 2011 Hi every body, i have a drawing (autocad 2011) ,which i have to measure the areas of the many rooms and i arrange these areas in a table! is there any fast way to do so? avoiding the boaring typical area measurements room by room? But its not english, with some modification can you get the table you want,.... Pline_area.lsp Quote
Ibrahim Posted August 31, 2011 Author Posted August 31, 2011 Thanks Srajcka, actually i used the a lisp and it was good ...will save this lisp also and get benefit from it ...thanks again Quote
Srajcka Posted August 31, 2011 Posted August 31, 2011 Now Im doing that i will draw a table, and than with LSP pick ana area and then it will suscribe into table,... (defun C:AREATT ( / en obj tblobj row col lst pt rows cols what fld) ;;;; Command: AREATT (AREA to table) ;;;; Posted http://dwg.ru/f/showthread.php?t=14528 ;;;; This command allows you to insert into the specified table cell and the subsequent ;;;; Text field (FIELD), containing the value of the square of the selected object. ;;;; Depending on the choice of navigation options by rows or columns. ;;;; If rows or columns coming to an end, they are automatically added. ;;;; Formatting cell is taken as specified in the first cell. ;;;; Precision of rounding and scaling factor are given the option "Setting" ;;;; Since this field is associated with a particular object, if you change ;;;; Object field is recalculated (need updating field) ;;;; Code can be stored in a file areatt.lsp ;;;; Possible macro to a button or menu item: ;;;; ^ C ^ C (if (not C: AREATT) (load "AREATT")); AREATT; (vl-load-com) (or *SCALE* (setq *SCALE* 1)) (or *PREC* (setq *PREC* 2)) (or *TEXTSIZE* (setq *TEXTSIZE* (getvar "TEXTSIZE"))) (or *SUFF* (setq *SUFF* ""))(or *PREF* (setq *PREF* "")) (setq *SUFF* (vl-princ-to-string *SUFF*)) (setq *PREF* (vl-princ-to-string *PREF*)) (princ "\nCurrent scale = ")(princ *SCALE*) (princ " Current precision = ")(princ *PREC*) (princ " Text size = ")(princ *TEXTSIZE*) (princ " Prefix= ")(princ *PREF*)(princ " Suffix= ")(princ *SUFF*) (setq tblobj nil tblobj (ssget "_X" '((0 . "ACAD_TABLE")))) (setq lst (mapcar 'vlax-ename->vla-object(vl-remove-if 'listp (mapcar 'cadr (ssnamex tblobj))))) (setq tblobj nil) (cond ((and lst (or (initget "Row Col Setting _Row Col Setting") t) (or (while (=(setq what (getkword "\nNavigate [on tne Row/on the Columns/Setting] <on the Columns>: ")) "Setting") (princ "\nNew scale <")(princ *SCALE*)(princ "> : ") (initget 6) (if (setq en (getdist))(setq *SCALE* en)) (princ "\nNew precision <")(princ *PREC*)(princ "> : ") (initget 4) (if (setq en (getint))(setq *PREC* en)) (princ "\nNew text size <")(princ *TEXTSIZE*)(princ "> : ") (initget 6) (if (setq en (getdist))(setq *TEXTSIZE* en)) (princ "\nPrefix (space - clear) <")(princ *PREF*)(princ "> : ") (if (= (setq en (getstring t)) " ")(setq en "")) (if (= (substr (vl-string-left-trim "\/" en) 1 2) "U+") (setq en (strcat "\\" (vl-string-left-trim "\/" en))))(setq *PREF* en) (princ "\nSuffix? (space - clear) <")(princ *SUFF*)(princ "> : ") (if (= (setq en (getstring t)) " ")(setq en "")) (if (= (substr (vl-string-left-trim "\/" en) 1 2) "U+") (setq en (strcat "\\" (vl-string-left-trim "\/" en))))(setq *SUFF* en) (initget "Row Col Setting _Row Col Setting") ) t ) (or what (setq what "Col")) (or (while (null tblobj) (initget 1) (setq pt (getpoint "\nSpecify a first table cell:")) (mapcar '(lambda (x) (or tblobj (and (= :vlax-true (vla-HitTest x (vlax-3d-point (trans pt 1 0)) (vlax-3d-point (trans (getvar "VIEWDIR") 1 0)) 'row 'col)) (setq tblobj x) ) ) ) lst) (if (null tblobj)(princ " ** missing **")) ) t) (or (vlax-write-enabled-p tblobj) (and (princ "\nTable on a locked layer!") nil ) ) (setq pt (vla-GetCellAlignment tblobj row col)) ) (setq rows (vla-get-rows tblobj)) (setq cols (vla-get-columns tblobj)) (while (setq en (car (entsel "\nSelect the entity to insert it square into the table (ENTER - exit): " ))) (cond ((vlax-property-available-p (setq en (vlax-ename->vla-object en)) 'Area) (setq fld (strcat "%<\\AcObjProp Object(%<\\_ObjId " (vl-princ-to-string(Get-ObjectID-x86-x64 en)) ">%).Area \\f \"%lu2%ps["*PREF* "," *SUFF* "]%pr"(itoa *PREC*) "%ct8["(vl-princ-to-string *SCALE*)"]\">%" ) ;_ strcat ) (cond ((= col cols) (vla-insertColumns tblobj col (vla-GetColumnWidth tblobj (1- col)) 1) (vla-SetCellAlignment tblobj row col pt) (setq rows (vla-get-rows tblobj)) (setq cols (vla-get-columns tblobj)) ) ((= row rows) (vla-insertRows tblobj row (vla-GetRowHeight tblobj (1- row)) 1) (vla-SetCellAlignment tblobj row col pt) (setq rows (vla-get-rows tblobj)) (setq cols (vla-get-columns tblobj)) ) (t nil)) (vla-SetText tblobj row col fld) (if (= what "Col")(setq col (1+ col))(setq row (1+ row))) ) (t(princ "\nThis primitive can not get property Area!")) ) ) ) (t (princ "\nTables not found!") ) ) (princ) ) ;;------------------------------------------------ -------- ;; Function gets a string representation ObjectID ;; Whether AutoCAD x86 or x64 ;; Source: https: / / discussion.autodesk.com / forums / message.jspa? MessageID = 6172961 ;; Http://forum.dwg.ru/showthread.php?t=51822 (defun Get-ObjectID-x86-x64 (obj / util) (setq util (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object)))) (if (= (type obj) 'ENAME)(setq obj (vlax-ename->vla-object obj))) (if (= (type obj) 'VLA-OBJECT) (if (> (vl-string-search "x64" (getvar "platform")) 0) (vlax-invoke-method util "GetObjectIdString" obj :vlax-False) (rtos (vla-get-objectid obj) 2 0) ) ) ) But i dont know how to do, that would the LSP draw a table,... Cause i need only number, i will draw aa table, than in first coum will be the material, and in he second will the LSP insert the area number, than i will take that number from table and export it into the excel, that is the concept i hope it will work,... Quote
Recommended Posts
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.