Export polyline data (area, layer and inner text) to excel

Export polyline data (area, layer and inner text) to excel

Anonymous
Not applicable
51,835 Views
179 Replies
Message 1 of 180

Export polyline data (area, layer and inner text) to excel

Anonymous
Not applicable

Hello, everyone!

I am searching for a lisp that can find all closed polylines in a drawing and export to excel their following information:

-Area of each closed polyline

-Layer in which the polyline resides

-Text inside each polyline

 

I have a building plan with polylines enclosing each room and the corresponding room text number also inside the polyline. I am looking for a lisp that can export to excel a table like this:

Text inside polylinePolyline Area (m2)Layer
"Room_1.1"10 m2Room_Layer
"Room_1.2"5 m2Room_Layer
"Room_1.3"5 m2Room_Layer
 -20 m2Floor_Layer

 

The polylines and room text numbers are located in different layers.

One of the polylines (last row in the table) encloses the whole building which means that there is more that one text inside it. For this single polyline, I only need its area and layer (text not needed).

 

I am fairly new to lisp creation so any help you can provide me would be highly appreciated!

Thanks in advance!

0 Likes
Accepted solutions (1)
51,836 Views
179 Replies
Replies (179)
Message 121 of 180

dlanorh
Advisor
Advisor

I've re-written the error check to take account of the two cases. This has been tested against a list of known errors combinations and should now handle both (or more) cases. Ignore the coded "##G#" patterns as this is an always fails for hexadecimal strings eliminating cases where the "E" is first, last or not present.

 

 

I am not one of the robots you're looking for

Message 122 of 180

OM805
Enthusiast
Enthusiast

dlanorh,

 

Looks to be doing the job.  Thank for taking the time. It is appreciated.

 

Regards,

 

OM

0 Likes
Message 123 of 180

OM805
Enthusiast
Enthusiast

dlanorh,

 

Hope all is well... Discovered another hiccup over the weekend.  Sometimes the Handle IDs come in as 4 digit numeric. Example 1064 is shown below and within attached files.  This should be flagged as an error. Help would be appreciated.

 

Space Class/NameArea (sqft)Perimeter (ft)LayerPolyline Closed?Object Handle IDID Error? Polyline Around Text?Notes:
-124.2249A-AREA-OTLNYesD0CANoYesCorrect
Polyline is not closed! | Fix Me!124.2248.39A-AREA-OTLNNoD0C9NoYesCorrect
Void | 205A CHASE89.5639.44A-AREA-OTLNYesD0C5NoYesCorrect
Void | 200B CHASE124.2249A-AREA-OTLNYesD0C4NoYesCorrect
This Space should flag as ID error. | Object ID shows up as 4 numeric characters539.69125.73A-AREA-OTLNYes1064NoYesWrong: Handle ID is an error 1064
Admin Circulation | 200 LOBBY      NoCorrect
0 Likes
Message 124 of 180

dlanorh
Advisor
Advisor

Technically, it's not an error, just an integer instead of a string which can be solved by formatting the column as text.

 

I have attached an updated lisp that as before preceeds the integer string with a ' forcing it to text and marking it as an "error"

 

I am not one of the robots you're looking for

Message 125 of 180

OM805
Enthusiast
Enthusiast

dlanorh,

 

Just wanted to report in and mention that the routine has been working out great. Thanks for all of your help.

 

Regards,

 

OM

0 Likes
Message 126 of 180

dlanorh
Advisor
Advisor

That's great. Thanks for the update. 😁 👍

I am not one of the robots you're looking for

Message 127 of 180

OM805
Enthusiast
Enthusiast

Dlanorh,

 

After further use the only thing that would be a bit more practical is the splitting of Space Class & Space Name into two columns instead of one. Also, the addition of  a "Space Name Duplicate?" column.  What do you think? Example shown below.

 

Current:

Space Class/NameArea (sqft)Perimeter (ft)LayerPolyline Closed?Object Handle IDID Error? Polyline Around Text?
Void | B139A CHASE27.2527.24A-AREA-OTLNYes1C223DNoYes
Void | B136A CHASE17.517A-AREA-OTLNYes1C2234NoYes

 

New:

Space ClassSpace NameArea (sqft)Perimeter (ft)LayerPolyline Closed?Object Handle IDID Error? Polyline Around Text? Space Name Duplicate?
VoidB139A CHASE27.2527.24A-AREA-OTLNYes1C223DNoYesNo
VoidB136A CHASE17.517A-AREA-OTLNYes1C2234NoYesNo

 

Regards,

 

OM

0 Likes
Message 128 of 180

dlanorh
Advisor
Advisor

Will have a look later today.

I am not one of the robots you're looking for

Message 129 of 180

dlanorh
Advisor
Advisor

Attached is updated lisp file and an example of the generated csv file. The lisp works exactly as before, I have just added the extra column and substituted a "," for the " | ". This seems to works OK

I am not one of the robots you're looking for

Message 130 of 180

OM805
Enthusiast
Enthusiast

Dlanorh,

 

This is what I get using our existing error dwg test file.  Something is certainly off.  Attached is the dwg test file with a "duplicate space name?" error added in for testing.  

 

Space ClassSpace NameArea (sqft)Perimeter (ft)LayerPolyline Closed?Object Handle IDID Error? Polyline Around Text?
Void205A CHASE89.5639.44A-AREA-OTLNYesD13BNoYes
-124.2249A-AREA-OTLNYesD0CANoYes 
Polyline is not closed!Fix Me!124.2248.39A-AREA-OTLNNoD0C9NoYes
Void205A CHASE89.5639.44A-AREA-OTLNYesD0C5NoYes
Void200B CHASE124.2249A-AREA-OTLNYesD0C4NoYes
This Space should flag as ID error.Object ID shows up as 4 numeric characters539.69125.73A-AREA-OTLNYes1064NoYes
Admin Circulation200 LOBBY      No

 

 

Thank you,

 

OM

0 Likes
Message 131 of 180

dlanorh
Advisor
Advisor

You will need to repost as a 2012 or earlier drawing, otherwise I cannot open it. I'm assuming the error is caused because there is no text found within the polyline. If so, how do you want this displayed?

 

I cannot remedy this until the weekend as I will have no access to a full version of AutoCAD until I return.

 

I am not one of the robots you're looking for

Message 132 of 180

OM805
Enthusiast
Enthusiast

2012 file is attached.

 

To clarify the requests:

1. Split Space Class and Space Name output into two columns.

2. If possible, add another column "Space Name Duplicate?" that looks for duplicate Space Name(s); labeling them as Yes or No.

 

Note... Request 1 is most important and 2 is nice to have.  Thanks in advance. Questions or concerns, please let me know.

 

Regards,

 

OM

 

 

0 Likes
Message 133 of 180

dlanorh
Advisor
Advisor

Apologies. I've not been able to look at this yet.

I am not one of the robots you're looking for

0 Likes
Message 134 of 180

dlanorh
Advisor
Advisor

@OM805 

 

Attached is the update lisp. I've re-written the Handle error check sub routine. Tested against your supplied drawing. This solves the immediate issues (I hope). The duplicate space name will need another more extensive re-write, which I will attempt over the next couple of days.

I am not one of the robots you're looking for

Message 135 of 180

OM805
Enthusiast
Enthusiast

Ran it through a few more robust tests and it does check out. Works good...  I could not be more appreciative.

 

Thank you,

 

OM

0 Likes
Message 136 of 180

OM805
Enthusiast
Enthusiast

Hmm?  Maybe, I spoke to soon. I does not seem the Handle ID Errors are being picked up. Attached is the data export and example dwg. 

 

Space ClassSpace NameArea (sqft)Perimeter (ft)LayerPolyline Closed?Object Handle IDID Error? Polyline Around Text?
External100B COURTYARD7839.67433.88A-AREA-OTLNYes2.50E+11NoYes
STORAGE103 STORAGE181.9857.55A-AREA-OTLNYes2.30E+97No

Yes

 

 

 

 

 

Regards,

 

OM

0 Likes
Message 137 of 180

dlanorh
Advisor
Advisor

I can't open the drawing, it needs to be 2012 or earlier. It's not obvious what is causing this so i need to run the lisp against the drawing.

I am not one of the robots you're looking for

0 Likes
Message 138 of 180

OM805
Enthusiast
Enthusiast

Apologies...  Attached is the DWG saved to Rev 10.

 

Regards and Thanks,

 

OM

0 Likes
Message 139 of 180

dlanorh
Advisor
Advisor

OK, though I had allowed for this, but I discovered my test data had an error, a capital "O" instead of a zero (0) 😱 .

 

Try the attached. It assumes that an "e" or "E" at the start or end won't trigger the problem, and I've tested this with a revised test data into excel. This should work for any handles string lengths, although I've only test up to string length of 6.

 

I'll keep plugging away with the duplicate space name.

I am not one of the robots you're looking for

Message 140 of 180

OM805
Enthusiast
Enthusiast

Working good on this end.

 

Thanks,

 

OM

0 Likes