Creo Open PRT文件操作指南

https://community.ptc.com/t5/Assembly-Design/ProE-VBA-API-examples/td-p/44157

This example connects to an open Pro/ENGINEER session and retrieves part PRT0001 and access its Family table instances and displays their names.


Sub Main2()
'
' This routine will open a Pro/E file from your WorkingDirectory in a new window:
'
Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession
Dim oModel As pfcls.IpfcModel

'Make an asynchronous connection with Pro/ENGINEER
Set conn = asynconn.Connect("", "", ".", 5)

'Get the current session
Set session = conn.session

'Show the current Working Directory
MsgBox "This is the current Working Directory: " & vbCrLf & session.GetCurrentDirectory

'Create a modeldescriptor to the Pro/E Model
Dim oModelDescriptorCreate As New CCpfcModelDescriptor
Dim oModelDescriptor As IpfcModelDescriptor
Set oModelDescriptor = oModelDescriptorCreate.Create(EpfcMDL_PART, "PRT0001.PRT", Null)

'Retrieve the model into the oModel handle
Set oModel = session.RetrieveModel(oModelDescriptor)


'Create a new window which displays the Pro/E Model
Dim oWindow As pfcls.IpfcWindow
Set oWindow = session.OpenFile(oModelDescriptor)

'Activate the new window
oWindow.Activate


'Show the name of the Pro/E Model in a messagebox
MsgBox "Model name = " & oModel.Filename
'
Dim A As IpfcBaseParameter
Dim Av As IpfcParamValue
Dim newA As IpfcParamValue
Dim A_value As Double
Dim generic As IpfcFamilyMember
Dim rows As IpfcFamilyTableRows
Dim row As IpfcFamilyTableRow
Dim InstName As String

'Declare (make) the Model as a IpfcFamilyMember type object
Set generic = oModel
' list the ROws of family table. If the part is not a generoc, there will be 0 rows
Set rows = generic.ListRows()

' Now, get each row and print the instance name. Once each instance is obtained, do rewquired operations
For Each row In rows
InstName = row.InstanceName
MsgBox "Fam Instance Name: " & InstName
Next

'Disconnect with Pro/ENGINEER
conn.Disconnect (2)

'Cleanup
Set asynconn = Nothing
Set conn = Nothing
Set session = Nothing
Set oModel = Nothing

End Sub
QR Code
微信扫一扫,欢迎咨询~

联系我们
武汉格发信息技术有限公司
湖北省武汉市经开区科技园西路6号103孵化器
电话:155-2731-8020 座机:027-59821821
邮件:tanzw@gofarlic.com
Copyright © 2023 Gofarsoft Co.,Ltd. 保留所有权利
遇到许可问题?该如何解决!?
评估许可证实际采购量? 
不清楚软件许可证使用数据? 
收到软件厂商律师函!?  
想要少购买点许可证,节省费用? 
收到软件厂商侵权通告!?  
有正版license,但许可证不够用,需要新购? 
联系方式 155-2731-8020
预留信息,一起解决您的问题
* 姓名:
* 手机:

* 公司名称:

姓名不为空

手机不正确

公司不为空