Visual LISP, AutoLISP and General Customization

Visual LISP, AutoLISP and General Customization

Reply
Active Member
esallen
Posts: 6
Registered: ‎06-13-2012
Message 1 of 6 (401 Views)

Measuring Area Using Override Dimensions, Was Told To Try Here

401 Views, 5 Replies
06-13-2012 12:48 PM

Hi All,

 

I'm very new to AutoCAD, I was hired to complete a space project this summer which required basic AutoCAD knowledge. I am responsible for populating a database in which one of the fields is the area of individual rooms in a building. The instructions indicated that I was to use polylines to enclose each room / area and to find the area based on these values.

 

Earlier this year, another student was hired to confirm the measurements on building blueprints. This student took accurate measurements of each room, however instead of correcting the drawings, he simply added override text to the dimensions. Therefore the displayed dimensions are correct but my area values using polylines are inaccurate.

 

The project that I'm working on includes a number of drawings and close to 1000 rooms. I downloaded a function I found online that allows me to figure out which dimensions were overridden by boxing them in a different colour and I've found that it is a significant ammount.

 

Is there a way to use these overridden dimensions, without altering the physical nature of the drawing, to find the area of a room?

 

Any advice is greatly appreciated, otherwise I'll be forced to do each calculation by hand haha.

 

Thanks in advance

 

Too Long, Didn't Read:

Need to use polylines to calculate area of many rooms. Dimensions have been overridden and are inaccurate. Can i use the overridden dimensions without altering the physical drawing?

*Expert Elite*
Kent1Cooper
Posts: 5,294
Registered: ‎09-13-2004
Message 2 of 6 (399 Views)

Re: Measuring Area Using Override Dimensions, Was Told To Try Here

06-13-2012 01:15 PM in reply to: esallen

esallen wrote:

....

Need to use polylines to calculate area of many rooms. Dimensions have been overridden and are inaccurate. Can i use the overridden dimensions without altering the physical drawing?


I can imagine a way to do that if all the rooms are rectangles with only two dimensions.  You could presumably use the Polylines as fences for finding the appropriate Dimension entities, extract the override text content from those [or use the measured value when there's no override], convert it from text to numerical values, and multiply them together.

 

But if the rooms might have columns boxed out projecting off the walls or into the corners, curved or angled edges anywhere, or other non-rectangularities, it's kind of hard to imagine how it could be done.

Kent Cooper
*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 3 of 6 (351 Views)

Re: Measuring Area Using Override Dimensions, Was Told To Try Here

06-14-2012 12:43 PM in reply to: esallen

Try this code, sorry without good explanation

;; require rooms on layer "A-ROOM", otherwise change the layer name within the code

(defun C:ARL(/  a acsp adoc ar b clay lyr maxp midp minp mtx pl setlayer sset txth)
  
(defun *error* (msg)
      (vla-endundomark (vla-get-activedocument
              (vlax-get-acad-object))
	      )
    (cond ((or (not msg)
	       (member msg '("console break" "Function cancelled" "quit / exit abort"))
	       )
	   )
	  ((princ (strcat "\nError: " msg)))
	  )
(setvar "cmdecho" 1)
(setvar "clayer" clay) 
    (princ)
    )
  
 (defun setlayer  (adoc layername num /)
    (setq lyr (vl-catch-all-apply
		'vla-add
		(list (vla-get-layers adoc) layername)))
    (vl-catch-all-apply
      'vla-put-color
      (list lyr (if num (if (< num 255) num 0))))
    )
;;------------------------------ main part -------------------------------;;
  
(setq adoc (vla-get-activedocument
              (vlax-get-acad-object))
      acsp (vla-get-block(vla-get-activelayout adoc))) 
  (vla-startundomark adoc )
  (setq clay (getvar "clayer"))
  (setlayer adoc "A-ROOM-TEXT" 12)
  (if (setq sset (ssget "_X" (list
			       (cons 0 "lwpolyline");<-- object type
			       (cons 70 1);<-- closed polyline
			       (cons 410 (getvar "ctab"));<-- current tab
			       (cons 8 "A-ROOM");<-- desired layer, you have to change them to your suit
				     )))
  (progn
    ;; define text height
  (initget 6)
  (setq txth (getreal (strcat "\nEnter text height for label <" (rtos(getvar "dimtxt")) ">: ")))
  (cond ((not txth)(setq txth (getvar "dimtxt"))));if enter pressed, so return default
  (setvar "clayer" "A-ROOM-TEXT");<-- set text layer here, change them to your suit
  
  ;; loop thru selected closed polylines on layer "A-ROOM"
  (vlax-for plobj (vla-get-activeselectionset adoc)
    ;; get bounds of every contour
    (vla-getboundingbox plobj 'minp 'maxp)
    ;; calculate midpoint (pseudo-center)
    (setq midp (mapcar '(lambda (a b) (/ (+ a b) 2))
	   (vlax-safearray->list minp)
	  (vlax-safearray->list maxp)))
    
    (setq ar (vla-get-area plobj));<-- get area
    ;; create mtext object
    (setq mtx (vlax-invoke
		acsp
		'addmtext
		midp
		0.0
		(strcat "\\A1;Area:\\P\\C1;" (rtos ar 2 2) " m.")));<-- change color(C1;),units (2 for metric) and precision (2) here
    (vlax-put mtx 'height txth)
    (vlax-put mtx 'attachmentpoint 5)
    )
    )
    )
  
  (vla-regen adoc 0)
  (*error* nil)
  (princ)
  )
(princ "\nStart command with ARL...")
(princ)
(vl-load-com)
(princ)

 

 

~'J'~

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
*Expert Elite*
Patchy
Posts: 6,226
Registered: ‎09-16-2009
Message 4 of 6 (342 Views)

Re: Measuring Area Using Override Dimensions, Was Told To Try Here

06-14-2012 01:09 PM in reply to: Hallex

Hi Hallex,

I tried your code but it label the actual polylines of the rooms, I think the request was to use the override dimensions to calculate the area, because the person that worked on this drawing before used override dimensions and did not revise the room sizes.

Active Member
esallen
Posts: 6
Registered: ‎06-13-2012
Message 5 of 6 (336 Views)

Re: Measuring Area Using Override Dimensions, Was Told To Try Here

06-14-2012 01:15 PM in reply to: Patchy

Yes Patchy, that's correct. Thank you Hallex for your time and effort it is greatly appreciated. I'm not entirely sure if what I'm asking can even be done.

*Expert Elite*
Hallex
Posts: 1,569
Registered: ‎10-08-2008
Message 6 of 6 (334 Views)

Re: Measuring Area Using Override Dimensions, Was Told To Try Here

06-14-2012 01:17 PM in reply to: Patchy

Sorry, my bad

I didn't understand the question, so forget about

Regards,

 

~'J'~

 

 

_____________________________________
C6309D9E0751D165D0934D0621DFF27919

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community