7115.export_stp.mvba
Private Sub CommandButton1_Click() Macro1 End Sub Sub Macro1() Dim startPoint As Point3d Dim point As Point3d, point2 As Point3d Dim lngTemp As Long Dim modalHandler As New Macro1ModalHandler AddModalDialogEventsHandler modalHandler ' L'istruzione seguente apre la finestra di dialogo modale "Esporta file STEP AP203/AP214" ' Avvia un comando CadInputQueue.SendCommand "MDL LOAD AP203OUT" ' RemoveModalDialogEventsHandler modalHandler CommandState.StartDefaultCommand DialogResult = msdDialogBoxResultOK End Sub 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) Dim path As String Const CurrentFolder As String = "$(_dgndir)" If DialogBoxName = "Esporta file STEP AP203/AP214" Then ' L'istruzione seguente apre la finestra di dialogo modale "Esporta con nome" CadInputQueue.SendCommand "AP203OUT FILE EXPORT" ' Rimuovere la linea successiva per consentire all’utente di chiudere la finestra di dialogo. DialogResult = msdDialogBoxResultOK End If ' Esporta file STEP AP203/AP214 If DialogBoxName = "Esporta con nome" Then percorso = ActiveWorkspace.ExpandConfigurationVariable(CurrentFolder) CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd " + percorso files = ActiveDesignFile.Name a = Len(files) b = a - 3 c = Left(files, b) Name_files = c & "stp" CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd " + Name_files ' Rimuovere la linea successiva per consentire all’utente di chiudere la finestra di dialogo. DialogResult = msdDialogBoxResultOK End If ' Esporta con nome End Sub
Hello, I recorded a macro to export a files in "stp" format I modified the macro by inserting a form with a button and I defined two varies to specify the file of the file and the name of the files. The problem is that when the objects select and I confirm in the export form, the export panel in STP format closes but no files are generated. why.thank you.I was able to verify that if I delete "dialogresult = msddiaogaxresultok" the panel does not close, I must confirm manually and in this case the file is generated.
Tiziano Sapora said: The problem is that when the objects select and I confirm in the export form, the export panel in STP format closes but no files are generated
It may be that you've removed the dialog event handler too soon. Remove (comment out) this line in your Main()...
Main()
RemoveModalDialogEventsHandler modalHandler
The correct place for that statement, according to VBA help, is the _OnDialogOpened subroutine.
_OnDialogOpened
Regards, Jon Summers LA Solutions
Thanks for the reply, I did various attempts by eliminating "removemodaldiarogioventhandler modalhandler" without success but in the end I solved. The problem is that the window should not be closed and a confirmation was missing on the export button then I simulated the pressure on the export button "Sendkeys"%{e} "and eliminated" Dialogresult = msddiaogaboxresultok ".In this way you work working
thank you 3010.export_stp.mvba
Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult) Dim path As String Const CurrentFolder As String = "$(_dgndir)" If DialogBoxName = "Esporta file STEP AP203/AP214" Then ' L'istruzione seguente apre la finestra di dialogo modale "Esporta con nome" CadInputQueue.SendCommand "AP203OUT FILE EXPORT" ' Rimuovere la linea successiva per consentire all’utente di chiudere la finestra di dialogo. ' DialogResult = msdDialogBoxResultOK SendKeys "%{E}" End If ' Esporta file STEP AP203/AP214 If DialogBoxName = "Esporta con nome" Then percorso = ActiveWorkspace.ExpandConfigurationVariable(CurrentFolder) CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setDirectoryCmd " + percorso files = ActiveDesignFile.Name a = Len(files) b = a - 3 c = Left(files, b) Name_files = c & "stp" CadInputQueue.SendCommand "MDL COMMAND MGDSHOOK,fileList_setFileNameCmd " + Name_files ' Rimuovere la linea successiva per consentire all’utente di chiudere la finestra di dialogo. DialogResult = msdDialogBoxResultOK End If ' Esporta con nome End Sub