Jannah Theme License is not validated, Go to the theme options page to validate the license, You need a single license for each domain name.
blog

Bootstrap AutoCAD Deployments for Customizations Part 8

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.

Contents

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_USERSoftwareAutodeskAutodesk Content Browser78RegisteredCatalogs")
(setq itemID "{6F6953A6-B6DA-494B-83E4-21BCF9710EC9}")
(setq image "P:autocad_mep_2015tool_catalogsstantec_2048Imagesstantec_logo_2.png")
(setq url "P:autocad_mep_2015tool_catalogsstantec_2048stantec_2048_tools.atc")
(setq displayName "Stantec 2048 Tools")
(setq description "Stantec BC 2048's Devices and Tools")
(setq coverPage "P:autocad_mep_2015tool_catalogsstantec_2048cover_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.

INTERESTING:   Three Quick Ways to Clean Up an AutoCAD Drawing: Tuesday Tips With Brandon - AutoCAD Blog
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.
INTERESTING:   AutoCAD News in 2019 - AutoCAD Blog

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

INTERESTING:   How To: Edit DWGs in the AutoCAD Web App - AutoCAD Blog

Bootstrap AutoCAD Deployments for Customizations Part 7

Source: Autodesk

Back to top button

Adblock Detected

Please disable your ad blocker to be able to view the page content. For an independent site with free content, it's literally a matter of life and death to have ads. Thank you for your understanding! Thanks