I've searched and searched and cannot find a solution to my problem.
I am currently working on a project for a client that includes 6 seperate dwgs each with about 13 layouts in them. The client wants 78 different dwgs (one for each layout). However, they want the layout to be transposed into model space rather than paper space. The layouts have multiple viewports in them so "chspace" is not a practical solution.
I know you can right-click on the layout tab and choose "Export Layout to Model...", but I am looking for a way to automate this approach.
There are others posts with LISPs that export each layout to a seperate dwg. However, these LISPs only move each layout into a seperate dwg. I'm looking to move the layout (title block and all) into a seperate dwg AND into model space.
If someone could provide a LISP that could do this, that would be amazing. I've never done programming in AutoCAD but could learn if I had to. So my second option would be if someone could layout a programming approach without the coding and I'll take it from there.
Thanks!
Welcome to the Autodesk Community, WillHBK
A quick and dirty one...
Give it a try.
(defun c:test ( / BASE LST OLD_DIA) (setq old_dia (getvar 'FILEDIA) base (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME))) ) (setvar 'FILEDIA 0) (setq lst (layoutlist)) (foreach l lst (command "_.ctab" l "exportlayout" (strcat base "-" l) ) ) (setvar 'FILEDIA old_dia) (princ) )
HTH
Henrique
EXCELLENT !
This is a routine that I never really thought I would use... BUT after trying it.... AWESOME !!!
Mel
@Anonymous wrote:
EXCELLENT !
This is a routine that I never really thought I would use... BUT after trying it.... AWESOME !!!
Mel
Mel, I'm glad it's useful to you!
Henrique
Thanks for the warm welcome. I've always found what I've needed on the forums and never actually had to post but I figured it was time to create a profile and join the community.
The LISP works well. Thanks for the help. It'll definitely save me lots of time. The only problem is that I get an "unhandled exception" error notice for each sheet when I export.
The error reads:
"Unhandled exception has occurred in a component in your application. If you click Continue, the application will ignore this error and attempt to continue. The given key was not present in the dictionary."
Details include:
"Application does not support just-in-time (JIT)
debugging. See the end of this message for details.
************** Exception Text **************
System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.
at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
at Autodesk.AutoCAD.ExportLayout.CustomObjectConverter.ResetLineTypeId()
at Autodesk.AutoCAD.ExportLayout.CustomObjectConverter.Convert(Database database)
at Autodesk.AutoCAD.ExportLayout.Engine.ExportLayout(ObjectId srcLayoutId)
at Autodesk.AutoCAD.ExportLayoutUI.Commands.ExportLayout()
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()
************** Loaded Assemblies **************
A bunch of other stuff, then:
----------------------------------------
************** JIT Debugging **************
Application does not support Windows Forms just-in-time (JIT)
debugging. Contact the application author for more
information.
Is this a common error for this type of export? Is there a simple solution? I've downloaded the service pack already, so it's not that.
Thanks for all the help.
Will
You're welcome, Will
Is this a common error for this type of export?
I never had it.
If you use the right-click on the layout tab to export, do you receive the same error?
Henrique
I get the same error when right-clicking. Could it be the number of layouts in my file? When I run the LISP on a file with only one layout, it works fine and I don't get an error message. I ran it on a file with two layouts and got the error.
Any ideas?
Will
@Anonymous wrote:
I get the same error when right-clicking. Could it be the number of layouts in my file? When I run the LISP on a file with only one layout, it works fine and I don't get an error message. I ran it on a file with two layouts and got the error.
Any ideas?
Will
Will,
I tested the code with 15 layouts without error.
Sorry, but I have no idea why it happens...
Henrique
I have tried the code with a drawing with about 15 layouts and I do not receive an error.
I am unable to assist.
I'd just like to say thank you to hmsilva - saved me a lot of time. I had a ~80 layouts per drawing...
A little note to the "Unhandled exception" problem, as I've experienced it a lot. I realize it's a bit late for Will, but anyway.
This error is a problem with the drawing, not the script. Try to export the problematic layout manually, to see what I mean. I fight it with purge/audit and sometimes I have to remove all except the needed layout, to export it successfuly. Rarely saving to older dwg version helps and DXFOUT too.
I have a problem with this lisp then I trying to invoke it on dwg with xrefs. Do you have any solution for this problem?
@apelbaum2014 wrote:
I have a problem with this lisp then I trying to invoke it on dwg with xrefs. Do you have any solution for this problem?
Can you be more specific?
What is the problem?
Henrique
Hi.. Thank you for the LISP.. This is one of the best LISP for autocad..
however, is it possible to make it more complete, such as having a Save As Dialog before it starts exporting?
i use 2013 and my client uses 2007, it end up i have to open it again one by one to save as the drawing to 2007 before i can send it...
another thing...
I found a way to minimize the "unhandled exception" everytime we export the layout..
It is because the drawing contain Xclip-ed reference or blocks...
so at the end you may want to Bind the xref, explode the xclips... and redraw the boundary as shown in the layouts..
thanks..
jagalabilawa
@Anonymous
@Anonymous
Anyone else have an issue when exporting to existing files? It seems to crash and fail when files already exist. I am trying to incorporate the iffindfile function and save if existing, but I am facing some issues. Any help on getting this script to overwrite existing files when exporting? Thanks.
Thank You very much sir , It works
I'm a bit late, but here's the solution to that:
(defun c:test ( / BASE LST OLD_DIA l layrexp)
(setq old_dia (getvar 'FILEDIA)
base (strcat (getvar 'DWGPREFIX) (vl-filename-base (getvar 'DWGNAME)))
)
(setvar 'FILEDIA 0)
(setq lst (layoutlist))
(foreach l lst
(setq layrexp (strcat base "-" l))
(Setvar 'ctab l)
(if (findfile (layrexp))
(command "_exportlayout" layrexp "_y") ; if it exists, answer 'yes' to overwrite
(command "_exportlayout" layrexp)
)
)
(setvar 'FILEDIA old_dia)
(princ)
)