ATS1211 Posted July 11, 2011 Posted July 11, 2011 Hello everyone, I'm very, very new to scripting in AutoCAD and was wondering if anyone has ever wrote a VB or LISP macro for batch exporting layouts to DWG's. I have a client who wants each layout in a seperate DWG and I have about 5500 layouts...so using exportlayout that many times would be really tedious and time consuming , which is why I'm coming to you folks for a little help! I am currently running AutoCAD 2011 if it helps! Thanks! Quote
BIGAL Posted July 12, 2011 Posted July 12, 2011 Manually you coluld use chspace then wblock to create a new dwg. Only difficult bit would be if you have multiple viewports. I think I have seen this request before though searching can be time consuming but 5000 dwgs ! just keep trying key words. Quote
SLW210 Posted July 12, 2011 Posted July 12, 2011 I am moving your thread to the .NET, ObjectARX & VBA forum. Like stated, a search might return something. You said 5500 layouts, but how many actual drawings are they in? Hopefully you are charging enough to make this worth your time. Quote
ATS1211 Posted July 12, 2011 Author Posted July 12, 2011 I am moving your thread to the .NET, ObjectARX & VBA forum. Like stated, a search might return something. You said 5500 layouts, but how many actual drawings are they in? Hopefully you are charging enough to make this worth your time. Thanks for moving the thread. I have approximately 550 drawings with 10 layouts per drawing, it's worth my time, I'm just looking for a way to save some as that would make it worth even more. I've searched a lot and will continue searching; so far i have only found other threads that have really no replies, I'm sure I'll dig up something though. Quote
SLW210 Posted July 12, 2011 Posted July 12, 2011 this lisp it will help That just created a new drawing model space and paper space. Quote
ATS1211 Posted July 12, 2011 Author Posted July 12, 2011 That just created a new drawing model space and paper space. Yes, not really what I was looking to do, but I'm continuing to search and will play around with that script to see if I can modify it somehow to delete everything in model space that is not in paper space. Very neat script btw Quote
e.mounir Posted July 13, 2011 Posted July 13, 2011 Are you used my lisp or not this lisp convert each layouts to separate drawing Quote
SLW210 Posted July 13, 2011 Posted July 13, 2011 Are you used my lisp or not this lisp convert each layouts to separate drawing I tested it and only got an exact copy of my drawing, model space and paper space. Quote
ATS1211 Posted July 13, 2011 Author Posted July 13, 2011 I tested it and only got an exact copy of my drawing, model space and paper space. I tested it as well and I got the same exact thing. This would work if it was able to delete everything in model space that was not visible in the paper space layout that it created. Quote
ATS1211 Posted July 15, 2011 Author Posted July 15, 2011 (edited) I figured it out: ; LayoutsToDwgs (defun C:ltd (/ lo loList) (setvar "FILEDIA" 0) (foreach lo (layoutlist) (progn (setvar "CTAB" lo) (command "exportlayout" "") ) ) (setvar "FILEDIA" 1) ) Thanks for everyone's input! Edited July 19, 2011 by SLW210 Quote
BIGAL Posted July 19, 2011 Posted July 19, 2011 Do you know how to create a script to process the drawings open dwg1 (load "layoutstodwgs")(ltd) close "N" open dwg2 (load "layoutstodwgs")(ltd) close "N" I would take the defun out just run it also start cmd cd to directory dir *.dwg >dirlist /b creates a txt file of dwg names put in word etc and add open etc Quote
ATS1211 Posted July 19, 2011 Author Posted July 19, 2011 Do you know how to create a script to process the drawings open dwg1 (load "layoutstodwgs")(ltd) close "N" open dwg2 (load "layoutstodwgs")(ltd) close "N" I would take the defun out just run it also start cmd cd to directory dir *.dwg >dirlist /b creates a txt file of dwg names put in word etc and add open etc This may be a silly question; but what do you mean by "process the drawings"? On a side note, I'm not sure how to do this but does anyone know if it would be possible to have the script open the drawing, delete the layer the view port was on and move the drawing in model space so that the lower left border is aligned with the origin? I appreciate all the help! Quote
SLW210 Posted July 19, 2011 Posted July 19, 2011 Please read Code Posting Guidelines. I fixed it for you THIS time. Quote
ATS1211 Posted July 19, 2011 Author Posted July 19, 2011 Please read Code Posting Guidelines. I fixed it for you THIS time. Thanks! Sorry about that... Quote
homasa Posted August 23, 2012 Posted August 23, 2012 Well guys thx a lot i found this thread very very usefull. But can this last script be modified to: 1) export all the files open in cad??? 2) instead of separate the file name and layout name with an "_" can this be changed to "." thx regards Quote
ATS1211 Posted August 23, 2012 Author Posted August 23, 2012 Wow, old thread! Are you looking to have multiple drawings open with layouts in each drawing and a script that will export all the layouts simultaneously? Why not just run the command in each drawing? If you are, you should look into Script pro or something that can batch run the routine I wrote above. Edit: I just noticed you edited your post. 1) See my response above 2) Why not use a batch rename program outside AutoCAD to change the underscore to a dot? The extra dot may also cause conflicts with other programs, underscores are preferred IMHO. Quote
homasa Posted August 23, 2012 Posted August 23, 2012 Hello Ats1211 well i try to optimize and not using external coding so i discover for the name that i could get the file name by: (setq fielprefix (getvar 'dwgname)) but i still cant join it with layout name meanwhile i tryied this (without success): (setq fielprefix (strcat ((getvar 'dwgname)) "." lo) also triyed: (setq fielprefix (strcat ((getvar 'dwgname)) "." CTAB) Meanwhile i think there is a way to do this with all the open drawings but didnt figured it out. Someone can help??? regards Wow, old thread! Are you looking to have multiple drawings open with layouts in each drawing and a script that will export all the layouts simultaneously? Why not just run the command in each drawing? If you are, you should look into Script pro or something that can batch run the routine I wrote above. Edit: I just noticed you edited your post. 1) See my response above 2) Why not use a batch rename program outside AutoCAD to change the underscore to a dot? The extra dot may also cause conflicts with other programs, underscores are preferred IMHO. Quote
homasa Posted August 23, 2012 Posted August 23, 2012 well i made it run by using : ; LayoutsToDwgs (defun C:ltd (/ lo loList filename layname fielprefix) (setvar "FILEDIA" 0) (foreach lo (layoutlist) (progn (setvar "CTAB" lo) (setq filename (cadr (fnsplitl (getvar "dwgname")))) (setq layname (GETVAR "CTAB")) (setq fielprefix (strcat filename "." layname)) (command "exportlayout" fielprefix) ) ) (setvar "FILEDIA" 1) ) still misses batch file. meanwhile i am doing it file by file Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.