Areas Displayed for Multiple Polylines Selected at Once

Areas Displayed for Multiple Polylines Selected at Once

reception
Explorer Explorer
3,044 Views
14 Replies
Message 1 of 15

Areas Displayed for Multiple Polylines Selected at Once

reception
Explorer
Explorer

Hi guys,

 

I really need someone to help me modify an existing LISP file (see attachment). As I need to show individual area on each enclosed polyline. The current LISP was a file I downloaded from another forum but they use 'square feet' instead of 'square meter'. Besides, I don't need a white background mask on the text. Preferably the area text would look exactly like the left image. 

Appreciate all your kind help!

 

Kind Regards

Ashley  

 

image_2022-03-14_142723.png

Accepted solutions (1)
3,045 Views
14 Replies
Replies (14)
Message 2 of 15

ВeekeeCZ
Consultant
Consultant

Possibly this 

 

(vl-load-com)

(defun c:PlArea  (/ ados acsp ss e ptList Str txt p)
  
  (setq  acsp (vla-get-modelspace (setq adoc (vla-get-activedocument (vlax-get-acad-object)))))
  (vla-startundomark adoc)
  (if (setq ss (ssget ":L" '((0 . "*POLYLINE")
			     ;(8 . "A-AREA-BDRY")
			     (-4 . "&")
			     (70 . 1)(410 . "Model"))))
    (repeat (sslength ss)
      (setq e     (ssname ss 0)
	    sum   '(0 0)
	    verts (cdr (assoc 90 (entget e))))
      (setq ptList (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget e))))
      (foreach x ptList (setq sum (mapcar '+ x sum)))
      (setq Str (strcat (rtos (vlax-curve-getarea e) 2 0) "m2"))
      (vla-put-AttachmentPoint
	(setq txt (vla-addMText
		    acsp
		    (setq p (vlax-3d-point (mapcar '/ sum (list verts verts))))
		    0
		    Str))
	acAttachmentPointMiddleCenter)
      (vla-put-InsertionPoint txt p)
      (vla-put-Height txt 2.5)
      (ssdel e ss)
      )(princ "\0 Objects found:"))
  (vla-endundomark adoc)
  (princ)
  )
0 Likes
Message 3 of 15

braudpat
Mentor
Mentor
Accepted solution

Hello @reception 

 

You can also try this beautiful routine "PolyArea_B" from Gilles (gile)

 

"PolyArea_B" runs on ARC,CIRCLE,ELLIPSE,POLYLINE 2D,SPLINE,MPOLYGON,REGION

 

The Health, Bye, Patrice (The Old French EE Froggy)

 

Patrice ( Supporting Troops ) - Autodesk Expert Elite
If you are happy with my answer please mark "Accept as Solution" and if very happy please give me a Kudos (Felicitations) - Thanks

Patrice BRAUD

EESignature


0 Likes
Message 4 of 15

Kent1Cooper
Consultant
Consultant

@ВeekeeCZ wrote:
....
      (setq Str (strcat (rtos (vlax-curve-getarea e) 2 0) "m2"))
....

You can get it in superscript [the "Squared" option in the Symbol pull-down list in the Mtext editor]:

  (setq Str (strcat (rtos (vlax-curve-getarea e) 2 0) "m\U+00B2"))

 

Kent Cooper, AIA
0 Likes
Message 5 of 15

reception
Explorer
Explorer

Brilliant! Works perfect! Thank you!

0 Likes
Message 6 of 15

reception
Explorer
Explorer
Thanks BeekeeCZ! works well on most of the polylines. Seems didn't work on some irregular shaped polylines.

0 Likes
Message 7 of 15

reception
Explorer
Explorer
Thanks for the updates!!
0 Likes
Message 8 of 15

yousef-aboelala
Observer
Observer

Please, Can you edit this code to make the area value divided by 1000 ? and thanks in advance.

0 Likes
Message 9 of 15

Kent1Cooper
Consultant
Consultant

@yousef-aboelala wrote:

Please, Can you edit this code to make the area value divided by 1000 ? and thanks in advance.


In your other post, you say your drawing unit is a millimeter and you want the area in square meters.  Would that not mean dividing by 1000000 instead?  There are 1000000 square millimeters in a square meter.

....

  (setq Str (strcat (rtos (/ (vlax-curve-getarea e) 1e6) 2 0) "m2"))

....

Change the 0 if you want decimal places in the result, not just whole square meters.

Kent Cooper, AIA
Message 10 of 15

yousef-aboelala
Observer
Observer

Yes i mean that you are right.
But i can't edit the lisp code i dont have any experience rly 🙂 can you edit it for me please ?

0 Likes
Message 11 of 15

yousef-aboelala
Observer
Observer

Perfect ! Thank you so much !

0 Likes
Message 12 of 15

Kent1Cooper
Consultant
Consultant

@yousef-aboelala wrote:

... i can't edit the lisp code .... can you edit it for me please ?


[Oops -- now I see you already did...] See my previous message, edited to include the one line that should be changed.

Kent Cooper, AIA
Message 13 of 15

pedromiguel3891
Enthusiast
Enthusiast

this is very good but can't get to change "precision 0.00 and m²"

0 Likes
Message 14 of 15

Moshe-A
Mentor
Mentor

@pedromiguel3891  hi,

 

try setting DIMZIN to 0

 

Moshe

 

 

0 Likes
Message 15 of 15

pedromiguel3891
Enthusiast
Enthusiast

@Moshe-A hey,

The problem is that within the lisp this area is sq ft. I am Portugal!

0 Likes