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.
I would think that you should be able to do it via VBA; quick and easy, plus you can specify a naming convention and save location at the same time.
hi Barry, I would be interested in a vba solution. Do you know by any chance if there is some code/documentationt available that shows how you can do that?
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.
Regards, Jon Summers LA Solutions
Joy van Vliet said:I thought up of the code below
Barry Lothian said:My approach instead would be to reference each model from the source DGN file in into the 'defaultmodelreference'
Mark Shamoun said:Side question how did you get a compress process using OpenDesignFileForProgram?
Please post questions about VBA to the Programming Forum.