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

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

Anonymous
Not applicable
51,686 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,687 Views
179 Replies
Replies (179)
Message 21 of 180

pbejse
Mentor
Mentor

@Anonymous wrote:

Thank you - but I didn't explain my situation completely.

 

.....

Thank you for your input in trying to solve my problem.

 

 

Your problem is easy, its understanding you're the exact requirement is the hard part. Post a drawing sample and what the table should like.

 

 

 

 

 

0 Likes
Message 22 of 180

Anonymous
Not applicable

OK - here is the Autocad drawing and a snapshot of the the kind of table I need.

The drawing is a quick architectural layout of a store plan.

Basically I have labeled store department areas  surrounded with polylines in a drawing. I would like to be able to sect them and have the put int an Excel chart.

I thought my problem was the same as miguelmlas - but now I realize i needed the areas to be in square feet (SF) because my drawings are in architectural units.

0 Likes
Message 23 of 180

devitg
Advisor
Advisor

Please change it 

 

area   (vlax-curve-getarea e) 

to 

 

area  ( / (vlax-curve-getarea e) (* 12 12))

as the area is given in Inch , divide it by 12 times 12 or 144 

 

 

Message 24 of 180

pbejse
Mentor
Mentor
There you go.

I have not a chance to look at the attachments, but what devtg posted makes sense and should work.

pBe

Message 25 of 180

Anonymous
Not applicable

Thank you pbejse and devitg!

Exactly what I need for my project.

Now I am going to see if I can figure out how to round the square foot numbers obtained in the table to be rounded off to the nearest foot.

0 Likes
Message 26 of 180

Anonymous
Not applicable

I used one of Lee Mac's lisp functions - rounding to the nearest integer - and set the precision to "0" and I got the results I needed.

 

Thanks again!

0 Likes
Message 27 of 180

wacho31
Explorer
Explorer

Hi please help me with code:

I would like to see effects like in attached screenshot.

- single & multiline inside polylines

- precision convert from mm2 to m2 and dot in area change to comma

 

 

 

 

 

 

 

0 Likes
Message 28 of 180

wacho31
Explorer
Explorer

Hi,

Could you help me solve te issue with code:

I would like to see effects like in attached screenshot.

- single & multiline inside polylines

- precision convert from mm2 to m2 and dot in area change to comma

 

screenshot in attachment what I would like to achieve and how it works now.

0 Likes
Message 29 of 180

pbejse
Mentor
Mentor

@wacho31 wrote:

Hi,

Could you help me solve te issue with code:

I would like to see effects like in attached screenshot.

- single & multiline inside polylines

- precision convert from mm2 to m2 and dot in area change to comma

 

screenshot in attachment what I would like to achieve and how it works now.


 

That's easy.

 

0 Likes
Message 30 of 180

Buzz0m
Collaborator
Collaborator

I'm surprised no body mentioned data extraction? I believe most of your needs can be found in this built in functionality. For the custom calculations you can add extra columns with mathemitical functions just like excel...

 

https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2019/ENU/AutoC...

0 Likes
Message 31 of 180

devitg
Advisor
Advisor
Show us a sample.dwg. sad to say acad can not handle screenshot.
0 Likes
Message 32 of 180

wacho31
Explorer
Explorer

Hi,

added attachments,

please help me with this issue.

0 Likes
Message 33 of 180

wacho31
Explorer
Explorer

Could you help me?

I attached files. Please help me with tis issue.

Thank You

0 Likes
Message 34 of 180

pbejse
Mentor
Mentor

@wacho31 wrote:

Could you help me?

I attached files. Please help me with tis issue.

Thank You


 

 

Please be aware that the sample files you posted on post# 32 are also available to everyone. no need to attached here again.

 

See attached file: EPD_vpBe.lsp

 

command: EDP

 

Text inside polyline,Polyline Area (m2),Layer,Closed,Handle
Single line 1,215654522.43 m2,obszary,Yes,2E4
Multiline 2 | Single line 5,226734779.63 m2,obszary,Yes,2E9
Single line 2,248440499.89 m2,media,Yes,2E6
Multiline 1 | Single line 3 | Single line 4,610955487.01 m2,obszary,Yes,2E5

HTH

 

0 Likes
Message 35 of 180

wacho31
Explorer
Explorer

Thank You for help, 🙂
- single & multiline inside polylines works perfect:)

 

Could you check how change also precision to convert from mm2 from drawing to m2 and dot in area change to comma like below:

 

Text inside polyline,Polyline Area (m2),Layer,Closed,Handle
Single line 1,215,65,obszary,Yes,2E4
Multiline 2 | Single line 5,226,73,obszary,Yes,2E9
Single line 2,248,44,media,Yes,2E6
Multiline 1 | Single line 3 | Single line 4,610,95,obszary,Yes,2E5

 

Thank you!

0 Likes
Message 36 of 180

CLL_PBE
Contributor
Contributor

@wacho31 wrote:

 

Could you check how change also precision to convert from mm2 from drawing to m2 ...


  ...
) 4 ) area (car data) (if (zerop ( logand 1 (cadr data))) "No" "Yes") (caddr data)
...

to

...
) 4 ) ( / area 1e6) (car data) (if (zerop ( logand 1 (cadr data))) "No" "Yes") (caddr data)
...

 


@wacho31 wrote:

.. dot in area change to comma like below..

...

Multiline 1 | Single line 3 | Single line 4,610,95,obszary,Yes,2E5

 


 

Sure you want to do that? You realize doing so will give you unexpected results when you open the csv file other than notepad, the comma may be interpreted as a delimiter.  or even importing the data back to Autocad.

 

 

 

 

0 Likes
Message 37 of 180

wacho31
Explorer
Explorer

Hi, thank you for help. Tomorrow i will check code from you. BTW you have right that if I will change dot to comma i couldn't separate column correcly e.g. in excel. Could i use semicollon for separate all data and then implement comma instead of dot in area? E.g.

Multiline 1 | Single line 3 | Single line 4;610,95;obszary;Yes;2E5

If my proposal  could work correctly could you help me with Code? Thank you!

0 Likes
Message 38 of 180

wacho31
Explorer
Explorer

Hi,

I changed separator from comma to semicolon but I have issue how change dot to comma in area

 

Multiline 1 | Single line 3 | Single line 4;610.95;obszary;Yes;2E5

 

0 Likes
Message 39 of 180

wacho31
Explorer
Explorer

Hi,

When i changed separator from comma to semicolon effects after export to csv and open it in excel isn't correct

 

0 Likes
Message 40 of 180

wacho31
Explorer
Explorer

Hi I solved issue with separator. I changed it to semicolon also inside heading line.

To achieve fully effects i need now change dot to comma in area.

 

0 Likes