An Approach to Implementation

Implementation: “The process of putting a decision or plan into effect.”

A few words describing a sometimes difficult task.

When I started my new job two years ago, one of my first goals was to implement a custom partial menu for the eight-member engineering group in my office. In the past I had kept all customization files on the server and had the clients access them from there. I soon discovered, however, that due to slow network access to our server that resides off-site, any new customization files would need to be stored locally in order to achieve acceptable performance.

I pondered that situation for a while and decided that for my implementation plan I would:

Create a master copy of the files and put them in shared folders on the server.
Make local copies of those same files and folders under “C:\Users\Public”. This location would somewhat conceal their location as well as avoid having them be specific to any one user.
Create a batch file, which would tie everything together and automatically keep the user’s local files in sync with the network versions.

While creating the files I needed for the custom menu, I chose to put everything under a folder called AutoCADSupport and then break down the files under it into three other folders according to their function:

  1. One folder for the actual menu files
  2. Another folder for the blocks I was using
  3. A third to hold the AutoLISP files I was writing

This structure kept everything nice and neat. I’ll explain the purpose of the SyncACAD.bat file and its shortcut later.

After spending some time creating the necessary files for a working partial menu, I copied them to the shared network folders.

Now all I needed was the batch file that would synchronize the files and folders on the network to the location on the client machines I had chosen earlier. I placed this file (which I called SyncACAD.bat) and a shortcut to it under the main AutoCADSupport folder on the network. Basically the batch file works like this:

  1. Make sure the network is available.
  2. Make sure the folders exist on the client computer.
  3. Copy the files from the network to the client. For this task I chose to use Robocopy (Robust File Copy) to do the heavy lifting. One of my favorite Robocopy options is the mirror switch (/mir). This allows me to make an exact copy of a folder into another location. Robocopy will also only copy files that have changed—keeping the subsequent batch file run-time to a minimum.
  4. Copy the shortcut to the batch file into the user’s Startup folder so it will run every time they log in.
  5. Copy the shortcut to the user’s desktop so they can also run it at will.

Below is the actual batch file:

Now let’s go through it line by line and see how it works.

Lines 1 – 4:  Turns off echoing commands to the screen, sets the window title, and then clears the screen. These are pretty standard commands for the start of most batch files I’ve worked with.

Line 5:  Acts like a linefeed and creates an empty line on the screen.

Line 6:  A comment line telling the reader what’s supposed to happen next.  The two colons in a row (::) tell the batch file that there’s nothing to execute on this line and to ignore the text that follows. I add comments at points along the file to remind me of what the program is supposed to be doing.

Line 7:  Checks to see if the network location is available. If not, the batch file skips all the way down to line 25.

Line 8:  If the network location was found successfully, this line prints a notification to the screen.

Lines 11 – 14: Checks to see if the four folders on the client computer exist and, if not, creates them. These steps are not strictly necessary when using Robocopy, but my preference is to make sure any folders I need already exist before copying any files to them.

Lines 17 – 19:  This is really where the bulk of the work happens. Robocopy copies the files from the network location to the local computer. The “/MIR” switch makes sure that each folder on the client is an exact copy of the server folder. That way, if files are deleted from the server, there aren’t any orphan files hanging around on the client computers, taking up space and confusing things. Also, as our network connection to the server can be unreliable at times, I’ve included switches telling Robocopy to retry any file 5 times (/R:5) and to wait for 5 seconds between tries (/W:5). You can see all of Robocopy’s available options by opening up a command window and typing “Robocopy /?” at the command line (without the quotes, of course).

Line 21: Copies the batch file shortcut to the current user’s startup folder. This is what makes the batch file run when the user logs in and keeps all the files in sync automagically.

Line 24:  Copies the shortcut to the user’s desktop. Originally I had not planned on doing this, but having a way for the users to update their local files without logging off and back on again (or explaining how to get to the Startup folder) made everyone’s life a little easier.

Line 25:  This is where the program jumps to when the network path can’t be found.

Once all the AutoCAD®-related files were in place on the server and the batch file tested (on a couple of mostly willing guinea pigs), all that was left to do was copy the files to the local machines and set up AutoCAD to find everything.

There are only eight people in my group, and they are all in the same office with me, so it was easy enough to go around and configure their machines individually. I already had the batch file in place, so the easiest way to get the files onto the local computers was to open Windows Explorer, navigate to the AutoCADSupport folder on the server, and double click on the batch file.

Once it had finished I had a perfect replica of the network folders.

Next, I added the newly created menu and support folders to the Support File Search Path and moved them to the top of the list.

Also, don’t forget to add these same folders to the list of Trusted Locations to avoid the security warning shown below.

After the folder locations had been set, the only thing left to do was load the new custom menu with the MENULOAD command. Browse to the %Public%\AutoCADSupport\Menu folder and pick the partial menu to load it.

From this point on, any changes made to the network folders are copied down to the users’ computers when they log into their machine. I’ve since added a logging feature to the batch file and tool palette folder to the list.  I was able to distribute the tool palettes to the users without having to revisit any of the computers.  I’ve also updated the properties of the shortcut so that it runs in a minimized window to keep the users from closing it after logging in (even though they were told not to!).

Appears in these Categories