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:
Priyanka Ravi said: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.
set item toolsettings <parameter> = <value>
General workflow is:
export element
export element all
All in one it's for example export element;set item toolsettings outputfile=d:\temp\myfile.txt;export element all.
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
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
Thank you for your suggestion.
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,
Priyanka Ravi said: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
Priyanka Ravi said: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.
Priyanka Ravi said: Kindly suggest me any alternative functions.
The only alternative is to implement own coordinate export funciton.
Priyanka Ravi said: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