Hi everyone,
I saw a few posts that explained how to export the models in a dgn file to seperate DWG files
https://communities.bentley.com/products/microstation/f/microstation-forum/171130/export-file-with-multiple-models-as-seperate-files/492329
, however I was wondering whether it's possible to save a dgn file with multiple models to seperate dgn files instead.
When I export only one model from all the modesl, still the size of the exported odel is the same as the origin dgn file where the model comes from. This seems weird, since I only export one model.
Joy van Vliet said: the size of the exported odel is the same as the origin dgn file where the model comes from. This seems weird, since I only export one model
Use the MicroStation compress key-in or the File=>Compress menu.
Regards, Jon Summers LA Solutions
hi Barry, with help of the following link: http://www.la-solutions.co.uk/content/connect/mvba/MVBA-EnumerateModels.htmI thought up of the code below.
I am trying to iterate over each model and consequently save the model in a separate dgn with the SaveAs function.
However when I run this code, I get an error. When I look at the exception log, I see the following line repeated roughly 200 times GetModuleFileName failed with error 126 for .............................
I assume the way how I have written the code, is not correct.
Option Explicit Option Base 0 Sub Main() Dim nModels As Long nModels = ExportModels(ActiveDesignFile) MsgBox "Found " & CStr(nModels) & " models ", vbInformation Or vbOKOnly, "Enumerated Models" End Sub ' --------------------------------------------------------------------- Function ExportModels(dgn As DesignFile) As Integer Dim index As Integer Dim strName As String For index = dgn.Models.Count To 1 Step -1 Dim oModel As ModelReference Set oModel = dgn.Models(index) oModel.DesignFile.SaveAs "c:\test.dgn", True, msdDesignFileFormatV8 Debug.Print "Model [" & CStr(index) & "] '" & oModel.Name & "'" Next End Function
Joy van Vliet said: I would be interested in a vba solution
Kindly post questions about VBA to the Programming Forum.
Joy van Vliet said:I was wondering whether it's possible to save a dgn file with multiple models to seperate dgn files
Season's Greetings! Try the macro described here. Unzip it and move ModelExporter.mvba to your workspace macros folder...
ModelExporter.mvba
You are the test pilot!
Answer Verified By: Joy van Vliet