For example, I found my part's volume and mass thanks to below codes.And also ı want to figure out position (x,y,z,rotx,roty,rotz) by like these codes.Is it possible?Thanks a lot now.
MsgBox "Part Volume: " &MyProduct.Analyze.Volume
MsgBox "Part Mass: " &MyProduct.Analyze.Mass
Option Explicit
Dim strSearch As String
Dim PartFound As Boolean
'Dim MySelection As Selection
Sub CATMain()
Dim MyDoc As Document
Dim MyProduct As Product
Set MyDoc = CATIA.ActiveDocument
Set MyProduct = MyDoc.Product
'Set MySelection = MyDoc.Selection
strSearch = InputBox("Input Search String")
PartFound = False
If strSearch = "" Then
MsgBox "Search String is Empty", vbExclamation, "Error"
End
End If
Call Traverse(MyProduct)
If PartFound = True Then
MsgBox "Part Found", vbInformation, "Success"
Else
MsgBox "Part Not Found", vbExclamation, "Fail"
End If
End Sub
Sub Traverse(MyProduct As Product)
Dim i As Integer
Dim PartName As String
If PartFound = True Then
Exit Sub
End If
For i = 1 To MyProduct.Products.Count
If MyProduct.Products.Item(i).Products.Count = 0 Then
PartName = MyProduct.Products.Item(i).ReferenceProduct.Parent.Name
If PartName = strSearch Then
PartFound = True
Dim MySelection As Selection
Set MySelection = MyProduct.Parent.Selection
MySelection.Clear
MySelection.Add MyProduct.Products.Item(i)
CATIA.StartCommand "center graph"
CATIA.StartCommand "reframe on"
MsgBox "Part Volume: " &MyProduct.Analyze.Volume
MsgBox "Part Mass: " &MyProduct.Analyze.Mass
End If
Else
Call Traverse(MyProduct.Products.Item(i).ReferenceProduct)
End If
Next
End Sub