Export to 2d

Does anyone have any VBA code for converting 3d files to 2d. I know that there is an export to 2d utility but I want to do this in batch. I would like it to be able to skip the file if it is already a 2d file.

 

Thank you

Parents Reply Children
  • Here is the code and below that is the modal handler 

    Just put the load and run vba command in a txt file that the batch process can read.

    Sub Export2d()
        Dim startPoint As Point3d
        Dim point As Point3d, point2 As Point3d
        Dim lngTemp As Long

       Dim modalhandler As New Macro1ModalHandler
        AddModalDialogEventsHandler modalhandler

    '   The following statement opens modal dialog "Save 3D as 2D"

    '   Start a command
        CadInputQueue.SendCommand "MDL LOAD cnvdgn"

        RemoveModalDialogEventsHandler modalhandler
        CommandState.StartDefaultCommand
    End Sub

    MODAL HANDLER

    Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult)
    Dim strname As String
    strname = ActiveDesignFile.Name

    ' The following cancels the dialog if file is 2d
    If DialogBoxName = "Save 2D as 3D" Then
    DialogResult = msdDialogBoxResultCancel

    ElseIf DialogBoxName = "Save 3D as 2D" Then

    ' The following line ignores view rotation
    SetCExpressionValue "optionInfoP->ignoreViewRotation", -1, "CNVDGN"

    CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setFilterCmd *.dgn"

    CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd P:\out\"

    CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd " & strname

    ' Remove the following line to let the user close the dialog box.
    DialogResult = msdDialogBoxResultOK

    End If ' Save 3D as 2D

    End Sub