Kumbra Posted January 5, 2017 Posted January 5, 2017 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 Quote
Lee Mac Posted January 5, 2017 Posted January 5, 2017 This program does not require the polyline to be closed: Total Area Quote
BIGAL Posted January 6, 2017 Posted January 6, 2017 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) ) Quote
Grrr Posted January 6, 2017 Posted January 6, 2017 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) ) Quote
Lee Mac Posted January 6, 2017 Posted January 6, 2017 @Grrr/BIGAL: Be aware of the issue of querying the ActiveX Area property of a hatch object with a self-intersecting boundary Quote
Grrr Posted January 6, 2017 Posted January 6, 2017 @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). Quote
Kumbra Posted January 10, 2017 Author Posted January 10, 2017 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! Quote
Recommended Posts
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.