+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 15
  1. #1
    Forum Newbie
    Using
    AutoCAD 2007
    Join Date
    Sep 2012
    Posts
    7

    Default AutoLisp For Area Calculation

    Registered forum members do not see this ad.

    Hi All, I need some help here.

    I'v been using a autolisp (obtained from a friend) to calculate floor area with AutoCAD 2007. However recently I've upgraded my AutoCAD to 2013 and I realised the lisp coudn't function completely.

    I've attached the lisp file here, really hope someone can help to rectify so that it works for AutoCAD 2013. Fyi I knows nothing about writting lisp code... many thanks in advance! (not sure why this code looks so massive compared to others..)

    To share with those who may be interested, this lisp allows you to select multiple polylines (eg. floor area), followed by select those polylines representing regions to be subtracted (eg. void area), it will help you tabulate all the polyline parcels (floor areas subtract floor void) with end result and with labels for each parcel.

    Enjoy!
    Attached Files

  2. #2
    Full Member wishbonesr's Avatar
    Computer Details
    wishbonesr's Computer Details
    Operating System:
    7
    Computer:
    Dell T3500
    CPU:
    Quad Core Xeon
    RAM:
    16GB
    Graphics:
    Quadro FX 2000
    Monitor:
    Tri 22" Dells
    Using
    AutoCAD 2012
    Join Date
    Nov 2005
    Location
    Texas
    Posts
    31

    Default

    Writes a file to the c:\ Modern Windoze OS's tend restrict writing at this level. There's a lot that could be updated with this program, and I don't know where to start.

    I could be wrong, but it appears that Gildred (the author) intended the software to stop functioning in in the year 12084 month 93 day 11, and to contact him then for an update. I had a good laugh.

    Code:
    (ALERT"\Pls. Contact Gildred for update of this program.")
    Almost all variables start with 'AT'.... Not to mention it looks decompiled as it resides on 5 lines is probably more suited for 500. Knowing this, I'd be shy to even download the code, not knowing it's copyright.

    That being said, the write location is probably the problem, and you'd probably be able to search and edit the file yourself to point to a writable location.

    Here are some alternatives that may help.
    http://www.cadtutor.net/forum/showth...al-point/page3

    http://www.lee-mac.com/areastofield.html
    http://www.lee-mac.com/totallengthandarea.html
    http://www.lee-mac.com/arealabel.html
    http://www.lee-mac.com/areafieldtoattribute.html

  3. #3
    Full Member cadplayer's Avatar
    Computer Details
    cadplayer's Computer Details
    Operating System:
    Windows 7
    CPU:
    Intel Core CPU 3.4 GHz, 64bit system
    RAM:
    16GB RAM
    Graphics:
    NVIDIA GeForce GTX 400
    Using
    Civil 3D 2012
    Join Date
    May 2011
    Posts
    40

    Default

    If you only calculate area of Polylines you can use my code.
    It display area of all Polylines seperate after layer.

    I´m very thankfully for all feedbacks to can do it better.
    For example I´m missing a request if Polyline is closed or not

    Code:
    ; question or ideas to my program
    ; contact me cadplayer@gmail.com!
    
    (defun c:sa ( /
                   i    ; increment
                   en   ; entity
                   lay  ; assoclist (entity . layer)
                   layEn ; collect of lay
                   layL ; used layer from picked areas
                   ar   ; area from hatch
                   arl  ; total area result
                   )
      (setvar "CMDECHO" 0)
      (setq arl 0)
      (prompt (strcat "\nTool to calculate area from polylines" "\nSelect polylines! "))
      (if (/= (setq ss (ssget '((0 . "*POLYLINE")))) nil)
        (progn
          (setq i 0)
          (repeat (sslength ss)
            (setq en (cdr (assoc -1 (entget (ssname ss i)))))
            (setq lay (cons en (cdr (assoc 8 (entget en)))))
            (setq layEn (cons lay layEn))
            (cond
              ((/= en nil)
               (setq ar (_areaOfObject en))
               (setq arl (+ ar arl))
               )
              )
            (setq i (1+ i))
            )
          (princ (strcat "\n\n>>>> Total of all area: " (rtos arl 2 2)))
          (princ)
          (setq arl 0)
          )
        )
      (if (setq layL (_RemoveDuplicates (mapcar 'cdr layEn)))
        (repeat (length layL)
          (progn
            (foreach N layEn
              (if (= (cdr N) (car layL))
                (progn
                  (setq ar (_areaOfObject (car N)))
                  (setq arl (+ ar arl))
                  (command "_layer" "_m" (cdr N) "")
                  (command "_hatch" "ansi31" 0.1 0 "_s" (car N) "")
                  )
                )
              )
            (princ (strcat "\n\nLayer: " (car layL) "\nTotal area: " (rtos arl 2 2)))
            (princ)
            )
          (setq layL (cdr layL))
          (setq arl 0)
          )
        )
      (princ)
      )
    
    ; calculate area of object
    (defun _areaOfObject (en / curve area)
      (setq curve (vlax-ename->vla-object en))
      (if
        (vl-catch-all-error-p
          (setq
            area
             (vl-catch-all-apply 'vlax-curve-getArea (list curve))
            )
          )
        nil
        area
        )
      (progn
        (command "._area" "_O" en)
        (getvar "area")
        )
      )
    
    ; Erase duplicates in list
    (defun _RemoveDuplicates ( lst / foo index )
        (defun foo (x)
            (cond
                ((vl-position x index))
                ((null (setq index (cons x index))))
            )
        )
        (vl-remove-if
           'foo
            lst
        )
      )

  4. #4
    Forum Newbie
    Using
    AutoCAD 2007
    Join Date
    Sep 2012
    Posts
    7

    Default

    Hi Wishbonesr and cadplayer, thanks for your comments and help.

    I've seen some of those links before, esp. from Lee Mac. They are awesome.

    However I need the end result to be in this specific format as it is for submission purpose. If you try using the autolisp that i attached earlier, you can find out the type of format I am looking at. Some experts out there pls help~

    Here's a more detail description of the autolisp function..

    Situation: You have a number of big closed polylines (Floor Areas). Within each of these Green Areas there is a few small closed polylines (Void Areas).

    Function of the autolisp:
    - it will first ask you specify scale of drawing (eg. you key in 50, 100 or 200 etc, it'll adjust the text size accordingly).
    - Select Floor Areas (you select the big closed polylines)
    - Any Void Areas? (eg. Yes)
    - Select Void Areas (you select the small closed polylines)
    - Pick insertion point for tabulation (you pick a point on empty space)
    ** The end result tabulation is as per shown in the screen shot below. It will also gives a label (eg. A, B, C...) and the area figure inside each polyline area.

    The above will help save a lot of time as without this lisp we'll have to do all the above manually... and repeatedly.

    Click image for larger version

Name:	area tabulation.jpg
Views:	859
Size:	21.9 KB
ID:	37347

    EXperts out there your big help is greatly appreciated. Thank you!
    Attached Images

  5. #5
    Full Member wishbonesr's Avatar
    Computer Details
    wishbonesr's Computer Details
    Operating System:
    7
    Computer:
    Dell T3500
    CPU:
    Quad Core Xeon
    RAM:
    16GB
    Graphics:
    Quadro FX 2000
    Monitor:
    Tri 22" Dells
    Using
    AutoCAD 2012
    Join Date
    Nov 2005
    Location
    Texas
    Posts
    31

    Default

    Spoke with my old man about this one. He told me that it was kinda common for some lispers (pre vlisp-compile days)to run a program on their routines to make it incredibly difficult to modify or debug. They then keep a copy of the original. He called it, "one form of job security".
    With that being learned, I decided to look harder, and had to stop myself when I started to optimize.

    I will say up front, that I make no claim to any portion of this code, and that all credit goes to Gildred.

    Went so far as to mask all functions with a prefix, just in case of conflict; And nested as many as I could without seriously modifying. The problem, was in fact the write location for the temporary files it uses. It has been fixed, and should work on any system.

    I was off on the number of lines this program should have been. Wound up being 940 without comments.

    Tested ATAB only.
    Attached Files

  6. #6
    Super Member Raggi_Thor's Avatar
    Using
    AutoCAD 2008
    Join Date
    Aug 2007
    Location
    Trondheim, NORWAY
    Posts
    718

    Default

    Seems like there is a problem with apostrophes ( " ) in this file, it won't load.
    Last edited by Raggi_Thor; 1st Oct 2012 at 02:59 pm.
    Mvh, Kvedja, Kind Regards,
    Ragnar Thor Mikkelsen
    http://www.DESIGNDATA.no/English.htm

  7. #7
    Forum Newbie
    Using
    AutoCAD 2007
    Join Date
    Sep 2012
    Posts
    7

    Default

    Wishbonesr....... you saved my life!!!!!!

    It works fine in AutoCAD 2013! Thank you SO MUCH!!!!!!!!!!!!!!!!!!

  8. #8
    Forum Newbie
    Using
    Civil 3D 2012
    Join Date
    Feb 2013
    Posts
    1

    Default

    How do I get this ATAB.lsp to dispaly S.F. and Acres? it displays sq.m.

  9. #9
    Forum Newbie
    Using
    AutoCAD 2013
    Join Date
    Apr 2014
    Posts
    1

    Default

    thanks that's what i looking for!!!

  10. #10
    Forum Newbie
    Using
    AutoCAD 2015
    Join Date
    Nov 2016
    Posts
    1

    Default

    Registered forum members do not see this ad.

    Greetings,

    The routine ATAB.lsp is awesome.
    Just one question:
    How can I set up a default text size for the measured area values?

Similar Threads

  1. multiple object area calculation in autocad 2009
    By sushant in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 2
    Last Post: 16th May 2012, 05:08 pm
  2. Help with AREA calculation and Label - also changing area units
    By camperoh in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 11th Jan 2011, 06:04 pm
  3. Area calculation for region...
    By Hunter in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 9th Feb 2009, 02:14 pm
  4. Calculation of Area and Length
    By vipulgos in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 19th Nov 2008, 04:01 pm
  5. multiple object area calculation properties
    By cldryden in forum AutoCAD Drawing Management & Output
    Replies: 1
    Last Post: 21st Nov 2006, 11:36 pm

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts