Copy Model from Another Design File

I am trying to copy a model from another design file using code. If I record this process, I get this

CadInputQueue.SendCommand("model import " & FileName & Modelname)

I would like to use something like

dim mdlNew as Attachment

dim att as attachment

mdlNew = MsApp.ActiveDesignFile.Models.Copy(att, modelname, modeldescription)

but I am having a difficult time assigning a file name to the attachment(att)

 

  • The code snip below shows how to copy a model from an external design file to the active design file (and model)

    Sub WorkDgnModelImport()

    Dim oDestModel As ModelReference
    Dim oSrcModel As ModelReference
    Dim oDestDesignFile As DesignFile
    Dim oSrcDesignFile As DesignFile
    Dim strFileToImport As String

    ' Configure destination design file and model to write to
    Set oDestDesignFile = ActiveDesignFile
    Set oDestModel = ActiveDesignFile.Models("Default")

    ' Configure source design file and model to read from
    strFileToImport = "C:\temp\dms18779\3d.dgn"
    Set oSrcDesignFile = OpenDesignFileForProgram(strFileToImport, False)
    Set oSrcModel = oSrcDesignFile.Models("Default")

    ' Perform copy from source model to destintation model - active model
    oDestDesignFile.Models.Copy oSrcModel, "ImportedModel-1"

    ' Cleanup
    oSrcDesignFile.Close

    End Sub

    HTH,
    Bob



    Answer Verified By: SteveMeyer