Lets start with the first part.
Creating a selection set of closed polylines and getting the areas and totaling them.
This code returns them as a list.
P=
Code:
;___________________________________________________________________________________________________________|
;
; Written By: Peter Jamtgaard copyright 2023 All Rights Reserved
;___________________________________________________________________________________________________________|
;
; Abstract: This routine allows the user to select closed polylines and return a list of individual areas
; and the total area of the selection set.
;___________________________________________________________________________________________________________|
;___________________________________________________________________________________________________________|
;
; Comand line function list
;___________________________________________________________________________________________________________|
;* C:PA
;* Command Line function to add up areas of selected closed polylines
;* C:PolylineAreas
;* Command Line function to add up areas of selected closed polylines
;___________________________________________________________________________________________________________|
;
; General Function Header List
;___________________________________________________________________________________________________________|
; Function List Argument1 Argument2 Arguement3
;* (PolylineAreas ssSelections)
;* Function to convert a selection set of closed polylines to a list of areas with total area
;* (SelectionSetToList ssSelections)
;* Function to convert a entity based selection set to a list.
;$ End Header
;___________________________________________________________________________________________________________
;
; Command Line function to add up areas of selected closed polylines
;___________________________________________________________________________________________________________
(defun C:PA ()(C:PolylineAreas))
(defun C:PolylineAreas (/ ssSelections)
(if (and (princ "\nSelect Closed Polylines: ")
(setq ssSelections (ssget (list (cons 0 "polyline")(cons 66 1))))
)
(PolylineAreas ssSelections)
)
)
;___________________________________________________________________________________________________________
;
; Function to convert a selection set of closed polylines to a list of areas with total area
;___________________________________________________________________________________________________________
(defun PolylineAreas (ssSelections / lstAreas lstObjects sngArea )
(if (and (setq lstObjects (SelectionSetToList ssSelections))
(setq lstAreas (mapcar 'vla-get-area lstObjects))
(setq sngArea (apply '+ lstAreas))
)
(reverse (cons sngArea (reverse lstAreas)))
)
)
;___________________________________________________________________________________________________________
;
; Function to convert a entity based selection set to a list.
;___________________________________________________________________________________________________________
(defun SelectionSetToList (ssSelections / entSelection intCount lstObjects objSelection )
(repeat (setq intCount (sslength ssSelections))
(and (setq intCount (1- intCount))
(setq entSelection (ssname ssSelections intCount))
(setq objSelection (vlax-ename->vla-object entSelection))
(setq lstObjects (cons objSelection lstObjects))
)
)
lstObjects
)
(princ "!")
(vl-load-com)