Jump to content
Kumbra

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

Recommended Posts

Kumbra

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

Share this post


Link to post
Share on other sites
Lee Mac

This program does not require the polyline to be closed: Total Area

Share this post


Link to post
Share on other sites
BIGAL

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

Share this post


Link to post
Share on other sites
Grrr

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>: ")))
   (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)
)

Share this post


Link to post
Share on other sites
Lee Mac

@Grrr/BIGAL: Be aware of the issue of querying the ActiveX Area property of a hatch object with a self-intersecting boundary ;)

Share this post


Link to post
Share on other sites
Grrr
@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). :)

Share this post


Link to post
Share on other sites
Kumbra

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!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×