LISP for extraction of polyline properties

LISP for extraction of polyline properties

NSL26
Contributor Contributor
2,457 Views
11 Replies
Message 1 of 12

LISP for extraction of polyline properties

NSL26
Contributor
Contributor

Hello.

 

I've got a LISP that can extract into a csv file the area of a closed polyline, the name of the room that is written inside it and the layer on which the polyline was drawn.

 

I would like to get into the same csv file the properties of each polyline, because they contain valuable information.

The properties are in a object data table.

That would be in the form of new columns in the csv file (one column for each property field in the object data table) after the ones already existing (area, name of room and layer).

 

Could you help me to find what lines I should add to the LISP in order to perform that ?

 

Thank you very much.

0 Likes
Accepted solutions (2)
2,458 Views
11 Replies
Replies (11)
Message 2 of 12

devitg
Advisor
Advisor

@NSL26 For better understanding, and maybe get further help, please upload such sample.dwg

0 Likes
Message 3 of 12

NSL26
Contributor
Contributor

Hello again, here's a sample.

 

It contains 2 apartments with the room shape layer only and the text.

Usually I draw all the floors on the same dwg file, one next to the other.

 

In the properties of each polyline, you can see the data object table I created and associated. 

It contains 4 fields : Building, Batch, Floor and Apartment.

 

I selected the polylines I need and wrote in the adequate field the number of the apartment, etc... So the value is updated on the properties of each individual polyline selected.

 

The LISP I have allows me to have a csv file with the name of the rooms, their area and the layer they are on.

 

What I would like to do is to also extract the properties data and have them in the csv.

And I would like to have all the data classified by building number and apartment.

 

In the end, I would get a csv file with : all the rooms of building 1 with their area, their building number, floor number and appartment number, beginning with the rooms of the first apartment of the first floor, then those of the second apartment of the first floor...

Then the same for the second floor, and so on.

And after, all that again for building 2, 3, 4.

 

I hope this will clarify my question. 

 

 

 

 

 

0 Likes
Message 4 of 12

CADaSchtroumpf
Advisor
Advisor

Hi,

I have this wich can be near to your ask...

0 Likes
Message 5 of 12

devitg
Advisor
Advisor

@CADaSchtroumpf 

 

 defun  ade_odgettables  and ade_odtabledefn    ade_odgetfield    are not at lsp 

 

devitg_0-1658275373571.png

 

0 Likes
Message 6 of 12

CADaSchtroumpf
Advisor
Advisor

@devitg  a écrit :

@CADaSchtroumpf 

 

 defun  ade_odgettables  and ade_odtabledefn    ade_odgetfield    are not at lsp 

 


@devitg 

Are specials functions lisp for AutocadMap only.

See documentation help.


@NSL26  a écrit :

 

In the properties of each polyline, you can see the data object table I created and associated.

It contains 4 fields : Building, Batch, Floor and Apartment.


Fields for Data Object are visible only on Autocad Map.

NSL26 should have posted in autocad-map-3d-forum  

0 Likes
Message 7 of 12

NSL26
Contributor
Contributor

.

0 Likes
Message 8 of 12

NSL26
Contributor
Contributor

Thank you, now I can have the content of the data object table in a csv file.

 

I have a few questions : 

 

1) when I select the polylines of a whole apartment with your LISP, I am unable to choose some of them.

Namely for the upper toilets and the cupboards, they do not get selected even if I try to select them.

 

When not using the LISP, I can select them with no problem.

 

Do you know why ?

 

2) In the csv file I get the room names (I added a "room name" field in the table) and their features in a descending order, beginning with Building 9, Floor 9, Apartment 99 for exemple, and ending with Building 1, Floor 1, Apartment 1. What should I change in the code in order to have them in an ascending order ?

 

3) In the csv file, on rare occasions, there's a break in the order : for example, I have 8 rooms for apartment 32 listed, then all the rooms for apartment 31, then the 2 remaining rooms of apartment 32.

Do you know the reason ?

 

Again, thank you very much.

 

(Sorry, i replied to the wrong person in the first place)

 

Edit : I added 2 photos to show you the problem. When I am asked whether I want to do a manual selection or not, when I choose "all", they are not all present in the csv file, and when I choose "manual" and pick the polylines I need, some (always the same) are not taken into account. It's always one toilet room and two cupboards. That happens when I have to click on a polyline and then chose manual and pick the rest of the polylines. 

If the first one I pick is not among the 3 problematic ones, they will not be selected after when I pick the whole apartment, and when the first polyline I pick is among the problematic ones, only these 3 polylines are selected when I try to select a whole apartment.

 

I'm using Map 3D 2023, that's maybe part of the problem ? 

0 Likes
Message 9 of 12

CADaSchtroumpf
Advisor
Advisor
Accepted solution

For question 1, it's because I'm using DXF code 70 to select all polylines with the same code. For example, if the starting model is a closed polyline (70 . 1), I will only select the polylines with the same code.
At the same time the generation of the type of line and also stored in this code (value 128) which will give for example (70 . 129) 128 + 1.
So the solution for you is to put the same linetype generation for all the polylines you want to process.

 

For 2 and 3 I can only advise you to do your sorting in excel, it will be the easiest.
To do this, you can also (as shown in the code) remark lines 263-265-266 by putting a semicolon at the beginning of the line. It will be easier to sort in excel according to a column.

0 Likes
Message 10 of 12

NSL26
Contributor
Contributor

Thank you very much, I'll do that.

 

Do you know a good tutorial to learn about DXF codes ?

0 Likes
Message 11 of 12

CADaSchtroumpf
Advisor
Advisor
Accepted solution

Apart from the documentation, I don't know of a tutorial...

But you can use this little code for listing the DXF code of an entitie (or sub-entitie).

(defun c:dxflistdata ( / ent msg l_str nb ch)
	(setq ent 0)
	(while (not (listp ent))
		(if user-dxf
			(setq msg "\n[Entite/Sous-entite]<S> - Choix de l'objet à lister ses codes DXF: ")
			(setq msg "\n[Entite/Sous-entite]<E> - Choix de l'objet à lister ses codes DXF: ")
		)
		(initget "Entite Sous-entite")
		(if user-dxf
			(setq ent (nentsel msg))
			(setq ent (entsel msg))
		)
		(if (eq ent "Sous-entite") (setq user-dxf T))
		(if (eq ent "Entite") (setq user-dxf nil))
	)
	(cond
		(ent
			(setq
				l_str (cons "\tDATA DXF d'OBJET\n\n" (mapcar '(lambda (x) (strcat x "\n")) (mapcar 'vl-prin1-to-string (entget (car ent)))))
				nb (length l_str)
				ch ""
			)
			(while (> (length l_str) 31)
				(repeat 31
					(setq
						ch (strcat ch (car l_str))
						l_str (cdr l_str)
					)
				)
				(alert ch)
				(setq l_str (cons "suite DATA DXF d'OBJET\n\n" l_str) ch "")
			)
			(setq ch (apply 'strcat l_str))
			(alert ch)
		)
	)
	(prin1)
)
0 Likes
Message 12 of 12

devitg
Advisor
Advisor

@NSL26  from adsk  all about DXF codes 

0 Likes