Catia Macro Export Points to Excel (get coordinates from a local axis system)

Hi there,

I'm using a nice Catia Macro in order to get points coordinates to an excel File. This macro gets the coordinates from the absolute axis system. Now I need to get these coordinates from a different axis system. Any idea/tip how can I do it?

Please find below the code I've been using:

Dim objGEXCELapp As Object
Dim objGEXCELwkBks As Object
Dim objGEXCELwkBk As Object
Dim objGEXCELwkShs As Object
Dim objGEXCELSh As Object
Dim FS, f, f1, fc, s
Dim coords(2) As Variant
Dim partDocument1

Sub CATMain()

CATIA.ActiveDocument.Selection.Search "CATGmoSearch.Point,all"

StartEXCEL

ExportPoint

End Sub

'******************************************************************************
Sub StartEXCEL()
'******************************************************************************
Err.Clear
On Error Resume Next
Set objGEXCELapp = GetObject(, "EXCEL.Application")

If Err.Number <> 0 Then
Err.Clear
Set objGEXCELapp = CreateObject("EXCEL.Application")
End If

objGEXCELapp.Application.Visible = True
Set objGEXCELwkBks = objGEXCELapp.Application.WorkBooks
Set objGEXCELwkBk = objGEXCELwkBks.Add
Set objGEXCELwkShs = objGEXCELwkBk.Worksheets(1)
Set objGEXCELSh = objGEXCELwkBk.Sheets(1)
objGEXCELSh.Cells(1, "A") = "Name"
objGEXCELSh.Cells(1, "B") = "X"
objGEXCELSh.Cells(1, "C") = "Y"
objGEXCELSh.Cells(1, "D") = "Z"

End Sub

'******************************************************************************
Sub ExportPoint()
'******************************************************************************
For i = 1 To CATIA.ActiveDocument.Selection.Count
Set Selection = CATIA.ActiveDocument.Selection
Set Element = Selection.Item(i)
Set Point = Element.Value

'Write PointData to Excel Sheet
Point.GetCoordinates (coords)

objGEXCELSh.Cells(i + 1, "A") = Point.Name
objGEXCELSh.Cells(i + 1, "B") = coords(0)
objGEXCELSh.Cells(i + 1, "C") = coords(1)
objGEXCELSh.Cells(i + 1, "D") = coords(2)

Next

End Sub

Thank you in advance!

Pedro

Answer
 
Comments 0

1 Answer

I would run the macro as-is to put the points relative to the Absolute Axis System, and then I would use an Axis-to-Axis Transformation to move the points to the local axis system.

 
Comments 0