Jump to content

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


Recommended Posts

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

Link to comment
Share on other sites

Something I am working on at moment


; Total HATCH area labeller
(Defun C:AHAT (/ arean area2 lay col en hobj Hp num rp sset)
(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) 

Link to comment
Share on other sites

BIGAL, you inspired me to write this:

; 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>: ")))
     ((= 7 (getvar 'errno)) (princ) (setvar 'errno 0))
     ((and SH (/= "HATCH" (cdr (assoc 0 (setq enx (entget SH))))) (princ "\nThis is not a \"HATCH\".")))
         (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)

Link to comment
Share on other sites

@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). :)

Link to comment
Share on other sites

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!


Link to comment
Share on other sites

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.

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