twitter youtube facebook linkedin email
Connect with:

AUTOCAD BLOG

Bootstrap AutoCAD Deployments for Customizations (8)

R. Robert Bell
February 25, 2016

Last week you saw how to gather catalog data so it could be added automatically to the Content Browser, a feature in such AutoCAD®-based products as AutoCAD Civil 3D and AutoCAD MEP (Bootstrap AutoCAD Deployments for Customizations Part 7). All we have to do now is work in a little more code.

Code… Why did it have to be more code?

Hey, I like to write code. And it feels great when you get AutoCAD to do exactly what you want. I’ve tried to make coding easy, and maybe even a bit fun, for you too.

OK. Let’s finish up. Here’s the code. The only parts you need to edit are at the very beginning and marked between comments.

;; Add catalog to Content Browser
;; Edit items below
(setq regKey "HKEY_CURRENT_USER\\Software\\Autodesk\\Autodesk Content Browser\\78\\RegisteredCatalogs")
(setq itemID "{6F6953A6-B6DA-494B-83E4-21BCF9710EC9}")
(setq image "P:\\autocad_mep_2015\\tool_catalogs\\stantec_2048\\Images\\stantec_logo_2.png")
(setq url "P:\\autocad_mep_2015\\tool_catalogs\\stantec_2048\\stantec_2048_tools.atc")
(setq displayName "Stantec 2048 Tools")
(setq description "Stantec BC 2048's Devices and Tools")
(setq coverPage "P:\\autocad_mep_2015\\tool_catalogs\\stantec_2048\\cover_page.html")
(setq publisher "Stantec BC 2048")
(setq toolTip "Stantec BC 2048's Devices and Tools")
;; Edit items above
(vl-registry-write regKey "Registered" 0)
(setq regKey (strcat regKey "\\" itemID "-Catalog"))
(cond ((not (vl-registry-read regKey "ItemID"))
(mapcar (function (lambda (a) (vl-registry-write regKey (car a) (cdr a))))
(list (cons "ItemID" itemID)
(cons "Url" url)
(cons "DisplayName" displayName)
(cons "Description" description)
(cons "Image" image)
(cons "CoverPage" coverPage)
(cons "Publisher" publisher)
(cons "ToolTip" toolTip)
(cons "Type" 2)
(cons "AccessRight" "1")))))

Be mindful of the double backslashes–especially when you copy the registry key (the bit that starts with HKEY_CURRENT_USER) from the registry file into the code. Except for the registry key, you can copy and paste all items directly—just make sure you preserve the double quotes in each line. Using the Visual LISP IDE is nice here because of the syntax color coding. See Figure 1.

Color coding with the Visual LISP IDE. Bootstrap AutoCAD Deployments for Customizations.

Figure 1: Seeing colors with the Visual LISP IDE (integrated development environment).

Content Browser code explained

Lines 3 through 11 (the lines between the comments) set the data for the rest of the code.

(vl-registry-write regKey "Registered" 0)
This line informs the Content Browser that an unregistered catalog has been added thru the registry. The Content Browser will register any new catalogs the next time it is launched.

(setq regKey (strcat regKey "\\" itemID "-Catalog"))
This creates the registry key for the actual catalog. We’re redefining the variable regKey using the original value for the variable, and bugs can creep in when you change data in a variable to data from the same variable. But this is a simple bit of code so… go for it.

(cond ((not (vl-registry-read regKey "ItemID"))
This line checks to see if the catalog already exists. If it does, the rest of the code will not execute.

(mapcar (function (lambda (a) (vl-registry-write regKey (car a) (cdr a))))
(list (cons "ItemID" itemID)
(cons "Url" url)
(cons "DisplayName" displayName)
(cons "Description" description)
(cons "Image" image)
(cons "CoverPage" coverPage)
(cons "Publisher" publisher)
(cons "ToolTip" toolTip)
(cons "Type" 2)
(cons "AccessRight" "1")))))

This section of code writes each line of information into the registry, which ensures the catalog loads when the Content Browser launches. I set up the last two lines (the ones with “Type” and “AccessRight”) so they do not get data from the exported registry file. Why? Because….

  • Type = 2 means the catalog is storing content. Although catalogs can store a range of items, in my experience users want only the company content.
  • AccessRight = “1” means that the catalog is read-only to users. Why? So if you update content, users will be able to refresh it without having to delete and reload the content.

That wasn’t so bad, was it—especially after that monster bootstrap.lsp code? Speaking of bootstrap.lsp….

Add this code to bootstrap.lsp

You need to add this code to the bootstrap.lsp code so it runs as part of the bootstrap process. Place it between the (princ “\nExecuting Bootstrap.”) and (setq includePaths 1) lines. See Figure 2.

See where to place the catalog code in the bootstrap.lsp code. Bootstrap AutoCAD deployments for customizations.

Figure 2: Place the catalog code right here in the bootstrap.lsp code. Done!

Bootstrap AutoCAD Deployments for Customizations: The End!

And that is it. Really.

Now that you’ve got deployment figured out, you should be able to roll out new versions of AutoCAD on time and without hassle—no matter how extensive your companywide AutoCAD customizations.

I hope you have enjoyed this series. Please feel free to contact me here or over Twitter (@r_robert_bell) if you have any questions or need some help.

To recap….

Bootstrapping AutoCAD from the secondary installer simplifies your AutoCAD deployment (IT will thank you), gives users a friction-free deployment experience, and ensures AutoCAD will always launch to the correct profile, regardless of how users start the software or whether they log on to multiple workstations. It’s easy to do—just add a single file to the deployment package and locate your customizations on the network—and it will ensure users keep right on ticking when they use new hardware.

Here’s the entire series, all together now:

Bootstrap AutoCAD Deployments for Customizations Part 1

Bootstrap AutoCAD Deployments for Customizations Part 2

Bootstrap AutoCAD Deployments for Customizations Part 3

Bootstrap AutoCAD Deployments for Customizations Part 4

Bootstrap AutoCAD Deployments for Customizations Part 5

Bootstrap AutoCAD Deployments for Customizations Part 6

Bootstrap AutoCAD Deployments for Customizations Part 7

KEEP UP WITH AUTOCAD

   

Try AutoCAD Now

AutoCAD Blog Free Trial

Questions?

Have subscription pricing questions? Check out our Subscription info page.

Need to find a service pack for a legacy version of AutoCAD? Our Downloads page has everything you need.

Running into a problem? Our Troubleshooting site should be able to help.

Getting started? Download a free trial of AutoCAD, AutoCAD LT, or AutoCAD Mobile!

Check Out AutoCAD 2018.1

R. Robert Bell

A longtime AUGI director—and the organization’s current President—Robert has been active in the MEP industry for over 25 years and an AutoCAD user since version 2.18. He provides strategic direction, technical oversight, and high-level support for Stantec. Follow him on Twitter @r_robert_bell.

6 Comments;

View by:
Most Recent Oldest
  1. ArchD

    I seem to get everything working, and it sets our company’s main file the first time, but if I run Civil 3D again from the default shortcut that runs the <> profile, it does nothing. The company profile is in the profiles list, but does not set. The only thing that seems to happen is that the bootstrap and code folders are added as duplicates in the trusted locations paths each time Civil 3D is run.

    Just to be clear, the first run works like a charm. It imports my company’s profile and sets it. On the second run on, it runs the <> profile with default paths with the exception of trusted locations which adds duplicate paths every run.

    1. R. Robert Bell (Post author)

      Archie, the missing puzzle piece is that I have my bootstrap copy a shortcut from a central location to the user’s desktop that launches AutoCAD with my desired profile. The user then ignores the out of the box (OOTB) shortcuts. If they launch using the OOTB one after the desired profile was already added, I simply make the desired profile the active one.

  2. GTVic

    I have to place all support files on the hard drive as slow network connections can really impact Civil 3D’s performance if network folders are in the path. My solution for AutoCAD is to alter the deployment so the default profile has a custom name. You can detect that in LISP, do all your customizing which includes deleting the dummy default profile and import the correct default profile. The advantage is that if the user selects the option to reset their profile, the process repeats perfectly. For civil 3d, this is not an option as Civil 3D launches with a specific profile in the shortcut and customizing that in the deployment results in errors. Good advice to keep the deployment simple. For 2013 I used AcadDoc.lsp but found the bootstrap had to load a .NET DLL which adds a Application.Idle handler and launches the real bootstrap code once AutoCAD was fully loaded and idle otherwise the configuration code would not work properly as parts of AutoCAD were still loading. Would appreciate a comment on that aspect for newer releases.

    1. R. Robert Bell (Post author)

      Altering the deployment so that it initially uses a special profile is very similar to the bootstrap approach documented in my posts. In either case, you have AutoLISP code that reacts to the non-desired profile, whether that profile is an OOTB or a special one. Your approach works as long as IT is giving you the ability to alter the deployment package. Some organizations, for better or worse, don’t permit that. This makes things tough, hence the Bootstrap series.
      Regarding the use of AcadDoc.lsp for load .NET applications, I wouldn’t do that. I would use Acad.lsp instead, because it loads only once, when the application is initializing. AcadDoc.lsp runs every time a drawing is opened/created. There is no need to have AutoCAD attempt to load .NET applications when each drawing is opened/created. I’ve not seen any issues loading a .NET application when using Acad.lsp to load them. But I have seen issues when using AcadDoc.lsp.
      Hope that helps!

  3. mlg@freese.com

    I’m a bit late to the table but I missed this when it first came out. We do something similar to your process where I work only not using the profiles. Our ACAD.LSP checks for a version file and for certain items existing in the users profile. If they are missing or changed then the custom toys kick in and copy over the updated or correct files needed. This lets me (as the CAD Coordinator) make changes to the company standards and put them on the network. Next time the user opens ACAD they get the updates. We also have created a CUIX for all of the company customizations that is added to the menu out of the box. I have a number of advanced users that like to customize their profile and this allows them that ability without locking them in to a rigid company standard. Just thought I’d throw this out there from the ‘for whatever it’s worth department.’

    1. R. Robert Bell (Post author)

      The approach you describe is actually what we do with our normal profile. Once bootstrap has gotten the correct profiles added, those profiles autocorrect certain settings every time a drawing is opened/created. I only correct settings that are needed for all users. I leave most of the profile settings alone after the initial profile creation so users can have their own preferences stick with them. We also have a corporate CUIX assigned as the enterprise CUIX and the user therefore has their own CUIX as the main so that they can customize the UI for themselves.