0

I'm working on automating some workflows in AutoCAD using VBA macros. I want to create a .bundle that loads my .dvb (VBA project) files at AutoCAD startup and makes the macros available as commands. Here's what I need to achieve:

  1. Create a .bundle structure for AutoCAD.

  2. Define the PackageContents.xml to ensure the .dvb files are loaded when AutoCAD starts.

  3. Automatically register the macros as commands so they can be invoked directly.

Could someone guide me through the steps to achieve this? Examples of the necessary folder structure, XML content, and AutoLISP/VBA code to load the .dvb and register commands would be very helpful.

I have created the .bundle Folder Structure:

MyVBAProject.bundle
├── Contents
│ ├── MyVBAProject.dvb
│ ├── MyStartup.lsp
│ └── PackageContents.xml

Here's my current PackageContents.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<ApplicationPackage
 SchemaVersion="1.0"
 AutodeskProduct="AutoCAD"
 Name="My VBA Project Loader"
 Description="Loads VBA macros at AutoCAD startup"
 Version="1.0.0"
 Author="Your Name"
 ProductType="Application">
 
 <Components>
 <RuntimeRequirements OS="Win64" Platform="AutoCAD" SeriesMin="R24.0" SeriesMax="R27.0"/>
 <ComponentEntry AppName="MyStartupLSP" ModuleName="./Contents/MyStartup.lsp" LoadOnAutoCADStartup="true"/>
 </Components>
</ApplicationPackage>

Here’s my MyStartup.lsp file to load the .dvb project:

(defun c:LoadVBAProject ()
 (vl-load-com)
 (vla-LoadDVB
 (vla-get-vbamanager (vlax-get-acad-object))
 (findfile "MyVBAProject.dvb")
 )
 (princ "\nVBA Project Loaded.")
)
;; Automatically call LoadVBAProject on startup
(c:LoadVBAProject)

My questions are:

  1. Am I structuring the .bundle and PackageContents.xml file correctly?

  2. How can I ensure that the macros in the .dvb file are exposed as AutoCAD commands automatically?

  3. Are there better ways to handle VBA project loading at startup or registering VBA macros as commands?

Any guidance or examples would be greatly appreciated!

asked Dec 10, 2024 at 15:48

1 Answer 1

0

The PackageContents.xml file should be at the root of the .bundle folder.

MyVBAProject.bundle
|__ PackageContents.xml
|__ Contents
 |__ MyVBAProject.dvd
 |__ MyStartup.lsp
answered Dec 11, 2024 at 6:48
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.