
Set partdocument1 = ("your_path\DocumentToOpen.CATPart") Replace "Part" by "Product" or "Drawing" to have the corresponding document. You didn't create another object with this method but just opened Sketcher. Notice that Set assign an object to a variable. Set geometricelements1 = sketch1.GeometricElements Let's head to the Part Design workbench !įor the property GeometricElements, if you've already defined a sketch named sketch1, you can type :ĭim geometricelements1 as GeometricElements Set circle2D1 = factory2D1.CreateClosedCircle(200, 90, 22) Set spline2D1 = factory2D1temp.CreateSpline(arrayOfObject1) Set arrayOfObject1(i - 1) = controlPoint2D1 Set controlPoint2D1 = factory2D1.CreateControlPoint(H, V) V = Worksheets("Feuil1").Range("B" & i).Value H = Worksheets("Feuil1").Range("A" & i).Value While Worksheets("Feuil1").Range("A" & i) "" Set sketches1 = hybridBody1.HybridSketches Then create a circle : center (200,90), radius = 22 Create a spline in CATIA V5 from this table. You have an Excel table available which contain coordinates of points. Let's try a little crossover exercice between CATIA and Excel
#Catia v5 code#
Refer to the help for the definition of more methodsĬreates and returns a 2D spline control point.Ĭreates and returns the intersection of an object with the sketch.Ĭreates and returns the possible intersections of an object with the sketch.Ĭreates and returns the projection of an object on the sketch.Ĭreates and returns the possible projections of an object on the sketch.ĭon't forget to use the macro recorder when you need a specific thing, it's a rough code but always useful. 'The CreateSpline function needs a CATSafeArrayVariant according to the help

Set controlPoint2D3 = factory2D1.CreateControlPoint(H3, V3) Set controlPoint2D2 = factory2D1.CreateControlPoint(H2, V2) Set controlPoint2D1 = factory2D1.CreateControlPoint(H1, V1) 'Create a spline with three control points like this : 'A spline needs control points instead of simple points Set circle2D1 = factory2D1.CreateClosedCircle(center_H_coordinate, center_V_coordinate, radius_of_your_circle) Set line2D1 = factory2D1.CreateLine(first_point_H_coordinate, first_point_V_coordinate, second_point_H_coordinate, second_point_V_coordinate ) Set point2D1 = factory2D1.CreatePoint(your_H_coordinate, your_V_coordinate) I suppose that the sketch is in your geometrical set (the code with the sketch directly in the body is slightly the same)įirst I make a short list of the useful items in the sketch mode :

Set sketches1 = hybridbody1.HybridSketches Set hybridBody1 = hybridBodies1.Item("Geometrical Set.1") With the sketch in your geometrical set.Set originelements1 = part1.OriginElements Set partDocument1 = myDocument.Add("Part") Set CATIA = CreateObject("CATIA.Application") Set CATIA = GetObject("CATIA.Application")
