Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Revise this List Routine so it contains SF and Acres?

8 REPLIES 8
Reply
Message 1 of 9
afengP5L99
464 Views, 8 Replies

Revise this List Routine so it contains SF and Acres?

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!

afengP5L99_0-1696963850377.png

 

Tags (1)
Labels (5)
8 REPLIES 8
Message 2 of 9
Kent1Cooper
in reply to: afengP5L99

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].

Kent Cooper, AIA
Message 3 of 9
pendean
in reply to: Kent1Cooper

@Kent1Cooper AREAM from @JTBWorld is just on endless repeat until ESC is triggered, neutral on units AFAIK.

@afengP5L99 You actually want a FIELD or at least a label of some sort too? Not use a one-off commandline blurb that vanishes.
Message 4 of 9
komondormrex
in reply to: afengP5L99

and what units do you currently have?

Message 5 of 9
afengP5L99
in reply to: Kent1Cooper

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.

 

Message 6 of 9
afengP5L99
in reply to: pendean

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.

Message 7 of 9
komondormrex
in reply to: afengP5L99

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

 

 

Message 8 of 9
Kent1Cooper
in reply to: afengP5L99

Try the attached AreaFAP.lspFAP 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.

Kent Cooper, AIA
Message 9 of 9
Kent1Cooper
in reply to: afengP5L99


@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.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report