View Full Version : Creating drawing list in AutoCad
gazzalp
27th Oct 2009, 09:02 pm
Everyone, i work for a structural engineering company, and quite a few of our jobs have 100+ drawings. Usually we create a drawing register showing all of our drawings and their revisions in Excel, but we also like to have a drawing list on our front page so when people recieve our drawings they don't need to look at the register to find out where to go to find each drawing. In the past we have tried to link our excel spreadsheet to Autocad but have not had very good results.
What i am hoping for is a macro/lisp that will read the DWG name from the specific folder, and create text in autocad to put on our first drawing for that job. For example we want a drawing list on our drawing number 01. Our DWG files are named similar to the following: 200902-A-Level 1 Plan.dwg (being the job number-revision-drawing name. I am hoping there is some kind of way i can get that information extracted (minus the job number) and put into text on our first drawing. Either that or if it could read the drawing name and revision from the title block. Obviously the macro would have to read from that job folder only.
Is there anyone else who does something similar to this? or has a better alternative? Like i said iver tried exporting our excel spreadsheet into the first drawing but we have problems with the size, cropping etc.
thanks for any help
JohnM
27th Oct 2009, 09:33 pm
Instead of inserting excel have you given any thought to coping the data to AutoCAD.
Open you excel worksheet
Highlight the data
Use CTRL+C or edit copy or whatever you use to copy to the clipboard
In AutoCAD go to the EDIT menu and select PAST SPECIAL
In the dialog box select AutoCAD entities from the list
Click OK and park it.
Takes all of 10 seconds.
gazzalp
27th Oct 2009, 09:44 pm
Yes thats true but than anytime we issue drawings we have to do that, we issue drawings every day. I want something where i dont have to open excel, id rather just issue autocad drawings and not worry about any other programs. I then also have to add any new drawings into excel which means typing them out and adding the revisions; but im sure theres a way to get the computer to do it for me.
Cadologist
27th Oct 2009, 09:56 pm
Have you looked into using 'sheetsets'? You can do this with easily with a sheetset option but it will be time consuming to get to that stage, you will have to re-create the titleblock used (inserting in fields rather then attributes) and then when working with the project, linking all the drawings (you can link in existing drawings) to the sheetset. Doing this, you have the option of creating an 'autopopulating' drawing list (and a bunch of other options in there) into a table format. This table can be easily updated by right-clicking on it and using 'autoupdate data links'.
Without getting too far ahead, you may want to check out 'sheetsets'.
alanjt
27th Oct 2009, 10:09 pm
I'd spend the time and setup sheetsets, but this should get you started...
(defun c:Dir2Text (/ #Pnt1 #Pnt2 #List #String)
(cond
((and (setq #Pnt1 (getpoint "\nSpecify first corner: "))
(setq #Pnt2 (getcorner #Pnt1 "\nSpecify opposite corner: "))
) ;_ and
(setq #List (vl-sort (vl-remove-if-not
'(lambda (x) (wcmatch x "*.dwg"))
(vl-directory-files (getvar 'dwgprefix))
) ;_ vl-remove-if-not
'<
) ;_ vl-sort
#String ""
) ;_ setq
(foreach x #List (setq #String (strcat #String (vl-filename-base x) "\\P")))
(AT:MText #Pnt1 #String (abs (- (car #Pnt1) (car #Pnt2))) nil 1)
)
) ;_ cond
(princ)
) ;_ defun
You'll need this subroutine to create the text: http://www.cadtutor.net/forum/showpost.php?p=278945&postcount=40
MarcoW
28th Oct 2009, 07:49 am
@ Gazzalp:
I know exactly what you mean ! Been here and there asking for help but it don't really got me an answer. So I figured to try something for my own.
First of all the sheet sets: it works in a different way than you and I want. We need a rgister sheet where all the info out of the titleblock is gathered.
Example (just a quick idea):
nr. descr. date size
01 - 04 1st floor 01-10-2009 ISOA1
02 - 04 2nd floor 01-10-2009 ISOA1
03 - 04 3rd floor 01-10-2009 ISOA1
04 - 04 4th floor 01-10-2009 ISOA1
Whenever one of the titleblocks are modigied it should be changed in the register.
That is what you mean am I right?
My guess is that it can be done with the "eattext" command in Autocad. It already works in my situation only there are some issues that I can't solve. (Sorting tables etc..)
So for now, at this moment, I can't give you a real solution but you should try to experiment with the command. Please feel free to ask me for I am just in need as you are to solve this.
Also search the forum with keywords "eattext" or "drawinglist".
Look, I've been trying...:
http://www.cadtutor.net/forum/showthread.php?t=37813&highlight=eattext&page=3
gazzalp
28th Oct 2009, 08:19 am
Cadologist - Ive looked into sheet sets for other things, i cant say i was a fan of them. They would take a lot of getting used to, and then ive got another 20 people to try and teach, so thats not the best solution for me i dont think. thanks though.
Alanjt - What exactly does this lisp do and how do i go about incorporating it?
MarcoW - you are correct thats what i am after, but it doesnt neccisserily have to read it from the title block. our dwg names also include the drawing number, title and revision, so it could read it from the dwg name if possible. I will have a go at the eattext command shortly, thanks
gazzalp
28th Oct 2009, 09:46 am
Marco, i have played around with eattext and it works pretty well. A couple of problems i have found that you might know how to overcome:
1. i am extracting from our titleblock, where our drawing name is over two lines. Therefore the attrbutes are "drawing title line 1" and "drawing title line 2". When extracting this information autocad puts it into a table, but with the rows "drawing title line 1" and "drawing title line 2" whereas i would prefer if in the table it was just called "drawing title" and both titles would come under that one row. Any ideas on how to fix this?
2. my only other problem so far is say for example i do this for a job, and then later add one more drawing. Rather then again either doing this command, or manually typing in the new drawing is there a way to update? ie. just add the one drawing to this table in order? It would be great if when i first select the drawings i want to extract from, i could instead select the whole job directory. That way in the future when i select the table and "refresh" it would add any more drawings that i have since added because it knows to update from the directory.
MarcoW
28th Oct 2009, 03:15 pm
I will try to post reaction tonight or else tomorrow. (No time to do so now...)
One question, where are you from (country)?
alanjt
28th Oct 2009, 03:20 pm
Alanjt - What exactly does this lisp do and how do i go about incorporating it?
Did you actually try it?
alanjt
28th Oct 2009, 03:33 pm
You'll have to excuse the directory list, I'm at home...
15117
It will collect all dwg names located in directory of current drawing and place them in an MText object, based on picked location.
alanjt
28th Oct 2009, 03:36 pm
This one will number them:
(defun c:Dir2Text (/ #Pnt1 #Pnt2 #List #String)
(cond
((and (setq #Pnt1 (getpoint "\nSpecify first corner: "))
(setq #Pnt2 (getcorner #Pnt1 "\nSpecify opposite corner: "))
) ;_ and
(setq #List (vl-sort (vl-remove-if-not
'(lambda (x) (wcmatch x "*.dwg"))
(vl-directory-files (getvar 'dwgprefix))
) ;_ vl-remove-if-not
'<
) ;_ vl-sort
#String ""
) ;_ setq
(foreach x #List
(setq #String
(strcat #String (itoa (1+ (vl-position x #List))) " - " (vl-filename-base x) "\\P")
) ;_ setq
) ;_ foreach
(AT:MText #Pnt1 #String (abs (- (car #Pnt1) (car #Pnt2))) nil 1)
)
) ;_ cond
(princ)
) ;_ defun
15119
alanjt
28th Oct 2009, 08:48 pm
Slow day and I'm having a little fun...
15127
(defun c:Dir2Text (/ #Pnt1 #List #String #Text #Read)
(cond
((setq #Pnt1 (getpoint "\nSpecify first corner: "))
(setq #List (vl-sort (vl-remove-if-not
'(lambda (x) (wcmatch x "*.dwg"))
(vl-directory-files (getvar 'dwgprefix))
) ;_ vl-remove-if-not
'<
) ;_ vl-sort
#String ""
) ;_ setq
(foreach x #List
(setq #String
(strcat #String (itoa (1+ (vl-position x #List))) " - " (vl-filename-base x) "\\P")
) ;_ setq
) ;_ foreach
(setq #Text (AT:MText #Pnt1 #String 0 nil 1))
(while (eq 5 (car (setq #Read (grread T 15 2))))
(redraw)
(grvecs (list 7
#Pnt1
(list (car (cadr #Read)) (cadr #Pnt1))
(list (car (cadr #Read)) (cadr #Pnt1))
(cadr #Read)
(cadr #Read)
(list (car #Pnt1) (cadr (cadr #Read)))
(list (car #Pnt1) (cadr (cadr #Read)))
#Pnt1
) ;_ list
) ;_ grvecs
(vla-put-width #Text (abs (- (car #Pnt1) (car (cadr #Read)))))
) ;_ while
)
) ;_ cond
(redraw)
(princ)
) ;_ defun
gazzalp
28th Oct 2009, 09:01 pm
alanjt - yes i have tried it and get the following error message: error: no function definition: AT:MTEXT
I put on mtext as per the subroutine then ran this lisp, it asked for corners which i gave and then gave the error. Im not sure how to use it or what it does...
Marco - i am from australia, why?
alanjt
28th Oct 2009, 09:04 pm
alanjt - yes i have tried it and get the following error message: error: no function definition: AT:MTEXT
I put on mtext as per the subroutine then ran this lisp, it asked for corners which i gave and then gave the error. Im not sure how to use it or what it does...
Marco - i am from australia, why?
You have to load the routine posted here and the AT:MText subroutine I linked. It's giving that error because AT:MText is not loaded.
gazzalp
28th Oct 2009, 09:27 pm
I have loaded both and still get the same message. Could you advise me as to what this function actually does? the video files you posted here dont seem to show that it does what i want (maybe you only posted part of what it does?)
ScribbleJ
28th Oct 2009, 09:48 pm
I have to jump on board here and reiterate / strongly emphasize sheet sets. Sheet Set manager can turn sheet management into a dream. As stated it will take time to get it started but it is more than worth the effort you put into it. You would have the solution to your current problem already licked if sheet set was implemented.
alanjt
28th Oct 2009, 09:50 pm
I have loaded both and still get the same message. Could you advise me as to what this function actually does? the video files you posted here dont seem to show that it does what i want (maybe you only posted part of what it does?)
You'll have to excuse the directory list, I'm at home...
15117
It will collect all dwg names located in directory of current drawing and place them in an MText object, based on picked location.
This was a 'to get you started'. Until you post an actual example of what you want, it's difficult to decipher your paragraph. A picture is worth a thousand words.
If you are getting an error saying AT:MText, you do NOT have it loaded.
alanjt
28th Oct 2009, 09:52 pm
I have to jump on board here and reiterate / strongly emphasize sheet sets. Sheet Set manager can turn sheet management into a dream. As stated it will take time to get it started but it is more than worth the effort you put into it. You would have the solution to your current problem already licked if sheet set was implemented.
Ditto......
Why must we deal with this:15128
I'm sure there's a good reason (spam related), it's just annoying.
alanjt
28th Oct 2009, 10:18 pm
LoL
This is just turning into an exercise for fun...
I wanted to fix the 1-9 number to display as 01-09.
15129
(defun c:Dir2Text (/ #Pnt1 #List #Pos #String #Text #Read)
(cond
((setq #Pnt1 (getpoint "\nSpecify first corner: "))
(setq #List (vl-sort (vl-remove-if-not
'(lambda (x) (wcmatch x "*.dwg"))
(vl-directory-files (getvar 'dwgprefix))
) ;_ vl-remove-if-not
'<
) ;_ vl-sort
#String ""
) ;_ setq
(foreach x #List
(setq #Pos (1+ (vl-position x #List)))
(if (< #Pos 10)
(setq #Pos (strcat "0" (itoa #Pos)))
(setq #Pos (itoa #Pos))
) ;_ if
(setq #String (strcat #String #Pos " - " (vl-filename-base x) "\\P"))
) ;_ foreach
(setq #Text (AT:MText #Pnt1 #String 0 nil 1))
(while (eq 5 (car (setq #Read (grread T 15 2))))
(redraw)
(grvecs (list 7
#Pnt1
(list (car (cadr #Read)) (cadr #Pnt1))
(list (car (cadr #Read)) (cadr #Pnt1))
(cadr #Read)
(cadr #Read)
(list (car #Pnt1) (cadr (cadr #Read)))
(list (car #Pnt1) (cadr (cadr #Read)))
#Pnt1
) ;_ list
) ;_ grvecs
(vla-put-width #Text (abs (- (car #Pnt1) (car (cadr #Read)))))
) ;_ while
)
) ;_ cond
(redraw)
(princ)
) ;_ defun
MarcoW
29th Oct 2009, 12:07 pm
Marco - i am from australia, why?
I thought "if you are dutch I might do some PM in dutch..." for it would make things easyer to explain. Nevermind...
I spend a few hours on researching the sheet set manager. I found a lot information but it all ends with the same: creating a set that contains bunch of drawings, layouts etc. I haven't fond anything that helps setting up the actual drawinglist, the connection to the titleblocks as we need it.
Strange... would we both be the only ones on earth that want to do this? No I guess not... So anyone?
The other way to do something is by eattext but I feel limited with the tables:
1. I can't seem to sort the table rows in de- or ascending order
2. Also I can not add or delete collums...
Maybe that somebody over here has experience with eattext, tables and SSM...
Freerefill
29th Oct 2009, 12:27 pm
LoL
This is just turning into an exercise for fun...
I wanted to fix the 1-9 number to display as 01-09.
How about it reads the total number and concatenates the proper number of leading 0's from numbers with digits less than the greatest? Id est, if there were 8, the numbers would be:
1 2 3 4 5 6 7 8
but if there were 12:
01 02 03 04 05 06 07 08 09 10 11 12
and if there were 1,142:
0001 0002 0003 ... 0009 0010 0011 .... 0098 0099 0100 0101 ... 0998 0999 1000 1001 ... 1141 1142
Just an idea to make you work even harder, alanjt :twisted:
By the by, really nice work so far. ^.^b
Glen Smith
29th Oct 2009, 01:32 pm
AutoCAD Electrical includes something called the Project Manager. In this you can do a drawing list report which will create a table with the filename (and a bucnh of other stuff) of all the drawings associated with the project. I'm not sure if the Project Manager is available with any other verticle or not - it sure does make creating index pages easy.
Glen
alanjt
29th Oct 2009, 01:33 pm
How about it reads the total number and concatenates the proper number of leading 0's from numbers with digits less than the greatest? Id est, if there were 8, the numbers would be:
1 2 3 4 5 6 7 8
but if there were 12:
01 02 03 04 05 06 07 08 09 10 11 12
and if there were 1,142:
0001 0002 0003 ... 0009 0010 0011 .... 0098 0099 0100 0101 ... 0998 0999 1000 1001 ... 1141 1142
Just an idea to make you work even harder, alanjt :twisted:
By the by, really nice work so far. ^.^b
Thanks. :)
LoL
That would be interesting, but I've actually got projects to work on today.
alanjt
29th Oct 2009, 07:01 pm
How about it reads the total number and concatenates the proper number of leading 0's from numbers with digits less than the greatest? Id est, if there were 8, the numbers would be:
1 2 3 4 5 6 7 8
but if there were 12:
01 02 03 04 05 06 07 08 09 10 11 12
and if there were 1,142:
0001 0002 0003 ... 0009 0010 0011 .... 0098 0099 0100 0101 ... 0998 0999 1000 1001 ... 1141 1142
Just an idea to make you work even harder, alanjt :twisted:
By the by, really nice work so far. ^.^b
Ask and you shall receive. :wink: Wasn't too terribly difficult. :)
;;; Fix number with leading zeros
;;; #Num - Number to fix
;;; #Length - Number of characters for final string
;;; Alan J. Thompson, 10.29.09
(defun AT:NumFix (#Num #Length / #Str)
(setq #Str (vl-princ-to-string #Num))
(while (< (strlen #Str) #Length)
(setq #Str (strcat "0" #Str))
) ;_ while
#Str
) ;_ defun
Command: (AT:NumFix 1 1)
"1"
Command: (AT:NumFix 1 2)
"01"
Command: (AT:NumFix 1 5)
"00001"
Command: (AT:NumFix 1 8)
"00000001"
Command: (AT:NumFix 1 15)
"000000000000001"
Command: (AT:NumFix 1 16)
"0000000000000001"
Command: (AT:NumFix 1 99)
"00000000000000000000000000000000000000000000000000 00000000000000000000000000000
00000000000000000001"Revised code:
;;; Place current drawing's directory contents (matching *.dwg) in MText
;;; Required Subroutines: AT:MText
;;; Alan J. Thompson, 10.28.09
(defun c:Dir2Text (/ AT:NumFix #Pnt1 #List #Pos #String #Text #Read)
;;; Fix number with leading zeros
;;; #Num - Number to fix
;;; #Length - Number of characters for final string
;;; Alan J. Thompson, 10.29.09
(defun AT:NumFix (#Num #Length / #Str)
(setq #Str (vl-princ-to-string #Num))
(while (< (strlen #Str) #Length)
(setq #Str (strcat "0" #Str))
) ;_ while
#Str
) ;_ defun
(cond
((setq #Pnt1 (getpoint "\nSpecify first corner: "))
(setq #List (vl-sort (vl-remove-if-not
'(lambda (x) (wcmatch x "*.dwg"))
(vl-directory-files (getvar 'dwgprefix))
) ;_ vl-remove-if-not
'<
) ;_ vl-sort
#String ""
) ;_ setq
(foreach x #List
(setq #Pos (AT:NumFix (1+ (vl-position x #List)) (strlen (itoa (length #List)))))
(setq #String (strcat #String #Pos " - " (vl-filename-base x) "\\P"))
) ;_ foreach
(setq #Text (AT:MText #Pnt1 #String 0 nil 1))
(while (eq 5 (car (setq #Read (grread T 15 2))))
(redraw)
(grvecs (list 7
#Pnt1
(list (car (cadr #Read)) (cadr #Pnt1))
(list (car (cadr #Read)) (cadr #Pnt1))
(cadr #Read)
(cadr #Read)
(list (car #Pnt1) (cadr (cadr #Read)))
(list (car #Pnt1) (cadr (cadr #Read)))
#Pnt1
) ;_ list
) ;_ grvecs
(vla-put-width #Text (abs (- (car #Pnt1) (car (cadr #Read)))))
) ;_ while
)
) ;_ cond
(redraw)
(princ)
) ;_ defun
gazzalp
29th Oct 2009, 08:53 pm
Marco, funny thing is i am actually half dutch - from my fathers side, although i dont speak a word of it :p although if you were to type out the days of the week i would recognise them but thats as far as it goes. With the tables from eattext you should be able to sort the tables - when you are first creating it and it comes up with your columns, click on the grey header. For example i had the following:
dwgname revision
001 A
006 B
003 A
If i click on dwg name it puts 1 at the top, then 3 then 6. Click it again and it reverses the order. In terms of adding or deleting columns do you mean once you have created the table? Again when you are making the table if you click on the grey header talked about above you can select "hide columns". Im still hoping to find a way to merge two columns into one...
Powered by vBulletin™ Version 4.1.2 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.