Hi there everybody!
I've been working on excel and manually transcribing the space type (Yellow) the space name (Blue) and the Area (Green)
Since this is very recurring for me I was thinking, is it possible to extract the information from the drawing via LISP?
I would like to run a command that loops through all polylines and either export information to Excel or Create an AutoCAD table right there in the drawing.
Your help is very much appreciated.
See drawing attached.
Victor P
Found this lisp in the forum all credits to Jimmy Bergmark!
But this covers the Area field how would I also retrieve the space type and the Space number?
Thank you all so much!
I found this code by @pbejse it does almost everything I need I just need help tweaking it a little bit... I would like to make it so that there is only one text per polyline allowed and add the space type (yellow) in sample drawing column
also, if you would please help in making it sqft. that would be great!
Thank you all so much!
(defun c:demo (/ ss i area layer all_data pts csv_file openfile)
;; 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))))
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
)
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"
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)
)
openfile
)
)
(close openfile)
(startapp "notepad" csv_file)
)
)
(princ)
)
Change as follow
@AVFx1410 wrote:Hi there everybody!
I've been working on excel and manually transcribing the space type (Yellow) the space name (Blue) and the Area (Green)
Since this is very recurring for me I was thinking, is it possible to extract the information from the drawing via LISP?
I would like to run a command that loops through all polylines and either export information to Excel or Create an AutoCAD table right there in the drawing.
Your help is very much appreciated.
See drawing attached.
Victor P
(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 12 12) ; it divide sqr inches by 12 by 12 to get sqr ft
layer
)
all_data
)
)
)
My $0.05 yes can have a table and / or export to excel. Or make table then export to excel. For me I go direct to excel these days.
Turned a few layers off so looking at room 1-055 returns Area: 76324.813 sq. in. (530.033 sq. ft.) note white line used for area.
You can get a surrounding area of the room label, by using the bpoly command. So theoretically could get all rooms area based on room name. Not checked (sslength (ssget "X" '((0 . "TEXT")(8 . "SV-TXT-SPACENAME")))) 82 rooms ? So would get area of all rooms automatically.
Please note though if a room is not closed may get a wrong answer. Found 1 !
Guess could do a stop room to large check, show where it is, then run again when fixed.
So table yes or no ?
Do the rooms change shape so is there a need to update the area for a room ? My answer is just make table again as it will be like 1-2 seconds.
Hi @Sea-Haven
Thanks for your input, I'd like both options to create a table but also export to excel if possible, I know it may be a lot to ask...
The polyline will never change it's shape for my purposes so no need to update it.
My reception 1-001 has a polyline so it is weird your drawings does not haha 😄
-----------------------------------------------------------------------------------------------------
On a different note I am working on some updates my self just for trial and error practice, how would I add another column for the SV-TXT-TYPE layer?
Thanks I appreciate every comment!
The lisp attached is more like what I need in terms of columns, however I don't need "ID error", "Polyline Around Text?"
Can some one help me modify the attached so that it works properly, I've attached the csv export with some errors.
Also would someone help me to remove the new, append or overwrite options... I don't really need that!
Thanks all for your help!
"My reception 1-001 has a polyline so it is weird your drawings does not". I am using Bricscad, can not see a pline, no area text either, can you check please the dwg supplied. Also need a line across the doorways to isolate the Reception room say on a non plot layer if want to auto work out areas which is the way I am suggesting do all rooms in one go. Some of the doors have a line across them.
Hi @Sea-Haven here is a screen shot of the dwg I attached, I know it looks funny but it is drawn that way by design.
The lisp I attached before, kind of works but I get some messed up cells in the CSV
Thanks for looking into it but no need to re-upload, it is good. Just need to get the areas from all the SV-SPACE Polylines might be nice to have a SV-ZONE area column (magenta) especially if it can be stripped from the code if it is no longer needed and 2 columns more for room id (blue) and space type (yellow)
thanks so much and let me know how else I can assist.
Ok understand now looking at layer SV-SPACE. Will see what I can do.
Make sure it looks like this when running.
Can't find what you're looking for? Ask the community or share your knowledge.