5 Better Civil 3D Update Batch Save Script Tips

Tags Civil 3D 2020, Civil 3D 2019, Batch Save, Upgrade, Update, implementation, lisp, script, scriptcall

Do you still manually upgrade each and every Civil 3D template, Civil 3D Style resource drawing, and all your Civil 3D project drawings to a new Civil 3D Update or release? Yuck.

Even if your organization doesn’t quickly upgrade to the latest new Civil 3D release, there will always be Civil 3D Updates you must deal with. These days changes to the Civil 3D Object Model are as likely to happen in Updates as new releases.

We Live with the Facts of Life in Civil 3D Land

There is certainly an apt metaphor about parents, children, and how we train them up or not involved here. From our personal and corporate perspective there are either or both Blessings and/or Curses that result.

See the Civil 3D Updates and Object Model Changes post and the linked Civil 3D Interoperability posts series. ‘Nuff said.

The Civil 3D Batch Save Utility

The Civil 3D Batch Save Utility is one of those precious Autodesk maintenance tool treasures that can remain unused, hidden, or forgotten. I am calling the utility a precious treasure not calling it My Precious.

The Civil 3D Batch Save Utility is purpose built to help you update, cope with, and see the effects of the latest and greatest Autodesk Civil 3D code on your work and production environment. Therefore, Batch Save does the same for entire Civil 3D projects, but only if you know what you are doing, how the tool works, and what the tool does.

The continuous development and maintenance of the Framework for Civil 3D depends on the systematic employment Civil 3D Batch Save Utility. The Framework supports multiple releases of Civil 3D in multiple Framework for Civil 3D Release flavors including the latest new Framework for Civil 3D Release 8 AIA. Check it out.

This means I personally have more than a little bit of real-world experience with Civil 3D Batch Save Utility in the systems management/maintenance context and also in the Civil 3D project upgrade context as well.

I believe many of you out there in Civil 3D Land could benefit from some of the hard-won skill.

What Batch Save Does

Batch Save is a managed scripting tool that runs Civil 3D in a headless environment or command line only environment. The basic goal of the Batch Save tool is to allow us to upgrade drawings or templates of any kind from one Civil 3D incremental Update or full release to another in mass based on one or more selected folders to process and an initial selected script.

Don’t we all wish Autodesk would provide an updated raw AutoCAD version of Batch Save. Please put it or vote for that on the AutoCAD 2021 Wish List. That would mean a raw ACAD version would need to be AutoCAD Toolset aware.

Autodesk released the Civil 3D Batch Save Utility with the initial Civil 3D 2019 release, but the tool works for most, if not any recent, release of Civil 3D you have installed on the local machine. Batch Save wasn’t installed with your older release of Civil 3D. However, you can now separately download the Batch Save Utility for older releases of Civil 3D from your Autodesk subscription account page.

Make sure you have the latest Updates for your release of Civil 3D installed. The Civil 3D Batch Save Utility also may reference the latest version of the Civil 3D Object Enabler.

Read the Thankful Civil 3D Upgrades with Batch Save post for other essential Batch Save details, mechanics, and how to hints. I do not repeat some very important Batch Save stuff here.

Batch Save supports SCRIPT, SCRIPTCALL (therefore chained scripts), and Lisp loads and function calls. In other words, most code that runs in any of these AutoCAD tools can be run against any selected folder and drawing collection.

The Poetry Couplets of Batch Save

Based on a good number of runs up and down the mountain, trial and error, and some pain and suffering, I now manage almost all of my Batch Save work as couplets of script and lsp files. As I recall, the supplied Autodesk examples do some of that too.

5 Better Batch Save Script Tips

Number One
Initial Batch Save Script Tool

The initial required Batch Save script employs a chain of one or more SCRIPTCALLs.
Yes. You can load a bunch of lsp and process multiple scripts all at once in a single SCRIPT but this tends to be much more difficult to test and QAQC.

Dividing the work into matched couplets of SCR and LSP allows you to reuse tested and proven functionality in the pairs differently as the circumstances require.

Example

An Example of a Simple Clean and Update Script contents

;Call this script with the SCRIPTCALL command

;It employs nested scripts

SCRIPTCALL

"C:\CAD\LayerUpdates\Scripts\Templates\SimplePreClean.scr"

SCRIPTCALL

"C:\CAD\LayerUpdates\Scripts\Templates\defaultPostClean.scr"

Number Two
Employ Matched Script and Lisp Couplets

A typical Batch Save couplet uses a Script to load and execute lisp and or other scripts with SCRIPTCALL. There are important variations to this technique talked about later.

Examples

An example of a SimplePreClean.SCR

(setvar "SECURELOAD" 0)

(load "C:\\CAD\\LayerUpdates\\Scripts\\Templates\\SimplePreClean.lsp")

(setvar "SECURELOAD" 1)

SimplePreClean

Note the use of a dedicated resource folder and the method to employ SECURELOAD to load the called .lsp file from that location.

An example of the SimplePreClean.lsp file

(defun c:SimplePreClean()

 (command "_textscr")

 (command "-purge" "r" "*" "n" )

 (command "qsave")

 )

In this case we’re purging the Regapps and saving the cleaner results. Whether and how we upgrade the targeted files in selected folders is determined in the Batch Save Utility dialog box. The save generates a change in the file even if a following script(s) in the chain fails for debug and QAQC reasons.

Number Three
Employ a Post Clean Couplet

The final SCRIPTCALL wraps things up after all the work is done. The script loads the lsp as seen above.

Example

An Example PostClean lsp function the does the routine cleanup, reset, and final save.

(defun c:defaultPostClean()

 (command "audit" "y")

 (command "-purge" "r" "*" "n" )

 (command "qsave")

 )

Note the order of various PURGE commands and the use of AUDIT and SETVAR changes varies based on your intended changes to the file(s).

Number Four
Use the Old to Upgrade to the New

One of the difficulties on changing the contents of old files in to make sure the specifics you need to update are present to operate on. AutoCAD scripts are mindless. They have no error checking. You could employ fancier lisp functions to do that but then again often it is simply easier just pile in all the potential resources, make the changes, and clean up what you don’t need.

The headless Civil 3D environment processes script and lisp much quicker than the full-blown application.

Maybe you want to INSERT a block collection, redefine some with a second INSERT, and PURGE any unused/unnecessary blocks.

Example

An example Lisp for layers that adds multiple collections of Layers in preparation for a RENAME of only some of those Layers.

(defun c:InsertOldLayers-STB()

 (command "-insert" "*C:\\CAD\\LayerUpdates\\Scripts\\Templates\\STB\\LS8-PPipes-NS.dwg" "0,0,0" "1" "0")

 (command "-insert" "*C:\\CAD\\LayerUpdates\\Scripts\\Templates\\STB\\LS8-Structures-NS.dwg" "0,0,0" "1" "0")

 (command "-insert" "*C:\\CAD\\LayerUpdates\\Scripts\\Templates\\STB\\LS8-City-NS" "0,0,0" "1" "0")

 (command "qsave")

 )

Note in this case the injected resource drawings intentionally do not include Layer States. The RENAME SCRIPT intended to follow will simply update the Layer names and automatically revise the existing Layer States.

Number Five
Preload LSP and Call on Demand

When you need to run and number of different processes to get from A to B (multiple SCRIPTCALLs), it often pays to load lisp early and call the functions later in other following SCRIPTs on demand. Put another way – you can build and load a number of similar and related functions from which you can call exactly what you need.

It may take a moment to get your head around that this works and applies to the important point of SCRIPT and LSP couplets applied to Batch Save Utility mechanics. The purpose of the SCRIPT in a couplet is not only to load a LSP file. It can exist to do other things and then call it and/or another functions.

Explore Batch Save and Civil 3D Projects in BIM 360 Design

In an upcoming post we’ll explore whether we can and how we might employ the Civil 3D Batch Save Utility for upgrading our Civil 3D projects up in the BIM 360 cloud environment.

First, we will need to get our work, Civil 3D template resources, and other Civil 3D Style resources updated to the latest and greatest version of Autodesk Civil 3D.

Batch Save allows us to get there faster and with demonstrably less hassle.

Make Civil 3D Work Better
Get the Framework for Civil 3D Release 8

 

BIM 360 Civil 3D Batch Save Upgrade Posts

Civil 3D in BIM 360 Project Maintenance

  • The Civil 3D Batch Save Utility and detailed upgrades to Civil 3D in BIM 360 design project drawings and resources

Civil 3D and BIM 360 Projects

  • Why Civil 3D in BIM 360 Design projects matter and how to get started on the road to implementation

5 Better Civil 3D Update Batch Save Script Tips

  • Five Scripting Tips to make the Civil 3D Batch Save Utility work better

Migrate A Civil 3D Test Project to BIM 360

  • The necessary details to migrate a Civil 3D test project to BIM 360 with the Autodesk Connector

How To Be Ready When Civil 3D Changes

  • Proactive and practical steps to take to make Civil 3D Upgrades and Updates easier