About the same thing we do.
I use these Export routines to create our backgrounds and automate as much as possible.
One of those things you want to click and go get a cup of coffee, come back, you have a background file.
Depends completely on how complex the project is though.
Including the original filename helps people a year or so later still find out how to update the project even if they didn't set it up.
;;; Create an exported Zbase-xref file from architectural files
(DEFUN c:zbx()
;====================================================================== Turn on command line responses
(setvar "CMDECHO" 0); DO NOT CHANGE THIS LINE
;======================================================================
;(alert "This routine creates an exported bound version of all the files in the directory you select!")
(command "TILEMODE" 1)
(command "Zoom" "Extents")
(command "Undo" "Begin")
;======================================================================
(autoload "zxv" '("zxv"))
(c:ZXV)
;====================================================================== Delete Page Setups & Set Plot Style to KTA.ctb
(prompt "\n Delete Old Page Setups !!!")
(autoload "dps" '("dps"))
(c:dps)
(princ "\n All Layouts Deleted!")
(princ)
;======================================================================
(prompt "\n Detach All Image References.....")
(autoload "ix" '("ix"))
(c:ix)
;======================================================================
(princ "\n Standard KTA drawing variables initiated!!")
(command "-style" "Standard" "archquik.shx" "0" "1" "0" "No" "No")
(princ "\n Archquik.shx is the Standard font!")
(princ)
;====================================================================== Control Line Scaling
(command "PSLTSCALE" 0)
(command "MSLTSCALE" 0)
;======================================================================
(princ "\n MSpace & PSpace LTScale Varaibles set to 0!! \n Defaults to LTSCALE settings now!")
(princ)
;====================================================================== Layer setups for backgrounds
(prompt "\n Thawing and Showing all layers.")
(command "layer" "t" "*" "on" "*" "u" "*" "")
(command "Zoom" "Extents")
(command "regenall")
;======================================================================
(prompt "\n XREF binding begins!")
(prompt "\n BINDTYPE set to Insert for all XREF's!")
(command "BINDTYPE" 1)
;(autoload "XRB" '("XRB"))
;(c:XRB)
(autoload "XRBIND" '("XRBIND"))
(c:XRBIND)
;======================================================================
;(prompt "\n Re-Load All XREF's as a precaution........")
;(autoload "rax" '("rax"))
;(c:rax)
;======================================================================
(princ "\n All XREF's Re-Loaded!!")
;======================================================================
(prompt "\n Set Layer 0 as current Layer.")
(command "_.layer" "s" "0" "")
;======================================================================
(autoload "repair" '("repair"))
(c:repair)
;======================================================================
(princ "\n Standard KTA drawing variables Loaded!!")
;======================================================================
(princ "\n Setting All Objects & Entities to ByLayer!!!!!!")
(command "setbylayer" "all" "" "yes" "yes")
(command "chprop" "all" "" "c" "bylayer" "")
(autoload "mkbylayer" '("mkbylayer"))
(c:mkbylayer)
;======================================================================
(princ "\n Setting all DimStyles ByLayer......")
(autoload "DS2BL" '("DS2BL"))
(c:DS2BL)
;======================================================================
(princ "\n All Possible Objects, DimStyles, Lines, Arrows, & Text set to ByLayer!!")
;====================================================================== Layer setups for backgrounds
(autoload "MAKE8" '("MAKE8"))
(c:MAKE8)
(prompt "\n All Layers Made Color 8 Grey !!!")
(command "_.layer" "c" "7" "DEFPOINTS" "")
(prompt "\n Layer Defpoints Color is White!")
(autoload "hatch19" '("hatch19"))
(c:HATCH19)
(autoload "LRD" '("LRD"))
(c:LRD)
(alert "\n All KTA NCS Layer names (if present) set to proper colors & descriptions!!!")
;(autoload "8" '("8"))
;(c:8)
;(autoload "19" '("19"))
;(c:19)
;======================================================================
(command "regenall")
(prompt "\n Layer colors completed !!!")
;======================================================================
(prompt "\n Setting All 3-D Items to zero height in Z-Axis!!! ---Please be patient---")
(defun z-zero (/ a ss len e o10 l10 n10 f o11 l11 n11 o39 n39)
(setq a 0)
(princ "\n Changes entities' z-coordinate to 0 (2D from 3D)." )
(setq ss (ssget "_X" ))
(setq len (sslength ss))
(repeat len
(setq e (entget (ssname ss a)))
(setq o10 (assoc 10 e))
(setq l10 (list (cadr (assoc 10 e)) (caddr (assoc 10 e)) 0.0))
(setq n10 (cons 10 l10))
(setq f (subst n10 o10 e))
(entmod f)
(setq a (1+ a))
);end repeat
(setq a 0)
(repeat len
(setq e (entget (ssname ss a)))
(setq o11 (assoc 11 e))
(setq l11 (list (cadr (assoc 11 e)) (caddr (assoc 11 e)) 0.0))
(setq n11 (cons 11 l11))
(setq f (subst n11 o11 e))
(entmod f)
(setq a (1+ a))
);end repeat
(setq a 0)
(repeat len
(setq e (entget (ssname ss a)))
(setq o39 (assoc 39 e))
(setq n39 (cons 39 0))
(setq f (subst n39 o39 e))
(entmod f)
(setq a (1+ a))
);end repeat
)
;======================================================================
(z-zero)
;======================================================================
;(prompt "\n Normal Detach of all XREF's not found!")
; (command "-xref" "Detach" "*")
;(prompt "\n Selecting ALL Object's!")
; (command "SELECT" "ALL" "")
;(prompt "\n Exploding New Blocks of these XREF Object's!")
; (command "EXPLODE" "LAST" "")
;======================================================================
;(princ "\n Objects in audit phase. Please be patient......")
;(command "audit" "y")
;(command "qsave")
;======================================================================
(princ "\n Purging empty file entries.......")
(c:purgeall)
(princ "\n")
;(command "saveas" "2007" "" "y")
(princ "\n File Purge Complete !!!!!!......")
;============================================== begin file name structure
(setq myPath (getvar "DWGPREFIX"))
(princ "\n Current File Path : ")
(princ myPath)
(setq myFile (getvar "DWGNAME"))
(princ "\n Current File Name : ")
(princ myFile)
(princ "\n Stripped File Name : ")
(setq strippedFile (vl-filename-base myFile))
(princ strippedFile)
(princ "\n File Prefix :")
(setq newPrefix (strcase "ZBaseBND-"))
(princ newPrefix)
(princ "\n File Extension :")
(setq newExtension (strcase ".dwg"))
(princ newExtension)
(setq newName (strcat newPrefix strippedFile newExtension))
(princ "\n New file name : ")
(princ newName)
(setq newFile (strcat myPath newName))
(princ "\n New file to Open :\n")
(princ newFile)
(princ "\n continue to Export.....\n")
(alert "
\n *----------------------- AEC Objects will be removed. --------------------------*
\n 1.) XREF's have been bound.
\n 2.) You will find your file with the 'ZBaseBND-' as the prefix in the filename.
\n 3.) File will be opened for you after clicking OK and export is complete.
\n 4.) You have just made a KTA Bound XREF for project use.
\n 5.) You may need to Burst the XREF's that are now Blocks in the file.
\n 6.) Cleanup any unnecessary items.
\n 7.) If MTEXT Objects have not adopted KTA's background colors, \n run the StripMText command. Follow the prompts.
\n 8.) Use the MKB command to fix any other colors not 8 or 19.
\n 9.) This file will undo all changes before saving and closing."
)
;========================================== Begin Export Function
;(command "-exporttoautocad")
;(command "Format" "2007")
;(command "Prefix" "ZBaseBND-")
;(command "Suffix" ".")
;(command "T")
;(command "Insert")
;(command "Bind" "Yes" "" "")
(defun myExport07()
(princ "\n Begin 2007 -ExportToAutoCAD functions :\n")
(command "-exporttoautocad")
(command "Format" "2007")
(command "T")
(command "Insert")
(command "Prefix" "ZBaseBND-")
;(command "Suffix" ".")
(command "Bind" "Yes" "" "")
(princ)
)
(defun myExport08()
(princ "\n Begin 2008 -ExportToAutoCAD functions :\n")
(command "-exporttoautocad")
(command "Format" "2007")
(command "T")
(command "Insert")
(command "Prefix" "ZBaseBND-")
;(command "Suffix" ".")
(command "Bind" "Yes" "" "")
(princ)
)
(defun myExport()
(princ "\n Begin 2010 -ExportToAutoCAD functions :\n")
(command "-exporttoautocad")
(command "Format" "2007")
(command "Prefix" "ZbaseBND-")
(command "Suffix" ".")
(command "T")
(command "Insert")
(command "Bind" "Yes" "" "")
(princ)
)
;============================== AutoCAD 2007 =====================================
; ACADVER = "17.0s (LMS Tech)"
;(if (= (vlax-product-key) "Software\\Autodesk\\AutoCAD\\R17.0\\ACAD-5001:409")
(if (= (getvar "ACADVER") "17.0s (LMS Tech)")
(myExport07)
(princ)
) ;End If
; ACADVER = "17.1s (LMS Tech)"
;============================== AutoCAD MEP 2008 =================================
; ACADVER = "17.2s (LMS Tech)"
;(if (= (vlax-product-key) "Software\\Autodesk\\AutoCAD\\R17.2\\ACAD-7006:409")
(if (= (getvar "ACADVER") "17.1s (LMS Tech)")
(myExport08)
(princ)
) ;End If
;============================== AutoCAD MEP 2009 =================================
; ACADVER = "17.2s (LMS Tech)"
;(if (= (vlax-product-key) "Software\\Autodesk\\AutoCAD\\R17.2\\ACAD-7006:409")
(if (= (getvar "ACADVER") "17.2s (LMS Tech)")
(myExport)
(princ)
) ;End If
;============================== AutoCAD MEP Acad 2010 =================================
; ACADVER = "17.2s (LMS Tech)"
;(if (= (vlax-product-key) "Software\\Autodesk\\AutoCAD\\R17.2\\ACAD-7006:409")
(if (= (getvar "ACADVER") "18.0s (LMS Tech)")
(myExport)
(princ)
) ;End If
;============================== AutoCAD MEP 2010 =================================
; ACADVER = "17.2s (LMS Tech)"
;(if (= (vlax-product-key) "Software\\Autodesk\\AutoCAD\\R17.2\\ACAD-7006:409")
(if (= (getvar "ACADVER") "18.1s (LMS Tech)")
(myExport)
(princ)
) ;End If
;=================================== Undo & save to leave original file as found
(princ "\n Begin to return file to original state :\n")
(command "Undo" "End")
(command "Undo" "Back" "Y")
(command "saveas" "2007" "" "y")
;(command "qsave")
;===================================
(princ "\n Locating New file to Open :\n")
(if (= (findfile newFile) nil)
(alert "\n Could not locate file.")
) ; end if
(defun OpenFile ()
(vla-open
(vla-get-documents
(vla-get-application (vlax-get-acad-object))
)
newFile
)
) ;_defun
(OpenFile)
;====================================================================== Turn on command line responses
(setvar "CMDECHO" 1); DO NOT CHANGE THIS LINE
;======================================================================
(princ "\n File open successful!!")
(command "close")
)