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

  • VBA to check if 2d or 3d : 

    http://www.la-solutions.co.uk/content/mvba/mvba-tips.htm#DgnFileDimension

    For batch process ..refer here.

    http://communities.bentley.com/products/microstation/microstation_v8i/f/19565/t/20661.aspx

    cd "C:\Program Files\Bentley\Program\MicroStation"
    msbatch cnvdgn inname:C:\3DConv\2D\*.* outname:t:\3DConv\3D\
    pause  

     

    THT,

    josie

  • this is a dos command, we do not have the msdos shell or the run command for windows, it has been removed.
  • cs1:
    We do not have the MSDOS shell or the run command for Windows: it has been removed.

    That reads like the heavy hand of IT is at work. It's not really something that anyone in this Be Community can help you with: it's a matter for you, your manager, and your employer to resolve.

    Put it to your manager, and her manager, and so on, that you are prevented from performing certain aspects of your work because of that policy. What is the cost (i.e. man-hours) of performing on each DGN file what you would prefer to do in batch mode? Multiply the cost per DGN by the number of DGNs. Then multiply again by the number of times per week/month/year you must perform that task. A $cost $budget is likely to mean more to them than a complaint that IT policies restrict your freedom.

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • thanks, but I finally figured out how to make it work through VBA and using batch process.
  • cs1:
    I finally figured out how to make it work through VBA and using batch process.

    Share your experience: what's the secret of running a batch process when you don't have access to the Windows command prompt?

    Regards, Jon Summers
    LA Solutions

     
    Regards, Jon Summers
    LA Solutions

  • 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