admin@creocustomization.com

Start & End Creo using VB API

Start & End Creo using VB API

Here is the snippet to start and end the Creo application using Creo VB API. This method can help to utilize Creo only when it is needed to generate the model. Otherwise, if CAD administrators need to create a custom application to load CREO configuration based on the user role or user choice while initiating the CREO, this snippet would help integrate the Creo application with Visual basics application.

Start Creo Connection

FunctionCCpfcAsyncConnection.Start(CmdLine as String, TextPath as String [optional]) as IpfcAsyncConnection
Syntax to Start Creo Session

Parameters:

CmdLine

The full path to the startup command, batch file or script file used to start Creo Parametric.

TextPath

The path under which the message and menu files are held. If no external messaging or menus are needed pass null.

Returns:

Object representing the asynchronous connection.

Public AConnection As IpfcAsyncConnection
Public CConnection As New CCpfcAsyncConnection

Try
   CConnection.Start("C:\PTC\Creo2-amd64-M120\Creo 2.0\Parametric\bin\parametric.exe", ".")
Catch ex As Exception
           MessageBox.Show(ex.ToString(), "Creo Start Failure")
End Try

Explanation

Declare the variable IpfcAsyncConnection & CCpfcAsyncConnection. These are classes used to connect Asynchronous library

Start command initiate the Creo from cmdline path.

End Creo Session

SubEnd() 
Syntax to End the Creo Session
Public AConnection As IpfcAsyncConnection
Public CConnection As New CCpfcAsyncConnection
  
Try
     AConnection.End()
Catch ex As Exception
     MessageBox.Show(ex.ToString(), "Creo End Failure")
End Try

Some Tips using Creo VB API:

Always use Try…Catch method to identify the error

If you want to use custom text path then change it in the Start syntax

Leave a Reply

Contact Us