d2z
Automotive
- May 1, 2013
- 6
Hi all
i'm new in catia macro programming. what i'm working on now is extracting points coordinates from CATPart.
my problem now is how to extract point in a sub geometrical set.
refer picture below (point 1 in geometrical set.2)
i only manage to extract point from 'parent geometrical set' (geometrical set.1)
here is my code for now. do comment what i can improve the current code. i have really basic programming skill.
tq in advance
i'm new in catia macro programming. what i'm working on now is extracting points coordinates from CATPart.
my problem now is how to extract point in a sub geometrical set.
refer picture below (point 1 in geometrical set.2)
i only manage to extract point from 'parent geometrical set' (geometrical set.1)
here is my code for now. do comment what i can improve the current code. i have really basic programming skill.
tq in advance
Code:
Sub CATMain()
Dim ActDoc As Object
Set ActDoc = CATIA.ActiveDocument
Dim part1 As Object
Set part1 = ActDoc.Part
Dim hybridBodies1 As Object
Set hybridBodies1 = part1.HybridBodies
For geometSet = 1 To hybridBodies1.Count
Dim hybridBody1 As Object
Set hybridBody1 = hybridBodies1.Item(geometSet)
Dim hybridShapes1 As Object
Set hybridShapes1 = hybridBody1.HybridShapes
For geometElem = 1 To hybridShapes1.Count
Dim point1
Set point1 = hybridShapes1.Item(geometElem)
On Error Resume Next
Dim coordArray(2)
Dim sel As Object
Set sel = ActDoc.selection
sel.Add (point1)
sel.Clear
point1.GetCoordinates coordArray
p=0
msgbox "Point: " & point1.Name & vbNewLine & "X : " & coordArray(p) & vbNewLine & "Y: " & coordArray(p+1) & vbNewLine & "Z: " & coordArray(p+2)
p + 1
Next 'geometElem
Next 'geometSet
End Sub