Recently, a method was presented for automatically integrating catalog data into the Content Browser used in AutoCAD-based products like AutoCAD Civil 3D and AutoCAD MEP. Now, let’s refine that process by adding a bit of code to enhance functionality.
Understanding the Need for Additional Code
Coding can be an enjoyable experience, especially when it brings about precise control in AutoCAD. The objective is to simplify the coding process, making it accessible and engaging.
It’s time to complete the implementation. Below is the essential code, requiring changes only in the designated sections.
;; Add catalog to Content Browser ;; Edit items below (setq regKey "HKEY_CURRENT_USER\\Software\\Autodesk\\AutoCAD 2025\\RegisteredCatalogs") (setq itemID "{6F6953A6-B6DA-494B-83E4-21BCF9710EC9}") (setq image "P:\\autocad_mep_2025\\tool_catalogs\\stantec_2048\\Images\\stantec_logo_2.png") (setq url "P:\\autocad_mep_2025\\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_2025\\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")))))
Take note of the double backslashes; particularly, exercise caution when copying the registry key starting with HKEY_CURRENT_USER from your registry file into this code. Except for the registry key, all other lines can be directly copied, ensuring that double quotes are retained. Utilizing the Visual LISP IDE enhances clarity through syntax highlighting, making it easier to pinpoint errors.
Explaining the Code Lines
Lines 3 through 11 are designated for setting up data. Each line corresponds to specific information needed for registry registration.
The command (vl-registry-write regKey "Registered" 0)
registers the newly added catalog within the registry, letting the Content Browser recognize new catalogs upon the next launch of AutoCAD.
Next, the line (setq regKey (strcat regKey "" itemID "-Catalog"))
constructs the key for the new catalog. This adjustment to the existing variable regKey may introduce minor complications, but it’s a manageable task.
The command (cond ((not (vl-registry-read regKey "ItemID"))
checks if the catalog is already present; if it is, the subsequent code won’t run.
The following segment (mapcar (function (lambda (a) (vl-registry-write regKey (car a) (cdr a))))...
stores all relevant information in the registry, making sure that the catalog loads seamlessly with the Content Browser. The last two parameters, “Type” and “AccessRight,” are uniquely defined:
- Setting “Type” to 2 designates that the catalog holds specific content. Users generally prefer having access solely to company content.
- Assigning “AccessRight” as “1” indicates that the catalog is read-only. This allows users to refresh content without the need for deletion or re-installation.
Incorporating the Code into bootstrap.lsp
To have this code executed during the bootstrap process, you need to integrate it into the bootstrap.lsp file. Position it between the lines (princ "Executing Bootstrap.")
and (setq includePaths 1)
to ensure proper execution.
Final Thoughts on Bootstrapping AutoCAD
This approach simplifies the deployment of AutoCAD 2025, allowing for effective management of company-wide customizations. The benefits include a streamlined installation process and a user-friendly launch experience that maintains the correct user profile, easing transitions across various workstations.
FAQ
1. What is the purpose of the registry key in this code?
The registry key facilitates the storage and retrieval of catalog data necessary for the Content Browser to recognize and load new catalogs upon launch.
2. Can I modify the catalog information later?
Yes, you can edit the catalog information by modifying the respective values in the code and re-running it to update the registry.
3. What happens if the catalog already exists when I run the code?
If the catalog is found in the registry, the code won’t execute further, preventing duplication of entries.