Questions similar to this appear on the MicroStation Forum.
Often we have a DGN file with multiple cell instances. We want to find the cell library where each cell may be found. In other words, an audit of cells. Usually, this is an area of interest to CAD Administrators.
A MicroStation session has access to zero or more cell libraries (*.cel
files).
Those libraries are found in the folders indicated by
configuration variable MS_CELL
.
The MicroStation VBA macro described here performs several tasks concerning cells and cell libraries …
MS_CELL
Here's some example data from a CSV file produced by the Cell Audit macro …
"Cell Name", "Description", "Library Path" "Single Door","CCW arc","\\asterix\datadir\Bentley\CONNECT\LA Solutions\Standards\Cell\DoorsWithSmartText.cel" "Single Door 2","CW arc","\\asterix\datadir\Bentley\CONNECT\LA Solutions\Standards\Cell\DoorsWithSmartText.cel" "Copy of AreaLabel2","Unavailable","Not Found" "AreaLabel4","Show model name updating automatically","\\asterix\datadir\Bentley\CONNECT\LA Solutions\Standards\Cell\AreaAnnotatorTemplateLibrary.cel" "Cell contains some text","Unavailable","Not Found" "AreaLabel1","area label template for AreaAnnotator","\\asterix\datadir\Bentley\CONNECT\LA Solutions\Standards\Cell\AreaAnnotatorTemplateLibrary.cel" "Fraction","Unavailable","Not Found"
The order of performing a cell audit is …
MS_CELL
When collecting information about cells and libraries, the code makes use of the Scripting.Dictionary class. A Dictionary object is similar to a PERL associative array, or a Python dictionary.
A dictionary stores data as a pair: a key and an object.
The object can be of almost any data type.
In this macro, the key is a String
(e.g. a cell name) and the object is a String
or another class.
There are two dictionaries, both held by the UserForm
as member variables …
Scripting.File
class
clsCellData
, keyed by the cell name and storing an instance of that class
This macro represents the limit of VBA capabilities. I would have preferred to write this as a C++ or C# app, because those languages provide more help for storing, comparing, and sorting classes.
This macro uses OpenDesignFileForProgram
to examine each cell library (DGN file) and read cell (model) names and descriptions.
Often, I advise against using OpenDesignFileForProgram
, but in this case it's a valid use.
A sample project is available. It includes code similar to that above and the VBA UserForm
shown above.
The macro is provided as freeware.
It is not formally supported software.
Use at your own risk.
You can download a ZIP file, and then extract CellAudit.mvba
to a folder
that MicroStation can find. A good place to put it would be
..\Workspace\Standards\macros
, or any other folder specified
in the MS_VBASEARCHDIRECTORIES
configuration variable.
Start the macro with this MicroStation key-in …
vba run [CellAudit]modMain.Main
Post questions about MicroStation programming to the MicroStation Programming Forum.