table of areas of multiple polyline with label (get it from the drawing)

table of areas of multiple polyline with label (get it from the drawing)

Anonymous
Not applicable
9,000 Views
14 Replies
Message 1 of 15

table of areas of multiple polyline with label (get it from the drawing)

Anonymous
Not applicable

Hi All

Is it possible to create a table of areas of multiple closed polyline with label (not creating label but get it from the drawing)?

 

I have multiple closed polylines and texts (label) which located inside of each polyline.

I need to create a table to show label and area.

 

I use to use  AreaLabelV1-9.lsp ( http://lee-mac.com/arealabel.html ) and now  use AC_AREA-CALC_v2.1.lsp  ( http://cadtips.cadalyst.com/tables/summarize-object-areas  )

 

The only function I would like to see is getting text located inside polyline and add as label in the table.

 

I think that is possible to do it with wps.lisp  ( http://www.cadforum.cz/cadforum_en/qaID.asp?tip=5697 ) which detect object inside of closed polyline.

 

Assume, all label texts will be locate inside polyline and there is no text touches or overlaps the polyline)

 

Area Table

Room Name

Area (Sq.Ft.)

Room A

300.56

Washroom

100.68

 

You can access all files at https://app.box.com/AreaTable

 

Thank you for reading this and I would appreciate for any responds.

0 Likes
9,001 Views
14 Replies
Replies (14)
Message 2 of 15

Ajilal.Vijayan
Advisor
Advisor

Hi,

try with this (quick & dirty)

 

Spoiler
;;; Poly-Pts (gile)
;;; Returns the vertices list of any type of polyline (WCS coordinates)
;;;
;;; Argument
;;; pl : a polyline (ename or vla-object)
;;;_gile
;;;http://forums.augi.com/showthread.php?83935-Creating-a-list-Polyline-vertices
(defun Poly-Pts	(pl / pa pt lst)
  (vl-load-com)
  (setq	pa (if (vlax-curve-IsClosed pl)
	     (vlax-curve-getEndParam pl)
	     (+ (vlax-curve-getEndParam pl) 1)
	   )
  )
  (while (setq pt (vlax-curve-getPointAtParam pl (setq pa (- pa 1))))
    (setq lst (cons pt lst))
  )
)

(defun c:roomtable ( / AllSlctn pobj pobjArea pobjPoints RoomText RoomTextObj pnt loc cnt)
(setq AllSlctn (ssget  '((0 . "LWPOLYLINE"))))
(if AllSlctn
(progn

(setq pnt (getpoint "\nPick the point for table: "))
(setq loc  (vla-get-modelspace(vla-get-activedocument(vlax-get-acad-object))))
(setq table (vla-AddTable loc (vlax-3d-point pnt) 2 2 1 5))
	    (vla-settext table 0 0 "Area Table")
            (vla-settext table 1 0 "Room Label")
            (vla-settext table 1 1 "Area")
(setq cnt 0)			
(repeat (sslength AllSlctn)
	(setq pobj (ssname AllSlctn cnt))
	(setq vlpobj (vlax-ename->vla-object pobj))
	(setq pobjArea (vla-get-area vlpobj))
	(setq pobjPoints (Poly-Pts pobj))
;Select text with Layer name "Layer2" (setq RoomTextObj (ssget "_WP" pobjPoints '((0 . "TEXT")(8 . "Layer2")))) (if RoomTextObj (progn (setq RoomText (vlax-ename->vla-object(ssname RoomTextObj 0 ))) (vla-insertrows table (+ 2 cnt) 1 1) (vla-settext table (+ 2 cnt) 0 (vla-get-TextString RoomText)) (vla-settext table (+ 2 cnt) 1 (/(vla-get-area vlpobj)144)) );progn );if (setq cnt ( + cnt 1)) );repeat );progn );if );defun

 

0 Likes
Message 3 of 15

Anonymous
Not applicable
Hello Ajilal.Vijayan
Honestly, my knowledge in Lisp is very short. I kind of understand what code does, but not good enough to modify or apply yet.
Would i ask little bit more advise?
Thank you.
0 Likes
Message 4 of 15

Ajilal.Vijayan
Advisor
Advisor

Hi,

Appload the attached lisp and run the program by entering 'RoomArea' command.

Select all the polylines and hit enter, then pick the point for table insertion.

Message 5 of 15

Anonymous
Not applicable

Hello Vijayan

 

I thought that i needed to apply the "room area" to AC_AREA-CALC_v2.1.lsp .... so i could not figure it out. (tried insert the room area in different location of the lisp.... failed -- ;

 

First of all, the lisp is great. simple and easy to use.

However, It seems the lisp is is not stable or i don't use it correclty.

It returns table without data dependins on the time i apply.

I did not get the correct table first few times, so i thought it was  part that i could insert into AC_AREA-CALC_v2.1.lsp

After i applied 20times, i realize it gives correct data. but it is 50% of chance i get the desired table.

 

I also applied to another sample, and i did not get any table with data in it. (please refer to attached files)

 

Is there special instruction to use the lisp correctly? 

By the way, could data be in field formation and select Mtext too? it is good as is, but would be better.

 

 

 

 

Once again, thank you for time. 

0 Likes
Message 6 of 15

CADaSchtroumpf
Advisor
Advisor

Hello,

Try to change in lisp code:

(setq RoomTextObj (ssget "_WP" pobjPoints '((0 . "TEXT")(8 . "Layer2"))))

to

(setq RoomTextObj (ssget "_WP" pobjPoints '((0 . "TEXT")(8 . "A-FLOR-IDEN"))))

"A-FLOR-IDEN" is your layer where text was ID of rooms.

Must do work's

0 Likes
Message 7 of 15

marko_ribar
Advisor
Advisor

Not long ago I've modified LM's Area Label V1-9 to accept islands... I know this isn't direct answer to your request, but maybe it can help you...

 

Here is that lisp in attachment...

http://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/combine-strong-points-of-two-great-li...

 

Regards, M.R.

Marko Ribar, d.i.a. (graduated engineer of architecture)
0 Likes
Message 8 of 15

Anonymous
Not applicable

Hello Vijayan

I'm not sure why but i still get the empty table or table with one row depending on the time i try.

As you can see on the screen shot, i tried 21times, 12 times i got the perfect one, 10 times with no data.

Once again, i selected all polylines and texts together. selected from left or right.. it seems there is some varaiable cuase the issue.

At least, it gives the correct name and area for the table.

Do you thing my CAD setting might interfere to lisp?

 

Anyway, Have a great weekend ^^;

0 Likes
Message 9 of 15

Anonymous
Not applicable
Hello Marko,
Thanks for the reply,
It seems it is similar to arealabelV1-9 and yes it will helpful for the island polyline.
I appreciate to the lead.
Thank you.
0 Likes
Message 10 of 15

Ajilal.Vijayan
Advisor
Advisor

Hi @Anonymous,

According to the first sample drawing you provided, I have added the Layer name also in the code to select the text.

So for the Label of room the code is looking for the layer name Layer2.

(setq RoomTextObj (ssget "_WP" pobjPoints '((0 . "TEXT")(8 . "Layer2")))) 

The above code is useful if you have so many labels inside the polyline and you need to select the right label to appear in the table.

Otherwise the code may select some other text which is inside the polyline.

 

If you dont want the code to depend on the layer name of text, then remove this from the code.

(setq RoomTextObj (ssget "_WP" pobjPoints '((0 . "TEXT")(8 . "Layer2"))))

Please find the attached lisp, in which I have removed the selection to depend on layer and added MTEXT selection as well.

Message 11 of 15

Anonymous
Not applicable

Hello Vijayan,

I use AutoCAD 2014 & 2016 in different computers but I got the same result.

It must be something in my computer setting caused the issues (returning empty table; it was not about the text layer)

When the lisp works, it works great, so I might just try the lisp till get the full table.

Once again, thanks for sharing your time and I really appreciated. 

 

0 Likes
Message 12 of 15

Ajilal.Vijayan
Advisor
Advisor

Hi,

Please find the attached drawing which you posted before to test.

I have run the code on this drawing and I was able to create area table every time I tried.

Can you post the drawing if the drawing which you are trying is different than this ?

0 Likes
Message 13 of 15

Anonymous
Not applicable

Hello Vijayan,

I tried on the same drawing as well as the original requet,Area Table.dwg too.

Just in case i tried in both file again, even tried in my coworkers’ computers, but i get the same result. (Half success)

Do you think there might be a preload app or lisp could help to get the table?

Or It might be another preload lisp or CAD setting in my office and home cause the issues.

In both ways, I wouldn't be able to fix it and I can’t provide office settings too...

 

Once again, even if it gives me a hiccup, I’m still happy to use the lisp as it gives correct data when it creates table.

Thank you!

0 Likes
Message 14 of 15

Anonymous
Not applicable

Good evening. is it possible to implement the table with a third column that shows the color of the selected object?

0 Likes
Message 15 of 15

Anonymous
Not applicable

Thank you so much for this.  It wasn't exactly what I needed, but so very close that I was able to make it work for me even knowing close to nothing in LISP

0 Likes