Connect Creo using VB API application

Dear developers! Good day,
Here I am going to explain how to connect Creo using VB API & what are all the common issues will happen while connection.

Declare required variable

Public AConnection As IpfcAsyncConnection
Public CConnection As New CCpfcAsyncConnection

  • IpfcAsyncConnection – It is the VB API class for Asynchronous connection
  • Creo connect is one of the function of CCpfcAsyncConnection class and the user need to initiate as new object

Connect Creo

Function CCpfcAsyncConnection.Connect (Display as String [optional], UserID as String [optional], TextPath as String [optional], TimeoutSec as Long [optional]) as IpfcAsyncConnection


The name of the display Creo Parametric is using. If this is null, match any display. If this is an empty string, assume the local host.
The name of the user running the Creo Parametric to connect to. If this is null, match any user. If this is an empty string, assume the current user.
The path under which the message and menu files are held. If no external messaging or menus are needed pass null.
The time, in seconds, to wait for Creo Parametric to respond to the connection request. Pass null to use the default connection timeout.


Connect Creo Using VB API
 Public Async Function CreoConnect() As Task

            AConnection = CConnection.Connect(Nothing, Nothing, Nothing, 10)

        Catch ex As Exception
            If ex.ToString.Contains("pfcExceptions::XToolkitNotFound") Then
                Dim index = MessageBox.Show("No Creo Session Found" & vbNewLine &
                                              "Start Creo then tries again" & vbNewLine & vbNewLine & "Do you want to retry?",
                                            "Creo Not Found", MessageBoxButton.YesNo, MessageBoxImage.Error)
                If index = Forms.DialogResult.Yes Then
                End If
            ElseIf ex.ToString.Contains("XToolkitAmbiguous") Then
                MessageBox.Show("It seems more than 1 creo found, I can't connect more than a CREO Session" & vbNewLine &
                        "Kindly close one of the Creo sessions then try again", "Not enough input", MessageBoxButton.OK, MessageBoxImage.Information)

                MsgBox("Exception New" & vbNewLine & ex.ToString)
                Dim Index As Integer = MessageBox.Show("Creo Connection Error" & vbNewLine &
                                             "Send error details to the Developer", "Application Error", MessageBoxButton.OK, MessageBoxImage.Error)
                If Index = Forms.DialogResult.OK Then
                    Dim FunctionName As String = Reflection.MethodBase.GetCurrentMethod.ToString
                End If
            End If
        End Try

    End Function

Some tips

  • Since it is asynchronous method, application will communicate with the VB API COM object. Hence it may take some seconds to connect and this time limit we can control in our coding.
  • Anyway during connection the application will hang until its connected and this may cause the application to not responding mode
  • So I would always suggest make the Creo connection function as task and use some good progress bar to keep your users calm
  • Don’t use this method if multiple creo running.


Thanks & Regards

Parthiban Kannan

Share Now

Leave a Reply