This article discusses how to open a MicroStation design file (also known as a DGN File) using MicroStation VBA. A DGN file is the default file format used when creating or editing 3D and 2D CAD files using Bentley Systems' MicroStation.
Questions similar to this appear on the Be Communities MicroStation Programming Forum.
A VBA programmer can choose between these methods …
OpenDesignFile
is the default method you should use to open a DGN file.
When you use this method, MicroStation opens the new file and its default model for editing.
The file and its models are in the same state you would see if you chose MicroStation menu File|Open.
By 'in the same state' we mean that all MicroStation's components or sub-systems are initialised. Those include, but are not limited to, the following …
When OpenDesignFile
is complete, execution returns to your code.
You can continue to work with all functionality provided by MicroStation VBA.
Use OpenDesignFileForProgram
in special circumstances, only when OpenDesignFile
does
not do what you want.
It is obvious that OpenDesignFileForProgram
opens a DGN file for a program.
What is not so obvious is that OpenDesignFileForProgram
does not open a DGN file for you as a user.
When you use this method, MicroStation opens the new file invisibly to the user.
The file is unavailable for editing (i.e. a user cannot see the file or its models in MicroStation's views).
The file and its models are not in the same state you would see if you chose MicroStation menu File|Open.
Many of MicroStation's components and sub-systems are not affected by OpenDesignFileForProgram
— keep
in mind that a user can continue to work with the active model in the active DGN file.
MicroStation's views show the contents of the active model and its references.
You can conclude that all VBA view objects are invalid for the DGN file you opened with OpenDesignFileForProgram
.
MicroStation's reference attachments remain attached to the active model.
Your DGN file opened using OpenDesignFileForProgram
does not have reference attachments.
There is a single active workspace. You can work with the VBA ActiveWorkspace
object
and evaluate configuration variables, for example.