Q How can I copy each model in a DGN file to its own DGN file?
Questions similar to this, posed by MicroStation users and VBA developers, appear on the the MicroStation Forum or Programming Forum.
A This VBA project implements a utility for enumerating the models in a DGN file. For each model, it creates a new DGN file and removes all other models. The result is a DGN file named after the model, that contains just that model.
Caveat: because it's not possible to remove the default model of a DGN file, some files will contain two models: the desired model and the default model.
MicroStation users sometimes want something different from the set of tools provided in the product.
The question asked, on Be Communities, was: "How can I export the models in a DGN file so that each model has its own DGN file?"
The VBA enumerates the models in the active DGN file. For each model, it creates a copy of the active DGN file named after the model.
It uses Microsoft's Scripting Runtime library, which makes file handling simpler.
Using OpenDesignFileForProgram, it opens each new DGN file.
It deletes each model whose name differs from the file name, leaving just the model desired.
The above code is available in this MicroStation
VBA project.
Unpack the ZIP archive and copy ModelExporter.mvba to a location where MicroStation
can find it.
A good place to copy it would be \Workspace\Standards\macros.
To create a new color CSV file, type the following into MicroStation's key-in dialog …
vba run [ModelExporter]modMain.Main
The exporter creates a set of DGN files in the same folder as your DGN file.
The file name is the same as the DGN model with a dgn extension.
Post questions about MicroStation programming to the MicroStation Programming Forum.