VBA Custom Configs
by Mark Stefanchuk, cadmanage.com
I’m not really a big fan of increasing the number of MicroStation config variables. Where possible, try to use built in variables. For example, you can use CreateCellElement3
with just the name of the cell as long as the cell library is defined in MS_CELLLIST. You might have something that looks like this in your VB code.
oCell = MainForm.oMSApp.CreateCellElement3(MainForm.uc_o.txtCameraName.Text, Point, True)
This is from a VB.Net example, that’s why the MicroStation Application object is included.
Here’s how I might define MS_CELLLIST for use with photogeoDGN.
CADMANAGE = C:/ProgramData/Cadmanage/PhotogeoDGN/Contents/ MS_ADDINPATH < $(CADMANAGE)Windows/8.11/ MS_CELLLIST < $(CADMANAGE)Resources/*.cel
Sometimes however, it is necessary to identify a special folder or some other resource in your custom program. For example, your program might include a catalog file that provides some engineering data that your program will associate with a cell. You could decide to put this in a resources folder that is always in the install directory. But, a better solution might be to let the end user decide where she wants to save the resource. In this case the resource or file is one that MicroStation doesn’t know anything about, but your program has to be able to find. To fix that we could define the following,
CMRI_CATALOG = $(CADMANAGE)Resources/testcatalog.xml
Put the variable in one of MicroStation’s configuration files, like your UCF. Now, to access the variable from your custom VBA program you need to use ConfigurationVariableValue. Here’s how to do that in VBA.
The example will print the value of the configuration variable in the VBA IDE’s immediate window.
Use this expansion to open the file, or in this case define your XML document object.
As long as the variable name is different than any other MicroStation config variable, you can use it, but I would recommend including a prefix. In the previous example, I used CMRI (for CAD Management Resources, Inc). This just helps to avoid variable conflicts.
About Mark Stefanchuk: Mark is a VP and senior consultant with CAD Management Resources, Inc. He divides his time between developing innovative custom software solutions and helping clients navigate complex design automation environments. If you would like to find out how he can assist you with your design technology he can be reached directly at email@example.com.