Requested a lisp for total area of polygon in table with their layerwise.

Requested a lisp for total area of polygon in table with their layerwise.

paliwal222
Advocate Advocate
5,220 Views
14 Replies
Message 1 of 15

Requested a lisp for total area of polygon in table with their layerwise.

paliwal222
Advocate
Advocate

Dear all,

requested a lisp of Total Area of various polygon by layerwise in a table in drawing.

OR customization in lisp, or suggest me any link please.

i have loading lisp file that mark area of per polygon in drawing. Drawing also attached.

Thanks.

 

0 Likes
Accepted solutions (2)
5,221 Views
14 Replies
Replies (14)
Message 2 of 15

Sea-Haven
Mentor
Mentor

There was a similar post request maybe 2 weeks ago trying to find, may have been on another forum.

 

Do a google.

Message 3 of 15

paliwal222
Advocate
Advocate

Sir, Thanks for so quick respond.

i load the lisp, but i found this error given below

 

(LOAD "C:/Users/USER/Desktop/Area by layer in table.lsp") c:ad
Command: AD
Usage: (acad_strlsort <list of strings>)
nil

Link:

https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/help-adding-total-area-of-polylines-...

 

 

0 Likes
Message 4 of 15

pbejse
Mentor
Mentor

What is the basis for the column "number"? 

pbejse_1-1649998590767.png

 

 

 

Message 5 of 15

paliwal222
Advocate
Advocate

 it is to be just serial number.

or if may be possible, total number of polygon or closed polylines, per layer

but it is not necessary. 

serial number also not necessary.

0 Likes
Message 6 of 15

paliwal222
Advocate
Advocate

I have found a lisp in forum, but its show hatched area. I want just close polyline area in table.

0 Likes
Message 7 of 15

pbejse
Mentor
Mentor

Please pick one among all the options you posted @paliwal222 and get back to us.

 

Message 8 of 15

paliwal222
Advocate
Advocate

ok sir,

here i attached the new lisp and autocad file.

now there is no of item per layer and their area.

take a look please

please, modify the attached list to (hatched area layerwise ---- changed in polygon area layerwise in table.)

thanks.

0 Likes
Message 9 of 15

pbejse
Mentor
Mentor

@paliwal222 wrote:

ok sir,

here i attached the new lisp and autocad file.

now there is no of item per layer and their area. <-- 


I'm guessing that means number and not the word NO.

 

(defun c:AreaByLayerWise ( / mysset  e i data  allData   basepoint SupportDrawingTable)
;;;		pBe : Apr 2022			;;;
(if (and
      (setq mysset  (ssget '((0 . "POLYLINE,LWPOLYLINE") (-4 . "&") (70 . 1))))
      (setq basepoint (getpoint "\nPick point for Table:"))
      )
    (progn
	    (repeat (setq i (sslength mysset))
	      (setq e (vlax-ename->vla-object (ssname mysset (setq i (1- i))))
		    data (mapcar '(lambda (p)
				    (vlax-get e p)) '("Layer" "Area")))
	      (setq allData 			      
	      		(if (setq f (assoc (car data) AllData))
			  	(subst (list (car f)(+ (Cadr f)(cadr data))(1+ (caddr f))) f allData)
				(cons (list (car data)(Cadr data) 1)  allData))
	      	)
	      )
        (setq allData (vl-sort allData '(lambda (a b )
				  (cond
				    ((> (caddr a)(caddr b)))
				    ((= (caddr a)(caddr b))(> (cadr a)(cadr b)))))))
	(setq SupportDrawingTable
		       (vlax-invoke
			 (vlax-get (vla-get-ActiveLayout
				     (vla-get-ActiveDocument
				       (vlax-get-acad-object)
				     )
				   )
				   'Block
			 ) 'Addtable basepoint  2 3 25.0 100.0
		     )
		)
      (vla-put-regeneratetablesuppressed SupportDrawingTable :vlax-true)
      (vla-settext SupportDrawingTable 0 0 "Area Table")
      (vla-setcelltextheight SupportDrawingTable 0 0 10.0)      
      (mapcar '(lambda (y)
	  	(vla-settext SupportDrawingTable 1 (car y) (cadr y))
	  	(vla-setcelltextheight SupportDrawingTable 1 (car y) 10.0)
                       )
		 '((0 "Layer")(1 "Number")(2 "Total Area"))
		)
      (vla-InsertRowsAndInherit SupportDrawingTable 2 1 (length allData))      
       (setq row 1)
                (while (setq a (car allData))
                      (vla-settext SupportDrawingTable (setq row (1+ row)) 0 (car a))
		      (vla-settext SupportDrawingTable row 1 (caddr a))
                      (vla-settext SupportDrawingTable row 2 (rtos (* 0.00694 (cadr a)) 2 2))
                      (setq allData (cdr allData))
                      )
      
      (vla-put-regeneratetablesuppressed SupportDrawingTable :vlax-false)
      )
    )
(princ)      
    )

 

HTH

 

Message 10 of 15

paliwal222
Advocate
Advocate

Dear sir thanks. its not so argent.

i try the given lisp but its not working and give message below and its also result a empty table with none of text

 

Command: AREABYLAYERWISE
Select objects: Specify opposite corner: 17 found
Select objects:
Pick point for Table:; error: bad argument type: numberp: nil

 

After restart pc, its same problem.

is there some mistake by me?

But overall 

"Area of Each hatch by layerwise in table areatable.LSP" is enough for me for my needs at now.

Thanks a lot for so much responding.

ok

0 Likes
Message 11 of 15

pbejse
Mentor
Mentor
Accepted solution

@paliwal222 wrote:

After restart pc, its same problem.

is there some mistake by me?


 

Not your fault at all @paliwal222 

for some strange reason this 0.006944444 became this 0.xxx-xxxxxxxx

 

Try copying the code again, otherwise, download the attached lisp file

HTH

 

Message 12 of 15

paliwal222
Advocate
Advocate

Dear Sir, 

Thanks a lot.

its work properly.

😊😊😊

0 Likes
Message 13 of 15

paliwal222
Advocate
Advocate

Dear, Sir Patrick,
Thanks again for providing me the code,

but this time I am little greedy

I have the drawing in meter

and also want to area table in meter.(input 1 = 1.000 meter here in this drawing)
I am try to convert the area multiply by 144 but its not give me accurate result

it's a very humble request from me, if code change in sq. meter and also 0.0000 precision
or send me which line i have to change.

thanks again so much.

0 Likes
Message 14 of 15

pbejse
Mentor
Mentor
Accepted solution

@paliwal222 wrote:

...and also want to area table in meter.(input 1 = 1.000 meter here in this drawing)


You should use the system variable Measurement  to determine if the drawing is metric or imperial

(setq factor (if (zerop (getvar 'Measurement)) 0.00694444 1.00))

and use the value here as multiplier

(vla-settext SupportDrawingTable row 2 (rtos (* factor (cadr a)) 2))

Also use Luprec system variable to determine the decimals

350.0000

 

HTH

 

Message 15 of 15

paliwal222
Advocate
Advocate

OK sir,

Thanks a lot.

😊😊😊

0 Likes