Exporting points in catia into .txt file or to Excel sheet

Exporting points in catia into .txt file or to Excel sheet

https://grabcad.com/questions/how-to-export-points-in-catia-into-txt-file-or-to-excel-sheet


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"
StartEXCEL
ExportPoint
'objGEXCELSh.Application.ActiveWorkbook.SaveAs (ExcelFolder & Left(CATIA.ActiveDocument.Name,Len(CATIA.ActiveDocument.Name)-8) & ".xls") 
'objGEXCELSh.Application.ActiveWorkbook.Close
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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值