how to export points in catia into .txt file or to excel sheet?

i am having a problem
i want to export points coordinates from cat part into .txt file

5 Answers

I got this from some user in some forum. Did some modification in it as well. You may try to find out if its working.

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 Integer
Dim PartDocument1

Sub CATMain()

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



'objGEXCELSh.Application.ActiveWorkbook.SaveAs (ExcelFolder & Left(CATIA.ActiveDocument.Name,Len(CATIA.ActiveDocument.Name)-8) & ".xls")

End Sub

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

If Err.Number <> 0 Then
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

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


End Sub

you can use macro to do that. Contact me if you would like to know more

thank you, it works and it's GREAT !

I've tried your Macro and it's looking promising- it opens excel and sets up titles, plus it highlights the points in catia- but the code gives an error in this line-
Point.GetCoordinates (coords)

and to be honest, I've no idea what I'm doing when it comes to VB.
If it makes a difference, I'm using windows 8, and Catia R18.
any ideas?
Thanks, Simon

Edit- I also get an error message-
"run-time error 13
type mismatch"

Hi, I tried with the Macro Muhammad shared but i only get an excel window with column titles after running it.

Could someone help, maybe with the earlier steps, like Do i need to create and save also a part before running it? Thank you very much.