Jump to content

LSP or SCR to batch EXPORTLAYOUT


Gorlak

Recommended Posts

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

 

Link to comment
Share on other sites

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))
)

 

Link to comment
Share on other sites

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?

 

BEFORE (Paperspace Layout).png

AFTER (Modelspace Layout).png

LSP file content.png

SmartBatch setup.png

ERASE Select objects.png

Link to comment
Share on other sites

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))

 

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...