private void CreateBase(CadConnect connector, ksDocument3D document, double capsuleRadius, double clipLenght, double handleRadius, double handleLenght, double totalLenght, double gridLenght) { var part = (ksPart)document.GetPart((short)Part_Type.pTop_Part); var currentPlane = (ksEntity)part.GetDefaultEntity((short)Obj3dType.o3d_planeXOY); var _entitySketch = (ksEntity)part.NewEntity((short)Obj3dType.o3d_sketch); var _sketchDefinition = (ksSketchDefinition)_entitySketch.GetDefinition(); _sketchDefinition.SetPlane(currentPlane); _entitySketch.name = "1"; _entitySketch.Create(); var _sketchEdit = (ksDocument2D)_sketchDefinition.BeginEdit(); _sketchEdit.ksLineSeg (0, 0, 0, handleRadius, 1); _sketchEdit.ksLineSeg (0, handleRadius, handleLenght, handleRadius, 1); var capsuleStartX = totalLenght - capsuleRadius - clipLenght; _sketchEdit.ksLineSeg(handleLenght, handleRadius, capsuleStartX, capsuleRadius, 1); _sketchEdit.ksLineSeg(capsuleStartX, capsuleRadius, totalLenght - capsuleRadius, capsuleRadius, 1); _sketchEdit.ksArcByPoint(totalLenght - capsuleRadius, 0, capsuleRadius, totalLenght - capsuleRadius, capsuleRadius, totalLenght, 0, -1, 1); _sketchEdit.ksLineSeg(totalLenght, 0, 0, 0, 1); _sketchEdit.ksLineSeg (0, 0, totalLenght, 0, 3); _sketchDefinition.EndEdit(); var entityRotated = (ksEntity)part.NewEntity((short)Obj3dType.o3d_baseRotated); var entityRotatedDefinition = (ksBaseRotatedDefinition)entityRotated.GetDefinition(); entityRotatedDefinition.directionType = 0; entityRotatedDefinition.SetSideParam(true, 360); entityRotatedDefinition.SetSketch(_entitySketch); entityRotated.Create(); document.shadedWireframe = true; document.drawMode = 3; CreateHorizontalTors(part, totalLenght, gridLenght, capsuleRadius); CreateVerticalTorsRight(part, totalLenght, gridLenght, capsuleRadius); CreateVerticalTorsLeft(part, totalLenght, gridLenght, capsuleRadius); }
/// <summary> /// Конструктор /// </summary> /// <param name="parameters">Параметры</param> public Builder(Parameters parameters) { using (var connector = new CadConnect()) { var document = connector.Connect(); document.Create(false, true); document = (ksDocument3D)connector.Kompas.ActiveDocument3D(); var part = (ksPart)document.GetPart((short)Part_Type.pTop_Part); CreateBase(connector, document, parameters.CapsuleRadius / 2, parameters.ClipLenght, parameters.HandleDiametr / 2, parameters.HandleLenght, parameters.TotalLenght, parameters.GridLenght); connector.Kompas.Visible = true; } }