Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
All,
Need help toexport from assemblyover 100 CSYS (individual parts)to single text file or excel document with all X,Y and X parameters (similar to transform).
Thanks in advance.
Hi Alex,
You can use VB API connected to EXCEL VBA for your purpose.
1/ make sure the API is installed with ProE (not the default install parameter)
2/ Register the VB API
3/ You can retrieve the components as features of the main assembly, and retrieve their position, in a transform matrix.
You can use this for example :
Sub import_Pos()
Dim asynconn As New pfcls.CCpfcAsyncConnection
Dim conn As pfcls.IpfcAsyncConnection
Dim session As pfcls.IpfcBaseSession
Dim mdlname
Set conn = asynconn.Connect(", ", ".", 5)
Set session = conn.session
Dim model As IpfcModel
Set model = session.CurrentModel
Dim modelDesc As IpfcModelDescriptor
'======================================================================
'Loop through all the components and retrieve information for all
'instance of the model found
'======================================================================
Dim components As CpfcFeatures
Dim component As IpfcComponentFeat
Dim my_assembly As IpfcSolid
Set my_assembly = model
Set components = my_assembly.ListFeaturesByType(False, EpfcFeatureType.EpfcFEATTYPE_COMPONENT)
Dim WS As Worksheet
Set WS = ActiveSheet
Dim lig As Integer
lig = 1
col_deb_position_rel = 2
For Each component In components
Set modelDesc = component.ModelDescr
'======================================================================
'Save the filename of the component
'======================================================================
WS.Cells(lig, 1).Value = component.ModelDescr.GetFileName
'======================================================================
'Save the position of the component
'======================================================================
WS.Cells(lig, col_deb_position_rel).Value = component.Position.matrix.Item(0, 0)
WS.Cells(lig, col_deb_position_rel + 1).Value = component.Position.matrix.Item(0, 1)
WS.Cells(lig, col_deb_position_rel + 2).Value = component.Position.matrix.Item(0, 2)
WS.Cells(lig, col_deb_position_rel + 3).Value = component.Position.matrix.Item(1, 0)
WS.Cells(lig, col_deb_position_rel + 4).Value = component.Position.matrix.Item(1, 1)
WS.Cells(lig, col_deb_position_rel + 5).Value = component.Position.matrix.Item(1, 2)
WS.Cells(lig, col_deb_position_rel + 6).Value = component.Position.matrix.Item(2, 0)
WS.Cells(lig, col_deb_position_rel + 7).Value = component.Position.matrix.Item(2, 1)
WS.Cells(lig, col_deb_position_rel + 8).Value = component.Position.matrix.Item(2, 2)
WS.Cells(lig, col_deb_position_rel + 9).Value = component.Position.matrix.Item(3, 0)
WS.Cells(lig, col_deb_position_rel + 10).Value = component.Position.matrix.Item(3, 1)
WS.Cells(lig, col_deb_position_rel + 11).Value = component.Position.matrix.Item(3, 2)
lig = lig + 1
Next
conn.Disconnect (2)
End Sub