Start & End Creo using VB API

Hello Creo developers,

In this article I am going to show how to start and end the Creo application via Creo VB API & this is for beginners.

Syntax to Start a Creo Session

Function CCpfcAsyncConnection.Start (CmdLine as String, TextPath as String [optional]) as IpfcAsyncConnection
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.

Code Sample

Start Creo 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

Syntax to End the Creo Session

Sub End ()

Code Sample

End 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:

  • Always use Try…Catch method to capture the Error Data
  • If you want to use custom text path then change it in the Start syntax

 

Thanks & Regards

Parthiban Kannan

Share Now
  •  
  •  
  •  
  •  
  •  
  •  

Leave a Reply