Gorlak Posted November 14, 2019 Posted November 14, 2019 Hello all, I have spent all of today trying to overcome a challenge and, having now been through and tried all the 'exportlayout' search results in this forum, I need to ask for help. I ae attempting to run a batch of the ‘EXPORTLAYOUT’ command within AutoCAD. I have several thousand AutoCAD DWG files, all with a single Layout in Paperspace. I need to convert all of those Layouts, unattended, to Modelspace only, as per the usual result of running the EXPORTLAYOUT command. I would get the result I needed if I ran EXPORTLAYOUT manually for each drawing but that is obviously impractical in time. I believe batching the EXPORTLAYOUT command is feasible, particularly using the JTB SmartBatch tool, which I have installed for trial. We also have BatchInDatabase installed but that does not have the required function. Does anyone have a suitable LSP or SCR file that I can run via JTB SmartBatch to achieve a nice set of Modelspace-only drawings? Thanks and regards, Howard Quote
BIGAL Posted November 15, 2019 Posted November 15, 2019 Ok as 1 only layout easier way is to use CHSPACE All <enter> (setvar 'ctab "model") save All done Needs a little bit more if the layout names are all different so to set to the layout before running please advise. script open dwg1 (load "movelayout") open dwg1 (load "movelayout") etc Will make sure a layout is current. (setq doc (vla-get-activedocument (vlax-get-acad-object))) (vlax-for lay (vla-get-Layouts doc) (setvar 'ctab (vla-get-name lay)) ) Quote
Gorlak Posted November 15, 2019 Author Posted November 15, 2019 Hi BIGAL, thank you for the suggestion. I tried the CHSPACE All command, but that does not achieve what is needed unfortunately. The CHPACE command moves the Paperspace objects, such as the title sheet, to Modelspace, but the command does not 'trim' the Modelspace content to the viewports. For clarity, I have attached a BEFORE and AFTER image of what I need to achieve, which is essentially the standard behaviour of EXPORTLAYOUT command. What I can't work out is ho to batch apply that command over multiple separate DWG files. I have tried using the JTB SmartBatch tool to apply the following LSP code to my test drawings, but without success, so far. (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) ) When running the SmartBatch tool, the drawing stops and requests ‘ERASE Select objects’, as per attached screenshot. Also, on all occasions of running the batch, no new drawings were created. Essentially, the EXPORTLAYOUT didn’t appear to run. Any suggestions what I'm doing wrong? Quote
BIGAL Posted November 15, 2019 Posted November 15, 2019 It may be this line needs a location to save the dwg as well. Tried without then with and was ok. (setq fielprefix (strcat (getvar 'dgwprefix) filename "-" layname)) 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.