MOORADAN Posted April 28, 2016 Posted April 28, 2016 Hi Guys, I have a 1200 lots land similar to shown in the attachment. The poly lines are not joined. I need a way to find the enclosed area of each lot and the area needs to be shown as a text on the drawing… Any suggestion to write a script or lisp to work this out… You save a lot of my life Cheers area.dwg Quote
nod684 Posted April 28, 2016 Posted April 28, 2016 (edited) Hi Guys, I have a 1200 lots land similar to shown in the attachment. The poly lines are not joined. I need a way to find the enclosed area of each lot and the area needs to be shown as a text on the drawing… Any suggestion to write a script or lisp to work this out… You save a lot of my life Cheers create separate hatches and recreate the boundary on a separate layer maybe? EDIT : just done as what I suggested in 5 mins since it is already a closed polyline... you can easily get the areas of each one of them area_01.dwg Edited April 28, 2016 by nod684 add attachment Quote
MOORADAN Posted April 28, 2016 Author Posted April 28, 2016 “create separate hatches and recreate the boundary on a separate layer maybe?” Thank you… But that will take pretty long time… What I thought is use “Boundary” command, select enclosed area, check the created polyline, add the area text.. ( but these things should happen in script than doing it manually as it would take long time).. Not sure how to write it Quote
Dadgad Posted April 28, 2016 Posted April 28, 2016 Check out this lisp by Lee Mac, there are others on his spectacular website, if you need to generate a table, for instance. The total area of multiple lots is an option in this and one of his other area lisps, with the table functionality. http://www.lee-mac.com/areastofield.html Thanks Lee! Quote
MOORADAN Posted April 28, 2016 Author Posted April 28, 2016 You are always there to help out Dadgad... Will check it out and get back to you... Quote
Dadgad Posted April 28, 2016 Posted April 28, 2016 (edited) Lee Mac is awesome! No need to use the Boundary command, just fire up the following lisp by Lee Mac... http://www.lee-mac.com/arealabel.html ...first you will need to download it to your computer, and LOAD it, of course, and then jump right in, with AT at the commandline. Pay attention to the commandline prompts! Remember if this is not what you want, there are additional options available, as well as other AREA specific lisps on Lee's site. Lee Rules! Edited April 28, 2016 by Dadgad Quote
BIGAL Posted April 28, 2016 Posted April 28, 2016 Hope Lee does not mind you can add a boundary to the code for a single pick of area. Only drawback is table not created. ;;------------------------=={ Areas to Field }==------------------------;; ;; ;; ;; This program allows a user to create an MText object containing a ;; ;; Field Expression referencing the area, or sum of areas, of one or ;; ;; more selected objects. ;; ;; ;; ;; Upon issuing the command syntax 'A2F' at the AutoCAD command-line, ;; ;; the user is prompted to make a selection of objects for which to ;; ;; retrieve the area; if more than one object is selected, the ;; ;; cumulative area for all objects will be displayed by the resultant ;; ;; MText Field. ;; ;; ;; ;; Following object selection, the user is prompted to pick a point ;; ;; at which to create the MText Field. If the specified point resides ;; ;; within an AutoCAD table cell, the program will populate the table ;; ;; cell with the appropriate Field Expression. ;; ;; ;; ;; The Field will display the sum of the areas of the selected ;; ;; objects, formatted using the Field formatting code specified at ;; ;; the top of the program - this formatting code may be altered to ;; ;; suit the user's requirements. ;; ;; ;; ;;----------------------------------------------------------------------;; ;; Author: Lee Mac, Copyright © 2014 - [url="http://www.lee-mac.com"]www.lee-mac.com[/url] ;; ;;----------------------------------------------------------------------;; ;; Version 1.3 - 2014-07-17 ;; ;;----------------------------------------------------------------------;; ; Boundary poly added by BIGAL 28-04-2016 (defun c:a2fbp ( / *error* fmt inc ins lst sel str pt ) (setq fmt "%lu6%qf1") ;; Field Formatting (defun *error* ( msg ) (LM:endundo (LM:acdoc)) (if (not (wcmatch (strcase msg t) "*break,*cancel*,*exit*")) (princ (strcat "\nError: " msg)) ) (princ) ) [color=red](setq ins (getpoint "Pick inside pt of new boundary"))[/color] [color=red](command "-boundary" ins "") [/color] ; (if (and (setq sel (ssget '((0 . "ARC,CIRCLE,ELLIPSE,HATCH,*POLYLINE,REGION,SPLINE")))) [color=red](if (and (setq sel (ssget "L"))[/color] ; (setq ins (getpoint "\nPick point or cell for field: ")) ) (progn (if (setq tmp (ssget "_X" (list '(0 . "ACAD_TABLE") (if (= 1 (getvar 'cvport)) (cons 410 (getvar 'ctab)) '(410 . "Model") ) ) ) ) (repeat (setq idx (sslength tmp)) (setq tab (cons (vlax-ename->vla-object (ssname tmp (setq idx (1- idx)))) tab)) ) ) (if (= 1 (sslength sel)) (setq str (strcat "%<[url="file://\\AcObjProp"]\\AcObjProp[/url] Object(%<[url="file://\\_ObjId"]\\_ObjId[/url] " (LM:ObjectID (vlax-ename->vla-object (ssname sel 0))) ">%).Area [url="file://\\f"]\\f[/url] \"" fmt "\">%" ) ) (progn (repeat (setq idx (sslength sel)) (setq lst (vl-list* "%<[url="file://\\AcObjProp"]\\AcObjProp[/url] Object(%<[url="file://\\_ObjId"]\\_ObjId[/url] " (LM:ObjectID (vlax-ename->vla-object (ssname sel (setq idx (1- idx))))) ">%).Area>%" " + " lst ) ) ) (setq str (strcat "%<[url="file://\\AcExpr"]\\AcExpr[/url] " (apply 'strcat (reverse (cdr (reverse lst)))) " [url="file://\\f"]\\f[/url] \"" fmt "\">%" ) ) ) ) (LM:startundo (LM:acdoc)) (if (setq tmp (LM:getcell tab (trans ins 1 0))) (apply 'vla-settext (append tmp (list str))) (vla-addmtext (vlax-get-property (LM:acdoc) (if (= 1 (getvar 'cvport)) 'paperspace 'modelspace)) (vlax-3D-point (trans ins 1 0)) 0.0 str ) ) (LM:endundo (LM:acdoc)) ) ) (princ) ) ;; ObjectID - Lee Mac ;; Returns a string containing the ObjectID of a supplied VLA-Object ;; Compatible with 32-bit & 64-bit systems (defun LM:ObjectID ( obj ) (eval (list 'defun 'LM:ObjectID '( obj ) (if (and (vl-string-search "64" (getenv "PROCESSOR_ARCHITECTURE")) (vlax-method-applicable-p (vla-get-utility (LM:acdoc)) 'getobjectidstring) ) (list 'vla-getobjectidstring (vla-get-utility (LM:acdoc)) 'obj ':vlax-false) '(itoa (vla-get-objectid obj)) ) ) ) (LM:ObjectID obj) ) ;; Get Cell - Lee Mac ;; If the supplied point lies within a cell boundary, ;; returns a list of: (<VLA Table Object> <Row> <Col>) (defun LM:getcell ( lst pnt / dir ) (setq dir (vlax-3D-point (trans (getvar 'viewdir) 1 0)) pnt (vlax-3D-point pnt) ) (vl-some '(lambda ( tab / row col ) (if (= :vlax-true (vla-hittest tab pnt dir 'row 'col)) (list tab row col) ) ) lst ) ) ;; Start Undo - Lee Mac ;; Opens an Undo Group. (defun LM:startundo ( doc ) (LM:endundo doc) (vla-startundomark doc) ) ;; End Undo - Lee Mac ;; Closes an Undo Group. (defun LM:endundo ( doc ) (while (= 8 (logand 8 (getvar 'undoctl))) (vla-endundomark doc) ) ) ;; Active Document - Lee Mac ;; Returns the VLA Active Document Object (defun LM:acdoc nil (eval (list 'defun 'LM:acdoc 'nil (vla-get-activedocument (vlax-get-acad-object)))) (LM:acdoc) ) (vl-load-com) (princ) ;;----------------------------------------------------------------------;; ;; End of File ;; ;;----------------------------------------------------------------------;; Quote
nod684 Posted April 28, 2016 Posted April 28, 2016 see my attachment. I have closed those unclosed areas in your drawing thru hatch and recreate boundary. then you can use Lee's lisp to quickly get the areas of each lot. Quote
MOORADAN Posted April 28, 2016 Author Posted April 28, 2016 Unfortunately Lisp has some Issue when its amended... Still I am happy using Boundary AT the moment as this itself saving lots of time... Thanks to all helped and Lee Quote
MOORADAN Posted April 28, 2016 Author Posted April 28, 2016 Thats what I was using Dadgag... BUt AT Lisp... That looks good where I can find that...? Quote
Dadgad Posted April 28, 2016 Posted April 28, 2016 (edited) Thats what I was using Dadgag... BUt AT Lisp... That looks good where I can find that...? AT is the commandline entry to start Lee's lisp, once you have downloaded it to your computer, and used the LOAD command to fire it up. Sorry, the lisp I used was another one of Lee's, here is the link... http://www.lee-mac.com/arealabel.html not the one that I posted earlier. What you see in the screenshot took less than a minute to do. Watch the little video on Lee's site, and read what he says about the options available on the description of the lisp. Pay particular attention to the last paragraph Additional Features! Thanks Lee! Edited April 29, 2016 by Dadgad Quote
tmelancon Posted April 28, 2016 Posted April 28, 2016 (edited) Hey give this a shot for your areas that you wanna place inside each lot. Worked in 10 seconds for me. T 07/08 www.cadalyst.com/code ;;; Tip 2292: AreaRon.lsp Area of Closed Polylines (c) 2008 Ronald Maneja (Wizman) ;;; PRODUCES TEXT CONTAINING AREA OF SELECTED CLOSED POLYLINES ;;; AND PUTS THEM IN AREARON LAYER ;;; CREATED BY RON MANEJA 31JAN08 ;;; USER INPUTS: SCALE, POLYLINE SELECTION ;;; ;;; VERSION 1.1 (09FEB09): ADDED AREA FOR REGIONS, SPLINE, CIRCLE & ELLIPSE ;;; (defun C:AREARON (/ allx ally areaobj counter ctr el entity-name entnamevla mysset prec_temp pt reg_centroid temp tst vertex x y oldlayer oldsnap temperr traperror blpt cir_center el_center maxpt minpt spl_center trpt ) (defun set_var () (setvar 'cmdecho 0) (setq oldlayer (getvar "clayer")) (setq oldsnap (getvar "osmode")) (setq temperr *error*) (setq *error* traperror) (setvar "osmode" 0) ) (defun traperror (errmsg) (command nil nil nil) (if (not (member errmsg '("console break" "Function Cancelled")) ) (princ (strcat "\nError: " errmsg)) ) (command "_.undo" "end") (setvar "clayer" oldlayer) (setvar "osmode" oldsnap) (setvar "cmdecho" 1) (princ "\nError Resetting Enviroment ") (setq *error* temperr) ) (defun reset_var () (setq *error* temperr) (setvar "clayer" oldlayer) (setvar "osmode" oldsnap) (command "_.undo" "end") (setvar "cmdecho" 1) ) (vl-load-com) (set_var) (command "_.undo" "be") (if (tblsearch "Layer" "AREARON") (command "._layer" "_thaw" "AREARON" "_on" "AREARON" "_unlock" "AREARON" "_set" "AREARON" "") ;_ closes command (command "._layer" "_make" "AREARON" "_color" 7 "AREARON" "") ;_ closes command ) (if (null sch) (setq sch 1.0) ) (initget 6) (setq temp (getreal (strcat "\nENTER SCALE <" (rtos sch 2 2) ">: " ) ) ) (if temp (setq sch temp) (setq temp sch) ) (if (null precision) (setq precision 1) ) (initget 6) (setq prec_temp (getint (strcat "\nHOW MANY DECIMAL PLACES?: <" (rtos precision 2 2) ">: " ) ) ) (if prec_temp (setq precision prec_temp) (setq prec_temp precision) ) (prompt "\nSELECT CLOSED POLYLINES/SPLINES, REGION, CIRCLE & ELLIPSE:> ") (setq mysset (ssget '((-4 . "<or") (-4 . "<and") (0 . "LWPOLYLINE") (70 . 1) (-4 . "and>") (-4 . "<and") (0 . "SPLINE") (70 . 11) (-4 . "and>") (0 . "REGION") (0 . "CIRCLE") (0 . "ELLIPSE") (-4 . "or>") ) ) counter 0 ) (if mysset (progn (while (< counter (sslength mysset)) (setq entity-name (ssname mysset counter) EL (entget entity-name) entnamevla (vlax-ename->vla-object entity-name) areaobj (vla-get-area entnamevla) ) (cond ((eq (cdr (assoc 0 el)) "LWPOLYLINE") (progn (setq allx 0 ally 0 ctr 0 tst 1 ) (while (assoc 10 el) (setq vertex (cdr (assoc 10 el)) ctr (+ ctr 1) x (car vertex) y (cadr vertex) allx (+ allx x) ally (+ ally y) EL (cdr (member (assoc 10 el) el)) ) ) (setq x (/ allx ctr) y (/ ally ctr) pt (list x y) ) (command "text" "j" "mc" pt (* sch 2.5) "0" (rtos areaobj 2 precision) ) ) ) ((eq (cdr (assoc 0 el)) "REGION") (setq reg_centroid (vlax-safearray->list (vlax-variant-value (vla-get-centroid entnamevla) ) ) ) (command "text" "j" "mc" reg_centroid (* sch 2.5) "0" (rtos areaobj 2 precision) ) ) ((eq (cdr (assoc 0 el)) "CIRCLE") (setq cir_center (vlax-safearray->list (vlax-variant-value (vla-get-center entnamevla) ) ) ) (command "text" "j" "mc" cir_center (* sch 2.5) "0" (rtos areaobj 2 precision) ) ) ((eq (cdr (assoc 0 el)) "ELLIPSE") (setq el_center (vlax-safearray->list (vlax-variant-value (vla-get-center entnamevla) ) ) ) (command "text" "j" "mc" el_center (* sch 2.5) "0" (rtos areaobj 2 precision) ) ) ((eq (cdr (assoc 0 el)) "SPLINE") (vla-GetBoundingBox entnamevla 'minPt 'maxPt) (setq blPt (vlax-safearray->list minPt) trPt (vlax-safearray->list maxPt) ) (setq spl_center (mapcar '* '(0.5 0.5 0.5) (mapcar '+ blPt trPt)) ) (command "text" "j" "mc" spl_center (* sch 2.5) "0" (rtos areaobj 2 precision) ) ) ) (setq counter (+ counter 1)) ) ) (alert "\nNO CLOSED POLYLINES/LWPOLYLINES/SPLINES IN YOUR SELECTION" ) ) (reset_var) (princ) ) (prompt "'\n>>>...AreaRon.Lsp is now Loaded, Type 'Arearon' to start command...<<<") (princ) Edited April 28, 2016 by tmelancon 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.