[indent]'variables[/indent]
Dim objGEXCELapp As Object
Dim objGEXCELwkBks As Object
Dim objGEXCELwkBk As Object
Dim objGEXCELwkShs As Object
Dim objGEXCELSh As Object
Dim coords(3) As Integer
Sub CATMain()[indent]'main sub[/indent]
startExcel
exportPolylinePoints
End Sub
[COLOR=#4E9A06][COLOR=#8AE234]'****************************************************************************
Sub StartEXCEL()[indent]'function for opening excel[/indent]
'****************************************************************************
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") = "ITEM X"
objGEXCELSh.Cells(2, "A") = "POINT"
objGEXCELSh.Cells(2, "B") = "X"
objGEXCELSh.Cells(2, "C") = "Y"
objGEXCELSh.Cells(2, "D") = "Z"
objGEXCELSh.Cells(2, "E") = "RADIUS"
End Sub[/color][/color]
'***********************************************************
Sub exportPolylinePoints[indent]'function for exporting the points[/indent]
'***********************************************************
Dim selection1 As selection 'selection in Catia
Set Selection1 = CATIA.ActiveDocument.selection
'pick first element (the polyline) of the selection in Catia
Dim polyline1 As HybridShapePolyline
Set polyline1 = selection1.Item(1).value
'get the number of elements in the polyline
dim polyline1NrOfElements as long
polyline1NrOfElements = polyline1.NumberOfElements
MsgBox "The selected polyline has " & polyline1NrOfElements & " points." 'display number of elements
for i = 1 to polyline1NrOfElements
[highlight #EF2929]dim pointRef as reference
dim pointRad as double
polyline1.GetElement(i), pointRef, pointRad[/highlight]
'How is the result from GetElement presented? This is my problem.
'Write PointData to Excel Sheet
objGEXCELSh.Cells(i + 2, "A") = pointRef.Name
objGEXCELSh.Cells(i + 2, "B") = coordsArray(0)
objGEXCELSh.Cells(i + 2, "C") = coordsArray(1)
objGEXCELSh.Cells(i + 2, "D") = coordsArray(2)
objGEXCELSh.Cells(i + 2, "E") = coordsArray(3) 'the radius
objGEXCELSh.Cells(i + 3, "A") = "TOTAL LENGTH = "
next
end Sub