Author Topic: Separate layouts to individual dwg files.  (Read 15031 times)

0 Members and 1 Guest are viewing this topic.

CADaver

  • Guest
Separate layouts to individual dwg files.
« on: October 31, 2007, 10:27:45 AM »
A client asked, I told him I'd check.   I searched here but no luck.  Is there a tool out there somewhere that will take a multi-layout tabbed file and make individual files with one layout tab each??

(Might as well explode dimensions while you're at it, sheesh!)

Slimę

  • Needs a day job
  • Posts: 6560
  • The Dude Abides...
Re: Separate layouts to individual dwg files.
« Reply #1 on: October 31, 2007, 10:38:40 AM »
I believe that ToolPac from DotSoft has that ability.
I drink beer and I know things....

deegeecees

  • Guest
Re: Separate layouts to individual dwg files.
« Reply #2 on: October 31, 2007, 10:41:50 AM »
Sounds easy enough. Pseudo code:

Get # of layouts to list
Create a copy of dwg file for each layout (length of list)
Delete all but 1 of the layouts for each dwg, iterating through the list

I think Alan can be of more help on this.


LE

  • Guest
Re: Separate layouts to individual dwg files.
« Reply #3 on: October 31, 2007, 10:42:23 AM »
Randy;

Have a look in the lisp section of www.jtbworld.com

Here is a direct link:
http://www.jtbworld.com/lisp/layoutstodwgs.htm

There is one lisp there, that it does that.
« Last Edit: October 31, 2007, 10:49:24 AM by LE »

ronjonp

  • Needs a day job
  • Posts: 7052
Re: Separate layouts to individual dwg files.
« Reply #4 on: October 31, 2007, 11:29:43 AM »
Here is my rewrite of Jimmy's routine. I've had better luck with this finishing the job plus it ignores tabs with nothing on them.

Code: [Select]
(defun c:layoutstodwgs (/ ct doc exprt fda lays msg pre)
  (vl-load-com)
  (setq fda   (getvar 'filedia)
pre   (getstring "\n Enter filename prefix: ")
exprt (getvar 'expert)
ct    (getvar 'ctab)
doc   (vla-get-activedocument (vlax-get-acad-object))
lays  (vla-get-layouts doc)
msg   ""
  )
  (setvar 'filedia 0)
  (setvar 'expert 5)
  (setvar 'tilemode 1)
  (command "_ucs" "_w")
  (foreach l (layoutlist)
    (setvar 'ctab l)
    (if (> (sslength (ssget "_x" (list (cons 410 (getvar 'ctab))))) 1)
      (progn (vla-endundomark doc)
     (vla-startundomark doc)
     (vlax-for x lays
       (and (/= (vla-get-name x) (getvar 'ctab)) (vl-catch-all-apply 'vla-delete (list x)))
     )
     (command "_-wblock" (strcat (getvar 'dwgprefix) pre l) "*")
     (setq msg (strcat (getvar 'dwgprefix) pre l ".dwg created.\n" msg))
     (vla-endundomark doc)
     (command "_u")
      )
      (setq msg (strcat "Tab " l " has nothing on it and skipped.\n" msg))
    )
  )
  (setvar 'filedia fda)
  (setvar 'expert exprt)
  (setvar 'ctab ct)
  (princ msg)
)
« Last Edit: January 14, 2014, 08:52:24 AM by ronjonp »

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

CAB

  • Global Moderator
  • Seagull
  • Posts: 10369
Re: Separate layouts to individual dwg files.
« Reply #5 on: October 31, 2007, 11:58:47 AM »
I tried one or two of these routines in the past and the problem was that they exported the objects
that were in paper space but left behind the objects visible in the viewports. So that was not good
for my use. I never pursed it as my need for such a routine was a one time thing.
Maybe Ron's routine will do that?  8-)
I've reached the age where the happy hour is a nap. (░┐░)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

ronjonp

  • Needs a day job
  • Posts: 7052
Re: Separate layouts to individual dwg files.
« Reply #6 on: October 31, 2007, 12:03:16 PM »
I tried one or two of these routines in the past and the problem was that they exported the objects
that were in paper space but left behind the objects visible in the viewports. So that was not good
for my use. I never pursed it as my need for such a routine was a one time thing.
Maybe Ron's routine will do that?  8-)

From my tests it grabbed all that is needed.

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Separate layouts to individual dwg files.
« Reply #7 on: October 31, 2007, 12:09:11 PM »
Here is my entry.  With some slight modifications it could be used with ObjectDBX.
Code: [Select]
(defun c:Tabs->Drawings (/ ActDoc MsObjList PsObjList dbxApp oVer FirstPass)

(setq ActDoc (vla-get-ActiveDocument (vlax-get-Acad-Object)))
(vlax-for obj (vla-get-ModelSpace ActDoc)
(setq MsObjList (cons obj MsObjList))
)
(vlax-for lo (vla-get-Layouts ActDoc)
(if (/= (vla-get-Name lo) "Model")
(progn
(setq FirstPass T)
(vlax-for obj (vla-get-Block lo)
(if (not FirstPass)
(setq PsObjList (cons obj PsObjList))
(setq FirstPass nil)
)
)
(setq dbxApp
(if (< (atoi (setq oVer (substr (getvar "acadver") 1 2))) 16)
(vla-GetInterfaceObject (vlax-get-acad-object) "ObjectDBX.AxDbDocument")
(vla-GetInterfaceObject (vlax-get-acad-object) (strcat "ObjectDBX.AxDbDocument." oVer))
)
)
(vlax-invoke ActDoc 'CopyObjects MsObjList (vla-get-ModelSpace dbxApp))
(vlax-invoke ActDoc 'CopyObjects PsObjList (vla-get-PaperSpace dbxApp))
(vla-SaveAs dbxApp (strcat (vla-get-Path ActDoc) "\\" (vla-get-Name lo)))
(vlax-release-object dbxApp)
(setq dbxApp nil)
(setq PsObjList nil)
)
)
)
(princ)
)
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CADaver

  • Guest
Re: Separate layouts to individual dwg files.
« Reply #8 on: November 01, 2007, 09:29:17 AM »
Thanks guys appreciate the help.  I'll pass the info off to the client if thats okay with everyone who offered help?

ronjonp

  • Needs a day job
  • Posts: 7052
Re: Separate layouts to individual dwg files.
« Reply #9 on: November 01, 2007, 09:51:39 AM »
Thanks guys appreciate the help.  I'll pass the info off to the client if thats okay with everyone who offered help?

Not a problem here....except the logic behind it. :-D

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

T.Willey

  • Needs a day job
  • Posts: 5218
Re: Separate layouts to individual dwg files.
« Reply #10 on: November 01, 2007, 11:02:31 AM »
Thanks guys appreciate the help.  I'll pass the info off to the client if thats okay with everyone who offered help?
I have no problem.  Mine will overwrite though without warning, FYI.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

CADaver

  • Guest
Re: Separate layouts to individual dwg files.
« Reply #11 on: November 01, 2007, 11:04:09 AM »
Thanks guys appreciate the help.  I'll pass the info off to the client if thats okay with everyone who offered help?

Not a problem here....except the logic behind it. :-D
I think I'll add code to explode all the dimensions while we're at it.

CADaver

  • Guest
Re: Separate layouts to individual dwg files.
« Reply #12 on: November 01, 2007, 11:05:08 AM »
Thanks guys appreciate the help.  I'll pass the info off to the client if thats okay with everyone who offered help?
I have no problem.  Mine will overwrite though without warning, FYI.
Even better.  I haven't tested any of them, and I will indicate such to the client.  Thanks for the help.

Bob Wahr

  • Guest
Re: Separate layouts to individual dwg files.
« Reply #13 on: November 01, 2007, 11:13:51 AM »
Some other functionality you might want to consider

explode all blocks
for each thingy in the DWuG
get layer of thingy
apply color setting of layer to thingy
apply linetype setting of layer to thingy
change layer to 0


ronjonp

  • Needs a day job
  • Posts: 7052
Re: Separate layouts to individual dwg files.
« Reply #14 on: November 01, 2007, 11:49:27 AM »
We could also move all XREF's to arbitrary base points and change all the scale factors to random numbers.  :-D

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC