cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

GETTING ERROR WHILE RUNNING MAPKEY IN VB-API

avijayan-2
14-Alexandrite

GETTING ERROR WHILE RUNNING MAPKEY IN VB-API

Hello Everyone.

I have created a MAPKEY to choose a config file from the Working Directory. Its working fine in manual mode.

Now i have added this mapkey to a Button Function. What actually the button will do is it will launch the CREO first after that it should run the mapkey to select the config file.

Launching CREO is working fine but its not running the macro.

Should i declare anything before i call the function " IpfcBaseSession.RunMacro" when i went through the VB-API document i didnt find any such thing.

Below is my CODE and ERROR Message.

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

       

  Dim asyncConnection As IpfcAsyncConnection = Nothing

        Dim form As Form2

      

        Try

            lblStatus.Text = ""

            If TextBox1.Text = "" Then

                MsgBox("Please enter  Creo Parametric path", MsgBoxStyle.Critical)

                lblStatus.Text = "Please enter  Creo Parametric path"

            Else

                lblStatus.Text = "Starting  Creo Parametric Session ..."

                Me.lblStatus.Refresh()

                Me.Cursor = Cursors.WaitCursor

                asyncConnection = (New CCpfcAsyncConnection).Start(TextBox1.Text, ".")

                If Not (TextBox2.Text = "") Then

                    asyncConnection.Session.ChangeDirectory(TextBox2.Text)

                End If

                Me.WindowState = FormWindowState.Minimized

                form = New Form2(asyncConnection)

                form.ShowDialog()

            End If

        Catch ex As Exception

            MsgBox(ex.Message.ToString + Chr(13) + ex.StackTrace.ToString)

            If Not asyncConnection Is Nothing AndAlso asyncConnection.IsRunning Then

                asyncConnection.End()

            End If

            lblStatus.Text = "Error occurred while starting new Creo Parametric Session"

        Finally

            Me.WindowState = FormWindowState.Normal

         

            Me.Cursor = Cursors.Default

            Me.Refresh()

        End Try

        IpfcBaseSession.RunMacro( c @MAPKEY_LABELCONFIG;~ Select `main_dlg_cur` `appl_casc`;\,

                                    Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdRibbonOptionsDlg` ;\,

                                    mapkey(continued) ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `ConfigLayout`;\,

                                    mapkey(continued) ~ Select `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;\,

                                    mapkey(continued) ~ Close `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;\,

                                    mapkey(continued) ~ Activate `ribbon_options_dialog` `ConfigLayout.Open`;\,

                                    mapkey(continued) ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;\,

                                    mapkey(continued) @MANUAL_PAUSESelect Config File..........;\,

                                    mapkey(continued) ~ Command `ProFileSelPushOpen_Standard@context_dlg_open_cmd` ;\,

                                    mapkey(continued) ~ Activate `ribbon_options_dialog` `OkPshBtn`;)

    End Sub

For error message please see the attached image.

Kindly help me to solve this issue.

With Regards

Aghil.M

ACCEPTED SOLUTION

Accepted Solutions
James62
12-Amethyst
(To:avijayan-2)

I'm only familiar with J-Link, but the API looks similar. Maybe it even follows the same rules. Try the following for the RunMacro(..) method:

IpfcBaseSession.RunMacro("Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdRibbonOptionsDlg` ;

                                    ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `ConfigLayout`;

                                    ~ Select `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;

                                    ~ Close `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;

                                    ~ Activate `ribbon_options_dialog` `ConfigLayout.Open`;

                                    ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;

                                    @MANUAL_PAUSESelect Config File..........;

                                    ~ Command `ProFileSelPushOpen_Standard@context_dlg_open_cmd` ;

                                    ~ Activate `ribbon_options_dialog` `OkPshBtn`;")

Be aware that i have no idea how to concatenate a string in VB and also I'd think you cannot put a @MANUAL_PAUSE line into the macro. I'd replace it with regular UIShowMessageDialog(...) instead if there is such a thing in VB API, and split the whole thing into two RunMacro(...) methods.

~J

View solution in original post

3 REPLIES 3
James62
12-Amethyst
(To:avijayan-2)

I'm only familiar with J-Link, but the API looks similar. Maybe it even follows the same rules. Try the following for the RunMacro(..) method:

IpfcBaseSession.RunMacro("Close `main_dlg_cur` `appl_casc`;~ Command `ProCmdRibbonOptionsDlg` ;

                                    ~ Select `ribbon_options_dialog` `PageSwitcherPageList` 1 `ConfigLayout`;

                                    ~ Select `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;

                                    ~ Close `ribbon_options_dialog` `ConfigLayout.ImportExportBtn`;

                                    ~ Activate `ribbon_options_dialog` `ConfigLayout.Open`;

                                    ~ Trail `UI Desktop` `UI Desktop` `DLG_PREVIEW_POST` `file_open`;

                                    @MANUAL_PAUSESelect Config File..........;

                                    ~ Command `ProFileSelPushOpen_Standard@context_dlg_open_cmd` ;

                                    ~ Activate `ribbon_options_dialog` `OkPshBtn`;")

Be aware that i have no idea how to concatenate a string in VB and also I'd think you cannot put a @MANUAL_PAUSE line into the macro. I'd replace it with regular UIShowMessageDialog(...) instead if there is such a thing in VB API, and split the whole thing into two RunMacro(...) methods.

~J

avijayan-2
14-Alexandrite
(To:James62)

Hi james,

Thanks for the reply. it solved my problem.

Arthur
6-Contributor
(To:avijayan-2)

hi Aghil.M,

can you post your code for using mapkeys? I can't make it work.

Thx in advance

Announcements
NEW Creo+ Topics: PTC Control Center and Creo+ Portal


Top Tags