admin@creocustomization.com

Create a menu item from Creo VB API Asynchronous Application

Create a menu item from Creo VB API Asynchronous Application

Creo VB API allows user to create menu item inside the Creo window using VB API commands

Procedure

  1. Create IpfcAsyncConnection
  2. Get the Session from IpfcAsyncConnection
  3. Create IpfcUICommand
  4. Add UIButton in the Session
    1. Create a text file names “CommandSample.txt” for command label and help and place it in the text folder
  5. Add action listener to the command

CommandSample.txt

#
#
Test#App
Test Button
#
#
Test#Help
Button added by Creo VB API application
#
#

VB Code

Imports pfcls
Class MainWindow
    Private Sub btn_ConnectCreo_Click(sender As Object, e As RoutedEventArgs) Handles btn_ConnectCreo.Click
        Try
            'CConnection.Connect("Display","User Id", "Text path", "Timeout sec")
            AConnection = CConnection.Connect(Nothing, Nothing, Nothing, Nothing)
            MessageBox.Show("Application Connected With Creo", "Success")
        Catch ex As Exception
            MessageBox.Show(ex.ToString(), "Creo Connect Failure")
        End Try
    End Sub

    Private Sub btn_ConnectCreo_Copy_Click(sender As Object, e As RoutedEventArgs) Handles btn_ConnectCreo_Copy.Click
        Try
            UICommand = AConnection.Session.UICreateCommand("Test", ActionCommand)
            AConnection.Session.UIAddButton(UICommand, "Windows", Nothing, "Test App", "Test Help", "CommandSample.txt")
            AConnection.AddActionListener(Me)

        Catch ex As Exception

        End Try
    End Sub

    Private Function ActionCommand() As IpfcUICommandActionListener
        MessageBox.Show("I am New Command")
    End Function

End Class

Leave a Reply

Contact Us