I have an issue where I am needing to open a seed/template file, Import model files from an existing, then export select models together into a new design file.
Manually i can do this by recording my actions of opening a template seed file, import models then go to the File>Save As... and from the V8 save as options dialog box>Filters tab click on the models button and individually choose models to save into the new file. But the delima is the recorded macro always just gets all the models not the ones i select.
How can i perform the same functionality of the save as options to specify individual models to save into the new drawing?
What ultimately i want to occur is to change the default model file by using the above mentioned methods.
Thank you in advance for any assistance provided.
A DesignFile object has a collection of Models. You need to OpenDesignFileForProgram your source DGN file, then enumerate DesignFile.Models. Filter out the models you don't want to copy. Then, add the models in that list to your ActiveDesignFile.Models collection.
Regards, Jon Summers LA Solutions
First off thank you for your reply. This is what I have in place thus far:
Public Sub ImportModelFiles(strOldFile As String, strSeedFile As String, strOutputFolder As String)
Dim oFile As DesignFile
Dim myFileName As String
'Dim strOldFile As String
Dim myOldFile As DesignFile
Dim mdlNew As ModelReference
Dim mdlOld As ModelReference
Dim mdlActive As ModelReference
Dim mdlTemp As ModelReference
Dim strFilenoExtension As String
'Open old file to copy models from
Set myOldFile = OpenDesignFileForProgram(strOldFile)
strFilenoExtension = Left(myOldFile.name, Len(myOldFile.name) - 4)
myFileName = strOutputFolder & "\" & strFilenoExtension & ".dgn"
'set default model for copy from old file
Set mdlOld = myOldFile.DefaultModelReference
'Create the new file from the seed file
CreateDesignFile strSeedFile, myFileName, False
Set oFile = OpenDesignFileForProgram(myFileName) 'Open this file to copy new models to
'rename model file in seed to "old" to avoid model name conflict on copy
For Each mdlTemp In oFile.Models
If UCase(mdlTemp.name) = "MODEL" Then
mdlTemp.name = "OLD2"
Exit For
End If
Next mdlTemp
'scan and copy all models from old file to new file
For Each mdlTemp In myOldFile.Models
Set mdlNew = oFile.Models.Copy(mdlTemp, mdlTemp.name, mdlTemp.Description)
oFile.Save
oFile.Close
myOldFile.Close
This all allows me to copy over the model files from another drawing into my newly created drawing but the problem still exist where I need to remove the default model in the newly created design file and that is where the "SaveAs>V8 Save Otpions>Filter tab select only the models you want" in the new file question comes from. I cant see how enumerating the models collection allows me the ability to change the default model reference of the design file?