/// <summary> /// Создание гравировки текста на детали /// </summary> /// <param name="length">Длина нижней части втулки</param> /// <param name="outerRadius">Внешний радиус втулки</param> /// <param name="innerRadius">Внутренний радус втулки</param> private void CreateEngraving(double length, double outerRadius, double innerRadius, string engravingText) { var document = (ksDocument3D)_kompas.ActiveDocument3D(); var part = (ksPart)document.GetPart((short)Part_Type.pTop_Part); double coordinateY = ((outerRadius + innerRadius) / 2) - 1.5; const int coordinateX = 0; const int angle = 0; const double characterHeight = 2; const int textNarrowing = 1; const int bitVector = 0; const int align = 1; const double topHeight = 1; const double bottomHeight = 0; ksEntity entityPlaneOffset = (ksEntity)part.NewEntity((short) Obj3dType.o3d_planeOffset); ksEntity entityPlaneXOY = (ksEntity)part.GetDefaultEntity((short) Obj3dType.o3d_planeXOY); ksPlaneOffsetDefinition planeOffsetDefinition = (ksPlaneOffsetDefinition)entityPlaneOffset.GetDefinition(); planeOffsetDefinition.SetPlane(entityPlaneXOY); planeOffsetDefinition.direction = true; planeOffsetDefinition.offset = length; entityPlaneOffset.Create(); ksEntity entitySketch = (ksEntity)part.NewEntity((short) Obj3dType.o3d_sketch); ksSketchDefinition sketchDefinition = (ksSketchDefinition) entitySketch.GetDefinition(); sketchDefinition.SetPlane(entityPlaneOffset); entitySketch.Create(); ksDocument2D sketchEdit = (ksDocument2D)sketchDefinition. BeginEdit(); int text = sketchEdit.ksText(coordinateX, coordinateY, angle, characterHeight, textNarrowing, bitVector, engravingText); sketchEdit.ksSetTextAlign(text, align); sketchDefinition.EndEdit(); CutExtrusion(part, entitySketch, topHeight, bottomHeight, false); }