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 polyline | Polyline Area (m2) | Layer |
"Room_1.1" | 10 m2 | Room_Layer |
"Room_1.2" | 5 m2 | Room_Layer |
"Room_1.3" | 5 m2 | Room_Layer |
- | 20 m2 | Floor_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!
Solved! Go to Solution.
Solved by pbejse. Go to Solution.
This
";" (strcat (rtos (Cadr itm) 2 2) " m2") ";"
to
";" (strcat (vl-string-translate "." "," (rtos (Cadr itm) 2 2)) " m2") ";"
Good job buddy
🙂
Is it possible to add below exported data in csv file
- in first column:
string "Total area:"
- in second column:
value with sum of areas
Thank You!
Hi There,
can you edit lisp to add column for perimeter of room beside area ?
@pbejse wrote:
@Anonymous wrote:
Just one more detail, would it be possible to add a 4th column to the table with the information on whether the polylines are closed or not (field "Closed" in "Misc" properties, attached image).
Here you go.
(defun c:EPD (/ ss i area layer all_data pts csv_file openfile) ; Export Polyline Data ;; pBe Sep 2018 ;; (if (and (setq all_data nil ss (ssget '((0 . "LWPOLYLINE"))) ) (repeat (setq i (sslength ss)) (setq e (ssname ss (setq i (1- i))) area (vlax-curve-getarea e) layer (cdr (assoc 8 (setq ent (entget e)))) cl_op (cdr (assoc 70 ent)) pts (mapcar 'cdr (vl-remove-if-not '(lambda (d) (= 10 (car d)) ) ent ) ) ) (if (setq ssText (ssget "_CP" pts '((0 . "TEXT")))) (setq all_data (cons (list (if (= (sslength ssText) 1) (cdr (assoc 1 (entget (ssname ssText 0)))) "-" ) area layer (if (zerop ( logand 1 cl_op)) "No" "Yes") ) all_data ) ) ) all_data ) (setq csv_file (getfiled "Save CSV File" (strcat (getvar 'dwgprefix) (vl-filename-base (getvar 'dwgname)) ".csv" ) "csv" 45 ) ) ) (progn (setq openfile (open csv_file "w")) (write-line "Text inside polyline,Polyline Area (m2),Layer,Closed" openfile ) (foreach itm (vl-sort all_data '(lambda (a b) (< (Cadr a) (cadr b))) ) (write-line (Strcat (Car itm) "," (strcat (rtos (Cadr itm) 2 2) " m2") "," (caddr itm) "," (last itm) ) openfile ) ) (close openfile) (startapp "notepad" csv_file) ) ) (princ) )
I assume you meant "length", it is the same is it not? Can you confirm that it is.
@jalal.mousa wrote:
Hi,
Yes you are right, once you use polyline it will give you in properties area and length
I would like to get :
1. Text inside polyline
2. Polyline layer name
3. Area (in sf or sm depends on inits)
4. Length (in lf or lm)
[cid:image001.png@01D4D7E7.FD000080]
Sure
command: TPAL [ attached file ]
Result:
Text inside polyline,Layer,Polyline Area (m2),Length
Single line 2,Alayer,248.44 m2,69.41
Single line 5,AnotherLayer,226.73 m2,60.32
Single line 4,AndAnother,610.96 m2,98.92
Single line 1,YetAnotherLayer,215.65 m2,58.78
HTH
@jalal.mousa wrote:
..
Please see attached file with 3 rooms I draw (room 100,102,103) that lisp won't work with
..
Those must be invisible drawing files I've been hearing about in the past 3 months
Try attaching the file again @jalal.mousa .
Hi not sure why it did not attached it maybe because i reply in e-mail
please see attached hope it will work
@jalal.mousa wrote:
Hi not sure why it did not attached it maybe because i reply in e-mail
please see attached hope it will work
On your previous post, you posted a code that you want to modify, and it shows below.
So...
change
(setq ssText (ssget "_CP" pts '((0 . "TEXT"))))
To
(setq ssText (ssget "_CP" pts '((0 . "MTEXT"))))
HTH
this solution works perfect
thanks a lot
I was wondering if I can ask for last few things
please see attached file that different polyline overlap each other in few locations
would it be possible to provide a count column and total length where they overlap ?
so in attached file you will see notes I put to clarify above
sorry for bothering you again
can you add:
in our example the answer would be ;
many thanks in advance
sorry for bothering you again
can you add:
in our example the answer would be ;
many thanks in advance
@jalal.mousa wrote:
this solution works perfect
thanks a lot
I was wondering if I can ask for last few things..
...
would it be possible to provide a count column and total length where they overlap
....
can you add:
- would it also possible to list all text that have no polyline around
- add column beside text content for text layer name
You can ask by all means.
Yes Yes, and Yes
Would you like some fries to go with that lisp?
@jalal.mousa wrote:
LOL
I know it is too much to ask
Just playing with you, I'll post the modified code later
Cheers
sorry to bother you again
i just notice that :
is this something can be fixed ?
@jalal.mousa wrote:
sorry to bother you again
i just notice that :
- if there is more than one text inside closed polyline it won't grab any of the text but -
- it won't grab closed polyline if no text inside
- it won't grab text if no closed polyline around it (this mentioned probably part of last email)
is this something can be fixed ?
Are you serious right now?
The answer is still YES
But first
Deposit 50 USD to this account number
(73 39 109 32 97 98 117 115 105 110 103 32 121 111 117 114 32 107 105 110 100 110 101 115 115)
....
Can't find what you're looking for? Ask the community or share your knowledge.