Jump to content

Measuring area enclosed by a polyline


Butch

Recommended Posts

  • Replies 36
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    10

  • Butch

    5

  • Ringis

    3

  • dpaulku

    3

Top Posters In This Topic

Posted Images

Polylines (and most other objects) have the VL area property, so area calculation is pretty easy* in LISP - even for open polylines:

 

(defun c:oarea (/ ent Obj)
 (vl-load-com)
 (if (and (setq ent (car (entsel "\nSelect Object: ")))
          (vlax-property-available-p
            (setq Obj (vlax-ename->vla-object ent)) 'Area))
   (princ (strcat"\n<< Area: " (vl-princ-to-string
                                 (vla-get-Area Obj)) " >>")))
 (princ))

 

*not meaning to sound pretentious...

Link to comment
Share on other sites

In Autocad 2010 it's simply part of the Properties in the Geometry section. It has Area and Length. This isn't available in Autocad 2007?

2009-07-17_134139.png

Link to comment
Share on other sites

Polylines (and most other objects) have the VL area property, so area calculation is pretty easy* in LISP - even for open polylines:

 

(defun c:oarea (/ ent Obj)
 (vl-load-com)
 (if (and (setq ent (car (entsel "\nSelect Object: ")))
          (vlax-property-available-p
            (setq Obj (vlax-ename->vla-object ent)) 'Area))
   (princ (strcat"\n<< Area: " (vl-princ-to-string
                                 (vla-get-Area Obj)) " >>")))
 (princ))

 

*not meaning to sound pretentious...

 

 

Lee Mac againg great only one tiny tiny problem is that the area results stays hidden and you must scroll back on the command line to see it. Could you make it visible so you dont have to scroll? :roll:

Link to comment
Share on other sites

It should only be one line up... :huh:

 

But, if you insist:

 

(defun c:oarea (/ ent Obj)
 (vl-load-com)
 (if (and (setq ent (car (entsel "\nSelect Object: ")))
          (vlax-property-available-p
            (setq Obj (vlax-ename->vla-object ent)) 'Area))
   (alert (strcat"\n<< Area: " (vl-princ-to-string
                                 (vla-get-Area Obj)) " >>")))
 (princ))

Link to comment
Share on other sites

Lee Mac againg great only one tiny tiny problem is that the area results stays hidden and you must scroll back on the command line to see it. Could you make it visible so you dont have to scroll? :roll:

 

You could use F2 to bring up more of the command line too.

Link to comment
Share on other sites

i'VE ALWAYS BEEN A STRONG SUPPORTER OF THE OFT-FORGOTTEN LIST COMMAND.

 

 

 

Works for me too. Just type in LIST on your keyboard, and there is.....

 

Takes too long to go the other routes for an area.

 

But,....

 

the figure must be closed or you get a phoney area in units.

 

 

 

Wm.

Link to comment
Share on other sites

Hello all,

 

you are right, a simple list/properties/area command will allow verry quick access to the area information.

 

IMHO there are many cases, where this information has to displayed on the drawing permanently, therefore this simple workaround will fail.

 

There are many lisps around here, which will place a single text ore parse the area value into a block attribute.

 

Just do a quick forum search here: polyline + area + lisp shows up 59 results, there are even more here...

... room + area will show 83 results

 

Looking at the results:

 

Some of these routines only place a single text on a selected polyline, others will work a bunch of given polylines.

 

Other routines work with fields, ore reactors; the advantage: if the polyline changes, the value will be automaticly updated.

 

And last but not least, there are some great lisps around here, which place the area information into a block attribute.

 

This is for me personaly the best way to deal with informations, because I am now able to work with this values.

(In my work, I do floor plans/office layouts and the area is allows an importand information)

 

For a beginner, it might be hard stuff understanding the block concept and all around data extraction, but compared to autocad R12 for DOS...

...It is nowadays verry easy :lol:

 

Just to tell it again: a quick forum search will fire up some great tools

 

regards

Wolfgang

Link to comment
Share on other sites

Something like this?

 

(defun c:oarea (/ ss lst)
 (vl-load-com)
 (if (setq ss (ssget))
   (progn
     (vlax-for Obj
       (vla-get-ActiveSelectionSet
         (vla-get-ActiveDocument
           (vlax-get-acad-object)))
       (if (vlax-property-available-p Obj 'Area)
         (setq lst (cons (vla-get-Area Obj) lst))))
     (if lst
       (alert
         (strcat"\n<< Area: " (rtos (apply '+ lst)) " >>")))))
 (princ))

Link to comment
Share on other sites

  • 6 months later...

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