Lisp to Sum Areas

Lisp to Sum Areas

bemmer7MZ3G
Contributor Contributor
1,812 Views
1 Reply
Message 1 of 2

Lisp to Sum Areas

bemmer7MZ3G
Contributor
Contributor

I have a lisp that works well that allows me to select the areas I want and it calculates the area and adds them together. The only issue I have is I am trying to keep the boundaries so I can see what I have already selected then delete them after the loop is done. I have not been quite able to figure it out. I have attached the .lsp and an example file of what I am working with. I am using it to find the area of the face of these panels.

0 Likes
Accepted solutions (1)
1,813 Views
1 Reply
Reply (1)
Message 2 of 2

Kent1Cooper
Consultant
Consultant
Accepted solution

Try this adjustment [untested]:
....

  (setq new-poly (entlast)) ; Get the newly created boundary

  (redraw new-poly 3); highlight

  (setq polyList (cons new-poly polyList)) ; Add current boundary to list
  (setq obj (vlax-ename->vla-object new-poly)) ; Turn boundary to vla object for area
  (setq area1 (vla-get-area obj)) ; Find area of boundary
  (princ (strcat "\nArea added: " (rtos area1 2 2)))
  (setq total-area (+ total-area area1))
  (setq n (1+ n)) ; Increment the Counter [never used for anything, by the way]
)

(foreach poly polyList (command "Erase" poly ""))

....

Kent Cooper, AIA
0 Likes