vba 如何将点坐标从 CATIA 产品导出到 Excel

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13704315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 18:42:09  来源:igfitidea点击:

How can I export point coordinates from a CATIA product to excel

vbacatia

提问by JHall

What I'm looking for is a VB script written in either excel or CATIA that can export the coordinates of points in a CATProduct to an excel spreadsheet. The process needs to be as automated as possible due to the large number of points that I am dealing with.

我正在寻找的是一个用 excel 或 CATIA 编写的 VB 脚本,它可以将 CATProduct 中的点坐标导出到 Excel 电子表格。由于我要处理的点数很多,因此该过程需要尽可能自动化。

Eventually, I will need to export only specific points and group these points together in 4's to identify what part they belong to.

最终,我只需要导出特定的点并将这些点组合成 4 个,以确定它们属于哪个部分。

I have an excel script that allow for points to be imported, but this only takes points from a geometry set and the points in the product I'm looking at are in the part body.

我有一个允许导入点的 excel 脚本,但这仅从几何集合中获取点,而我正在查看的产品中的点位于零件主体中。

采纳答案by GisMofx

Follow this link here to write to a CSV file which can be imported to excel: http://www.coe.org/p/fo/et/thread=27438

按照这里的链接写入可以导入到 excel 的 CSV 文件:http: //www.coe.org/p/fo/et/thread=27438

You'll need to add the excel VBA references files to you Catia VBA Project.

您需要将 Excel VBA 引用文件添加到 Catia VBA 项目。

Regarding your point information:

关于您的积分信息:

Just to show you how to drill down to a point, I used Insert > Object Resolutionof a basic point and included some comments on how to get the coordinates and also where to loop. There is one thing to note, some methods are "marked as restricted" which necessitates the intermediate "hack" of setting the point object to a variant before you can use the "GetCoordinates" sub.

只是为了向您展示如何深入到一个点,我使用了一个基本点的插入 > 对象分辨率,并包含了一些关于如何获取坐标以及循环位置的注释。有一点需要注意,一些方法被“标记为受限”,这需要在您可以使用“GetCoordinates”子之前将点对象设置为变体的中间“hack”。

Sub GetPointData()
'---- Begin resolution script for object : Point.1

Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part
Set part1 = partDocument1.Part

Dim hybridBodies1 As HybridBodies
Set hybridBodies1 = part1.HybridBodies

Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1")

Dim hybridShapes1 As HybridShapes
Set hybridShapes1 = hybridBody1.HybridShapes

Dim hybridShapePointCoord1 As HybridShapePointCoord
Dim XYZ(2) As Variant
Dim var As Variant


'BEGIN LOOP THROUGH YOUR POINTS HERE
Set hybridShapePointCoord1 = hybridShapes1.Item("Point.1")
Set var = hybridShapePointCoord1
var.GetCoordinates XYZ
'WRITE XYZ TO CSV
'NEXT POINT
'END LOOP

'---- End resolution script
End Sub

回答by ferdo

I believe it can be done, what I would do is to search and select all points in CATProduct, then get parent for each selected point up to the Part, then get coordinates (of course, you need to write everything in Excel if you have the code there).

我相信这是可以做到的,我要做的是在CATProduct中搜索并选择所有点,然后将每个选定点的父级获取到Part,然后获取坐标(当然,如果您有的话,您需要在Excel中编写所有内容那里的代码)。

I don't know if you can upload here your excel vba but shouldn't be so difficult.

我不知道您是否可以将您的 excel vba 上传到这里,但应该不会那么难。