Since I haven't really used VBA in a very long time I've decided that I'm gonna teach myself, from scratch, to use it with AutoCAD.
I'll document what I do and how I do it here so that you can follow along with my progress or, if you already know VBA, point me in the right direction.
This will be open to anyone so feel free to tell me what you think.
To start off, I'll be using a couple of things as a reference.
AfraLisp has a great section on VBA as it pertains to AutoCAD and I highly recommend it.
They have a great article called
An Introduction to VB and VBA that you should check out if you're new to VBA.
As my project, I'm going to be creating a VBA application in AutoCAD that takes the place of my companies 'Details' book.
So I'll start by explaining what I hope to accomplish.
The menu I'm using is in a folder called
C:\clc\acadmenu
Under this directory I have a folder called DETAILS which contains sub-folders of my details broken into categories.
We're an electrical engineering firm so our categories are as such:
COMM -
Communications DetailsLIGHTS -
Lighting DetailsMECH -
Mechanical DetailsMISC -
Miscellaneous DetailsPOWER -
Power DetailsAll of my details are named as such:
Comm0001.dwg
Comm0002.dwg
Comm0003.dwg
Comm0004.dwg
Comm0005.dwg
Comm0006.dwg
etc...and
Lite0001.dwg
Lite0002.dwg
Lite0003.dwg
Lite0004.dwg
Lite0005.dwg
Lite0006.dwg
etc...So my thinking, at this point, is this:
I have created a text file in the base directory called DETAILS.TXT which contains a list of directories (categories) with a description separated by the pipe (|) symbol
COMM|Communications Details
LIGHTS|Lighting Details
MECH|Mechanical Details
MISC|Miscellaneous Details
POWER|Power Details
In each subdirectory I have a text file, named for the folder, containing a similar list of the detail drawings along with a description such as
Comm0001|Sample Sound System Conduit Schedule
Comm0002|Ceiling Smoke Detector Mounting Detail
Comm0003|Wall Mounted Data/Telephone Outlet Detail
Comm0004|Data/Voice/Video Outlets Detail
Comm0005|Antenna Mounting Detail
etc...My hope s that I can have the application load the information from the first text file allowing the user to select which type of detail he intends to view/insert.
Once selected, load the information from the corresponding text file and display the description of each type of detail. When the user selects the description they intend to view/insert, a large preview of the drawing will be shown and they have the option of inserting the drawing into AutoCAD.
I'll be using the AcPreview ActiveX Control module for the preview
(more on control modules later) and I'll work through the process step by step so, if you like, you can create the same project yourself.
The way I figure it, if I ever want to add another detail or change the description of one it will simply mean modifying the text file pertaining to the category I wish to add/remove from.
And, as always, if you think I might be on the wrong track feel free to say so. Have a better idea? I'm open to suggestion.
So I'm off to read that introduction to VBA and I'll return here and post my thoughts on it when I'm done.