Exporting/importing points using Excel is a common request. But for obvious reasons each customer has slightly different spreadsheet format and maybe even point naming rules.
So the goal is to create a universal macro that can be easily adjusted (with configuration files for example) to work for any customer.
I want to know how extract a geometrical set name from a CATPart.(all geometrical sets that the part contain, no matter the quantity of GS or even if the GS have another one inside(no matter how many have) and export it to Excel file.
jzecha...
here are my premises:
[ol 1]
[li]I have a set with points called HoleCenterPoints, located directly under part.[/li]
[li]I have an empty body called Holes (holes will end up here)[/li]
[li]I have an empty set called Hole_References (line normal to surface and plane normal to curve will be added here for each HoleCenterPoint-point).[/li]
[li]My surface is a dead one, i.e. a parameter... called InputSurface (I tested the script on a sphere)[/li]
[li]Parameters of the holes are metric, you will need to change it according to your needs.[/li]
[/ol]
Sub CATMain()
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument
Dim Sel As Selection
Set Sel = partDocument1.Selection
Dim part1 As Part
Set part1 = partDocument1.Part
Dim hybridBodies1 As hybridBodies
Set hybridBodies1 = part1.hybridBodies
Dim hybridBody1 As HybridBody
Set hybridBody1 = hybridBodies1.item("Hole_References")
part1.InWorkObject = hybridBody1
Dim hybridShapeFactory1 As HybridShapeFactory
Set hybridShapeFactory1 = part1.HybridShapeFactory
Dim parameters1 As Parameters
Set parameters1 = part1.Parameters
Dim hybridShapeSurfaceExplicit1 As HybridShapeSurfaceExplicit
Set hybridShapeSurfaceExplicit1 = parameters1.item("InputSurface")
Dim hybridBody2 As HybridBody
Set hybridBody2 = hybridBodies1.item("HoleCenterPoints")
Dim myHybridShape As HybridShape
Dim coord(2)
Dim bodies1 As Bodies
Set bodies1 = part1.Bodies
Dim body1 As Body
Set body1 = bodies1.item("Holes")
For Each myHybridShape In hybridBody2.HybridShapes
myHybridShape.GetCoordinates coord
Dim hybridShapeLineNormal1 As HybridShapeLineNormal
Set hybridShapeLineNormal1 = hybridShapeFactory1.AddNewLineNormal(hybridShapeSurfaceExplicit1, myHybridShape, 0, 20, False)
Dim hybridShapePlaneNormal1 As HybridShapePlaneNormal
Set hybridShapePlaneNormal1 = hybridShapeFactory1.AddNewPlaneNormal(hybridShapeLineNormal1, myHybridShape)