Question

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.

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

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.

Was it helpful?

Solution

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

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

Regarding your point information:

Just to show you how to drill down to a point, I used Insert > Object Resolution of 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.

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

OTHER TIPS

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).

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top