+ Reply to Thread
Results 1 to 7 of 7
  1. #1
    Forum Newbie
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2013
    Join Date
    Jan 2017
    Location
    Bosnia and Herzegovina
    Posts
    2

    Default Looking for Lsp which can calculate sum of polygon and closed polyline area?

    Registered forum members do not see this ad.

    First of me, Hi to everyone! Glad to be part of this.
    I am pretty new to this forum so as to AutoCad software, I am GIS maniac.

    Currently working on some urban plan and my company need to calculate area of existing polygons, hatches and polylines. A lot of people worked on same project and that is why we have different types of geometry.
    I can manually change all of this to closed polylines but there is over 2000 polygons and hatches.
    Is there any lsp which can calculate all types of geometry? I tried many but they are just calculating closed polylines.

    Thank you very much and sorry for bad english

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,360

    Default

    This program does not require the polyline to be closed: Total Area
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Luminous Being
    Using
    Civil 3D 2016
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    9,882

    Default

    Something I am working on at moment

    Code:
    ; Total HATCH area labeller
    (Defun C:AHAT (/ arean area2 lay col en hobj Hp num rp sset)
    (setq Hp (ENTGET (CAR (ENTSEL "\nPICK HATCH "))))
    (SETQ LAY (CDR (ASSOC 8 HP)))
    (setq sset (ssget  (list (cons 0 "hatch") (CONS 8 LAY))))
    (setq arean 0)
    (setq area2 0)
    (REPEAT (setq num (sslength sset))
    (setq en (ssname sset (setq num (- num 1))))
    (SETQ COL (CDR (ASSOC 62 (entget EN)))) ; by layer check
    (SETQ ARNEW (vla-get-area (vlax-ename->vla-object en)))
    (IF (= COL NIL) 
    (setq AREAN (+ AREAN ARNEW))
    (SETQ AREA2 (+ AREA2 ARNEW))
    )
    )
    (ALERT (STRCAT "AREA IS ..." (RTOS AREAN 2 2)"\N\NAREA2 IS ..." (RTOS AREA2 2 2)))
    (princ)
    )
    A man who never made mistakes never made anything

  4. #4
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,157

    Default

    BIGAL, you inspired me to write this:
    Code:
    ; Total area of hatches with certain pattern
    (defun C:test ( / SH enx SS i Lst )
      (setvar 'errno 0)
      (while (/= 52 (getvar 'errno))
        (setq SH (car (entsel "\nSelect source hatch pattern to filter by <exit>: ")))
        (cond
          ((= 7 (getvar 'errno)) (princ) (setvar 'errno 0))
          ((and SH (/= "HATCH" (cdr (assoc 0 (setq enx (entget SH))))) (princ "\nThis is not a \"HATCH\".")))
          (
            (and
              SH
              (princ (strcat "\nSelect hatches with \"" (cdr (assoc 2 enx)) "\" pattern to sum their area: "))
              (setq SS (ssget (list (assoc 0 enx) (assoc 2 enx))))
              (repeat (setq i (sslength SS))
                (setq Lst (cons (vla-get-Area (vlax-ename->vla-object (ssname SS (setq i (1- i))))) Lst))
              )
              (not (alert (strcat "\nTotal area of the hatch with \"" (cdr (assoc 2 enx)) "\" pattern is: " (rtos (apply '+ Lst) 2 2) " units.")))
            )
            (setvar 'errno 52)
          )
        )
      )
      (princ)
    )

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,360

    Default

    @Grrr/BIGAL: Be aware of the issue of querying the ActiveX Area property of a hatch object with a self-intersecting boundary
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  6. #6
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,157

    Default

    Quote Originally Posted by Lee Mac View Post
    @Grrr/BIGAL: Be aware of the issue of querying the ActiveX Area property of a hatch object with a self-intersecting boundary
    Oh right, I didn't considered this scenario!
    Leaving my inspiration as a concept (thankfuly I don't need to use it for real).

  7. #7
    Forum Newbie
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2013
    Join Date
    Jan 2017
    Location
    Bosnia and Herzegovina
    Posts
    2

    Default

    Registered forum members do not see this ad.

    Thank you.
    I have not expected this kind of help. With this lisp-s and little editing of some,I managed to get total area. I do not have many experience of making codes but I edited code of Princ(or Grr and get results with different lsp for mpolygons,then different for hatches and then for polylines.
    Anyway thank you very much!
    Kumbra!

Similar Threads

  1. No Area Value for Polyline / closed polygon
    By dal-designs in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 10
    Last Post: 13th Jul 2016, 09:15 pm
  2. Closed Polyline Area by Layer
    By memphis710 in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 3rd Mar 2013, 08:59 pm
  3. calculate 3D polyline area
    By bepcec in forum AutoCAD Beginners' Area
    Replies: 8
    Last Post: 30th Nov 2011, 04:45 pm
  4. Area & Volume of closed polyline
    By noyjoreb in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 14th Nov 2010, 12:50 am
  5. Area value from a closed polyline in to the clipboard?
    By tclaudiu in forum AutoLISP, Visual LISP & DCL
    Replies: 11
    Last Post: 28th Aug 2009, 10:04 am

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