Connect Creo by It’s connection ID in VB API

To connect a specific Creo Session from multiple session, VB API provides the function ConnectById(). Here this article is for how to implement this function.

ConnectByID()
  Function CCpfcAsyncConnection.ConnectById  (Id as IpfcConnectionId, TextPath as String [optional], TimeoutSec as Long [optional]) as IpfcAsyncConnection 
  • Connects to a specific Creo Parametric session by passing the identification string.
  • The ID string for a given session can be obtained from IpfcAsyncConnection.GetConnectionId().
  • The application may only connect to one Creo Parametric session at any time.
Parameters:
Id
The connection id string which previously obtained for the Creo Parametric session you wish to connect to.
TextPath
The path under which the message and menu files are held. If no external messaging or menus are needed pass null.
TimeoutSec
The time, in seconds, to wait for Creo Parametric to respond to the connection request. Pass null to use the default timeout.
Returns:
Object representing the asynchronous connection.

Procedure:

  1. Declare the required variables (IpfcAsyncConnection, CCpfcAsyncConnection)
  2. Get Connection ID
  3. Connect by ConnectionID

Code:

Connect Creo By Connection ID
 Public AConnection As IpfcAsyncConnection
        Public CConnection As New CCpfcAsyncConnection
        Dim ConnectionID

        Try

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

            
            ConnectionID = AConnection.GetConnectionId            
            CConnection.ConnectById(ConnectionID, ".", 10)

            Dim ConnectionString = AConnection.GetConnectionId.ExternalRep.ToString()
            MessageBox.Show("Connected by ID: " & ConnectionString & " Created", "Success")

        Catch ex As Exception
            MessageBox.Show(ex.ToString(), "Connect By ID Failure")
        End Try

 

Thanks & Regards

Parthiban Kannan

Follow Me on LinkedIn

Share Now
  • 3
  •  
  •  
  •  
  •  
  •  
    3
    Shares

Leave a Reply