Export Element command not working in microstation using vba

I need to call "Export Element" command using vba code in microstation. But modalHandler has not trigger the "Export Element" command. Please guide me how to call "Export Element" command using vba.

Here I copied my code:

Implements IModalDialogEvents
Private Sub IModalDialogEvents_OnDialogClosed(ByVal DialogBoxName As String, ByVal DialogResult As MsdDialogBoxResult)
End Sub
Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult)
    If DialogBoxName = "Create Export File" Then
        CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setFilterCmd *.txt"
        CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd D:\"
        CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd 81.txt"
    '   Remove the following line to let the user close the dialog box.
        DialogResult = msdDialogBoxResultOK
    End If  ' Create Export File
    If DialogBoxName = "Alert" Then
    '   Remove the following line to let the user close the dialog box.
        DialogResult = msdDialogBoxResultOK
    End If  ' Alert
End Sub
Sub Macro1()
    Dim startPoint As Point3d
    Dim point As Point3d, point2 As Point3d
    Dim lngTemp As Long
'   The following statement opens modal dialog "Alert"
    Dim modalHandler As New Macro16ModalHandler
    AddModalDialogEventsHandler modalHandler
'   The following statement opens modal dialog "Create Export File"
'   Start a command
    CadInputQueue.SendCommand "EXPORT ELEMENT "
    RemoveModalDialogEventsHandler modalHandler
    CommandState.StartDefaultCommand
End Sub
Parents
  • Please guide me how to call "Export Element" command using vba

    It depends what do you want to achieve.

    XYZ tool is quite standard MicroStation application, so to use key-ins is preferred way. Why do you want to use VBA?

    How to use XYZ tool has been discussed many times (did you search existing discussions?), there is also Wiki page about XYZ key-ins.

    At a basic level to control the tool using key-ins is very simple, because it seems (based on very quick testing using MicroStation CONNECT Edition Update 11) a standard set item toolsettings <parameter> = <value> is well supported by this tool.

    General workflow is:

    1. Activate tool / open XYZ dialog using export element key-in.
    2. Define all parameters using set item toolsettings <parameter> = <value> key-in.
    3. Start the tool again, but with mode specification, e.g. export element all.

    All in one it's for example export element;set item toolsettings outputfile=d:\temp\myfile.txt;export element all.

    If you want to use it in a batch mod, confirmation dialog box can be a problem. I do not know whether a key-in that works without opening the dialog exists, but a workaround can be implemented using VBA:

    Module code:

    Sub UseXyzExportTool()
    
        Dim modalHandler As New XyzModalHandler
        
        AddModalDialogEventsHandler modalHandler
    
        CadInputQueue.SendKeyin "export element;set item toolsettings outputfile=d:\temp\myfile4.txt;export element all"
    
        RemoveModalDialogEventsHandler modalHandler
        
        CommandState.StartDefaultCommand
    End Sub

    Class code (handler):

    Implements IModalDialogEvents
    Private Sub IModalDialogEvents_OnDialogClosed(ByVal DialogBoxName As String, ByVal DialogResult As MsdDialogBoxResult)
    
    End Sub
    
    Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult)
    
        If DialogBoxName = "Alert" Then
    
        '   Remove the following line to let the user close the dialog box.
            DialogResult = msdDialogBoxResultOK
    
        End If  ' Alert
    
    End Sub
    
    

    With regards,

      Jan

  • Thank you for your suggestion.

    XYZ tool is quite standard MicroStation application, so to use key-ins is preferred way. Why do you want to use VBA?

    I have used this in key-in command but I need to develop this in programmatic.

    If you want to use it in a batch mod, confirmation dialog box can be a problem

    Yes. I have faced the problem in confirmation dialog box that has not triggered while send "Export Element" key in command.

    I am also executing the vba code as you given but same issue occurs. Kindly suggest me any alternative functions.

  • Hi,

    I have used this in key-in command but I need to develop this in programmatic.

    it's not quite clear what do you mean by "need to develop this". Do you mean that

    • You have to implement own code with the same functionality (which in general is not simple task and C/C++ would be probably required)
    • or you have to call XYZ tool from your own VBA code?
    I am also executing the vba code as you given but same issue occurs.

    In such case the problem is somewhere in your configuration or environment. I never posted code that is not tested and I am sure it works on my computer.

    You have not shared any detail like what version do you use, if and what error is displayed, how your batch script looks like etc. so it's impossible to guess what can be wrong.

    Did you modify my code to "fit" into your environment and workflow? There are some requiremens that I guess are obvious: When export is run in batch, it has to be ensured coordinates are exported into uniquely named files, otherwise another confirmation dialog is displayed.

    Kindly suggest me any alternative functions.

    The only alternative is to implement own coordinate export funciton.

    With regards,

      Jan

  • Kindly suggest me any alternative functions

    You need to tell us which version (e.g. v10.x.y.z) of MicroStation, or other product, you are using.

     
    Regards, Jon Summers
    LA Solutions

Reply Children
No Data