Code:
Sub SketchMakro1()Set BT = CATIA.ActiveDocument.Part
Set body1 = BT.Bodies.Item("Gewinde")
Set sketches1 = body1.Sketches
'Set reference1 = Bauteil.CreateReferenceFromName(face3)
Set sketch1 = sketches1.Add(Flaeche3)
'Set sketch1 = Bohrungeins.Sketch
Dim arrayOfVariantOfDouble1(8)
arrayOfVariantOfDouble1(0) = 0#
arrayOfVariantOfDouble1(1) = 0#
arrayOfVariantOfDouble1(2) = 0#
arrayOfVariantOfDouble1(3) = 0#
arrayOfVariantOfDouble1(4) = 0#
arrayOfVariantOfDouble1(5) = 0#
arrayOfVariantOfDouble1(6) = 0#
arrayOfVariantOfDouble1(7) = 0#
arrayOfVariantOfDouble1(8) = 0#
sketch1.SetAbsoluteAxisData arrayOfVariantOfDouble1
BT.InWorkObject = sketch1
Set factory2D1 = sketch1.OpenEdition()
Set geometricElements1 = sketch1.GeometricElements
Set axis2D1 = geometricElements1.Item("AbsoluteAxis")
Set line2D1 = axis2D1.GetItem("HDirection")
line2D1.ReportName = 1
Set line2D2 = axis2D1.GetItem("VDirection")
line2D2.ReportName = 2
Set point2D1 = factory2D1.CreatePoint(10, 10)
point2D1.ReportName = 3
point2D1.Construction = False
Dim body2 As Body
Set body2 = BT.Bodies.Item("Funktionsteil")
Dim shapes1 As Shapes
Set shapes1 = body2.Shapes
Dim pad1 As Pad
Set pad1 = shapes1.Item(1)
Dim reference2 As Reference
Set reference2 = BT.CreateReferenceFromBRepName("FSur:(Face:(Brp:(Pad.2;2);None:();Cf11:());WithPermanentBody;WithoutBuildError;WithInitialFeatureSupport;MonoFond;MFBRepVersion_CXR15)", pad1)
Dim geometricElements2 As GeometricElements
Set geometricElements2 = factory2D1.CreateIntersections(reference2)
Dim geometry2D1 As Geometry2D
Set geometry2D1 = geometricElements2.Item("Mark.1")
geometry2D1.Construction = True
Dim constraints1 As Constraints
Set constraints1 = sketch1.Constraints
Dim reference3 As Reference
Set reference3 = BT.CreateReferenceFromObject(point2D1)
Dim reference4 As Reference
Set reference4 = BT.CreateReferenceFromObject(geometry2D1)
Dim constraint1 As Constraint
Set constraint1 = constraints1.AddBiEltCst(catCstTypeDistance, reference3, reference4)
constraint1.Mode = catCstModeDrivingDimension
Dim length1 As Length
Set length1 = constraint1.Dimension
length1.Value = A
Dim reference5 As Reference
Set reference5 = part1.CreateReferenceFromBRepName("FSur:(Face:(Brp:(Pad.2;0:(Brp:(Sketch.6;2)));None:();Cf11:());WithPermanentBody;WithoutBuildError;WithInitialFeatureSupport;MonoFond;MFBRepVersio n_CXR15)", pad1)
Dim geometricElements3 As GeometricElements
Set geometricElements3 = factory2D1.CreateIntersections(reference5)
Dim geometry2D2 As Geometry2D
Set geometry2D2 = geometricElements3.Item("Mark.1")
geometry2D2.Construction = True
Dim reference6 As Reference
Set reference6 = part1.CreateReferenceFromObject(point2D1)
Dim reference7 As Reference
Set reference7 = part1.CreateReferenceFromObject(geometry2D2)
Dim constraint2 As Constraint
Set constraint2 = constraints1.AddBiEltCst(catCstTypeDistance, reference6, reference7)
constraint2.Mode = catCstModeDrivingDimension
Dim length2 As Length
Set length2 = constraint2.Dimension
length2.Value = C
sketch1.CloseEdition
part1.InWorkObject = body1
part1.Update