Right now this just displays the area in the command bar. I want it to list the unit of the area in SF and in Acre. I want it to say Area = ____ SF, ___ AC, Length = _____ FT
Thank you!
For a single object as it appears to do in your image? [If that's a result from your command, it looks like you interrupted it before it could display its total area report. But I'm confused -- command echoing is supposed to be turned off, so it shouldn't be reporting even what shows. Is that actually from your command?] Or for multiple objects collectively?
Also, what shows in the image is what AREA reports for an open-ended object. [For a closed Polyline/Ellipse/Spline/Region, it says "Perimeter" rather than "Length," and for a Circle, "Circumference."] Is there any meaning to the area of an open-ended object? Should the selection restrict itself to closed ones only?
And finally: Is your drawing unit a foot?
EDIT: Is AreaM the command name you really want? It looks like something intended for Meters, but maybe the M is for Multiple, so since you clearly don't want Meters, and since it's for more than just Area, and whether or not you want Multiple objects, suggest a different name [or I'll suggest one if I work something up].
I want it to include all objects selected, closed or not. And yes, unit drawing is in feet. AreaM is for Area Multiples! The purpose is to select multiple areas to calculate total pervious/impervious areas of a site after drawing in the areas with polylines.
I don't need a label. A pop up field would be nice, or if it just stays in command bar like it does now i'm fine with too.
in command line
(defun c:area_length (/ total_area total_length sset pattern)
(setq total_area 0
total_length 0
)
(if (setq sset (ssget '((0 . "polyline,lwpolyline,circle,ellipse,spline,region"))))
(foreach curve (mapcar 'vlax-ename->vla-object (vl-remove-if 'listp (mapcar 'cadr (ssnamex sset))))
(setq total_area (+ total_area (vla-get-area curve))
pattern (strcat "*" (vla-get-objectname curve) "*")
total_length (+ total_length (cond
((wcmatch "AcDb2dPolylineAcDbPolyline" pattern)
(vla-get-length curve)
)
((wcmatch "AcDbCircle" pattern)
(vla-get-circumference curve)
)
((wcmatch "AcDbEllipseAcDbSpline" pattern)
(vlax-curve-getdistatparam curve (vlax-curve-getendparam curve))
)
((wcmatch "AcDbRegion" pattern)
(vla-get-perimeter curve)
)
(t)
)
)
)
)
)
(princ "\nArea = ")
(princ total_area)
(princ " SF, ")
(princ (cvunit total_area "square feet" "acres"))
(princ " AC, ")
(princ "Length = ")
(princ total_length)
(princ " FT")
(princ)
)
Try the attached AreaFAP.lsp. FAP stands for [square] Feet+Acres+Perimeter. I worked it up for closed objects only before seeing your latest message, but that part is easily removed. But I still question what it would mean to take the area of an open Polyline/Spline/Ellipse -- the area it represents is as if a straight-line closure was there, but surely that's not always going to be valid. If you allow non-closed objects, should Arcs be included? [The AREA command doesn't accept them, though they do have an Area property in both VLA-object and (getpropertyvalue) approaches.]
It includes total Perimeter since that was part of the routine you asked about revising, though it looks like maybe you don't need that part.
@afengP5L99 wrote:
... The purpose is to select multiple areas to calculate total pervious/impervious areas of a site after drawing in the areas with polylines.
If that's all you need, and not the total perimeter also as in the routine you requested revision of, and if you're willing to hit Enter twice when you're done picking things [it will prompt you with "Specify first corner point or [Object/Subtract area]:" after the first Enter], try this:
(defun C:AreaFA (); total Area in sq. Feet & Acres
(command-s "_.area" "_add" "_object")
(prompt
(strcat ; numbers in decimal units under current precision setting
"\nTotal Area = "
(rtos (getvar 'area) 2) " SF, "
(rtos (/ (getvar 'area) 43560) 2) " AC."
); strcat
); prompt
(prin1)
)
Aside from being so much shorter, using that AREA / Add / Object command/option combination means that it colors in the areas as you pick them, so you can really see what you're getting.
Can't find what you're looking for? Ask the community or share your knowledge.