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
3. Registering the COM Server
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 |