본문 바로가기
  • Welcome!
VBA, VB.NET For Creo

Installation and setup for using Creo VBA

by ToolBOX01 2025. 3. 10.
반응형

1. Creo VBA API installation

Select "API Toolkits > VBA API . . ." to install.

2. Setting up "pro_comm_msg.exe"

Facilitates communication between the executable xtop.exe and asynchronous Pro/TOOLKIT applications

For your application to communicate with Creo Parametric, you must set the PRO_COMM_MSG_EXE environment variable to the full path of the executable, pro_comm_msg.exe. Typically, the path to the executable is <creo_loadpoint>\<datecode>\Common Files\<machine type>\obj\pro_comm_msg.exe, where machine type is i486_nt for 32-bit Windows and x86e_win64 for 64-bit Windows installations.
Set PRO_COMM_MSG_EXE as:
1.Click Start > Settings > Control Panel.
2.Click System. The System Properties windows opens.
3.In the Advanced tab, click the Environment Variables button.
4.Add PRO_COMM_MSG_EXE to System variables.

 

3. Registering the COM Server

To register the COM server, run the vb_api_register.bat file located at <creo_loadpoint>/Parametric/bin.
 
* Be sure to run it in administrator mode
 
To unregister the COM server, run the vb_api_unregister.bat file located at <creo_loadpoint>/Parametric/bin.
After the COM server is registered with the system, whenever an application tries to access the types contained in this server the server starts automatically. By default, Windows starts services such as pfclscom.exe in the Windows system directory (c:\winnt\system_32). Because the server will also start new sessions of Creo Parametric from the process working directory, you may want to control the server run directory. You can configure the server to start in a specific directory by setting the system environment variable PFCLS_START_DIR to any existing directory on your computer.
 

4. Excel Developer Environment Settings

Add a developer tab to excel

5. Define a template Excel file for VBA development.

set project references for the VB API, Just select Tools and then References and Check the box for Creo Parametric VB API Type Library for Creo Parametric as shown in the following figure.

6. mapkey

vba run on excel file.
Call excel file from creo custom tab.
Call excel file with mapkey.

!VBA01 PROGRAM =======================================================================================
mapkey vb01 @MAPKEY_NAMEVBA PROGRAM;@MAPKEY_LABELVBA PROGRAM;\
mapkey(continued) @SYSTEMstart /B "" \
mapkey(continued) C:\\vba_project\\vba01\\Template_VBA.xlsm;

Create and use a program development environment more easily using mapkey and icons. Please save the created VBA Excel file as and distribute it. To test with the song, use a free cloud such as Google Drive.

7. caution - Run-time error 2147417851 (80010105)

When developing with VBA, click the "F8" key in development mode to run the code sequentially. Check if there are any errors. This is an error that occurs occasionally and I don't know the cause. Resolution: From PTC Support... The COM process may crash during an untrapped error. The workaround is to manually terminate the "pfclscom.exe" process.

Press ctrl+del+alt keys. Launch Task Manager.

Find "pfclscom.exe" in the Task Manager submenu and delete it manually, then press "F8" in VBA to run the program again.

 

 

▷ Here is a Creo VBA installation site for your reference.

 

Visual Basic API for PTC's CREO - Setup

In order to use this API (Application Programming Interface) it is necessary first to install this capability and do the proper setup in bot...

creoauto.blogspot.com

 

▷ Creo VBA API Help

 

PTC Help Center

Your browser has DOM storage disabled. Make sure DOM storage is enabled and try again.

support.ptc.com

 

TIP - VBA Template Code

I use this code to develop my programs by copying it. It's the code I use all the time. Use this as a basis to create a better starting template code.

Option Explicit

Sub Main()

	Application.EnableEvents = False
	On Error GoTo RunError
    
    	Dim asynconn As New pfcls.CCpfcAsyncConnection
    	Dim conn As pfcls.IpfcAsyncConnection: Set conn = asynconn.Connect("", "", ".", 5)
    	Dim BaseSession As pfcls.IpfcBaseSession: Set BaseSession = conn.session
    	Dim Model As IpfcModel: Set Model = BaseSession.CurrentModel
    	Dim Solid As IpfcSolid: Set Solid = Model
    
    
    
    
    
    
    
    
    
    	conn.Disconnect (2)
    
    	'Cleanup
    	Set asynconn = Nothing
   		Set conn = Nothing
    	Set BaseSession = Nothing
    	Set Model = Nothing


    
	RunError:
    	If Err.Number <> 0 Then
        	MsgBox "Process Failed : Unknown error occurred." + Chr(13) + _
                	"Error No: " + CStr(Err.Number) + Chr(13) + _
                	"Error: " + Err.Description, vbCritical, "Error"
        	If Not conn Is Nothing Then
            	If conn.IsRunning Then
                	conn.Disconnect (2)
            	End If
        	End If
    	End If

End Sub

 


'VBA, VB.NET For Creo' 카테고리의 다른 글

How to display all model names in a session  (0) 2025.03.11
Output the currently active 3D model name  (0) 2025.03.11
IpfcSurface  (0) 2025.02.01
Creo] IpfcModel  (0) 2025.02.01
Creo] Get the dimensions that the model's features have  (0) 2025.01.29