예제 #1
0
        /// <summary>
        /// Построение детали
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BuildBearingButton(object sender, EventArgs e)
        {
            ValidateTextFields();
            if (_errorList.Count != 0)
            {
                return;
            }
            _errorList.Clear();

            RollingElementForm rollingElementForm = RollingElementForm.Ball;

            if (RollingElementBall.Checked)
            {
                rollingElementForm = RollingElementForm.Ball;
            }
            if (RollingElementCylinder.Checked)
            {
                rollingElementForm = RollingElementForm.Cylinder;
            }

            double bearingWidth  = Convert.ToDouble(bearingWidthBox.Text);
            double innerRimDiam  = Convert.ToDouble(innerRimDiamBox.Text);
            double outerRimDiam  = Convert.ToDouble(outerRimDiamBox.Text);
            double rimsThickness = Convert.ToDouble(rimsThicknessBox.Text);
            double ballDiam      = Convert.ToDouble(rollingElementDiam.Text);

            BearingParametrs bearing = null;

            try
            {
                bearing = new BearingParametrs(rollingElementForm, bearingWidth, innerRimDiam, outerRimDiam, rimsThickness, ballDiam);
            }
            catch (ArgumentException exception)
            {
                _errorList.Add(exception.Message);
                ShowErrors();
                return;
            }
            _kompas3D.BuildBearing(bearing);
        }
예제 #2
0
        /// <summary>
        /// Метод для построения подшпника
        /// </summary>
        /// <param name="bearing">Параметры подшипника</param>
        public void BuildBearing(BearingParametrs bearing)
        {
            StartKompas();

            if (_kompas == null)
            {
                throw new Exception("Не возможно построить деталь. Нет связи с Kompas3D.");
            }

            if (bearing == null)
            {
                throw new ArgumentNullException(nameof(bearing));
            }

            ksDocument3D doc = _kompas.Document3D();

            doc.Create();

            //указатель на деталь
            ksPart rims = doc.GetPart((short)Kompas6Constants3D.Part_Type.pTop_Part);
            //определим плоскость XY
            ksEntity planeXOY = rims.GetDefaultEntity((short)Kompas6Constants3D.Obj3dType.o3d_planeXOY);
            //создаем переменную эскиза
            ksEntity rimsSketch = rims.NewEntity((short)Kompas6Constants3D.Obj3dType.o3d_sketch);
            //получим указатель на параметры эскиза
            ksSketchDefinition rimsSketchDef = rimsSketch.GetDefinition();

            //зададим плоскость на которой создаем эскиз
            rimsSketchDef.SetPlane(planeXOY);
            // создаем эскиз
            rimsSketch.Create();
            //входим в режим редактирование эскиза
            ksDocument2D rimsDoc = rimsSketchDef.BeginEdit();

            DrawInnerRim(rimsDoc, bearing.BearingWidth, bearing.InnerRimDiam, bearing.OuterRimDiam,
                         bearing.RimsThickness, bearing.RollingElementDiam, bearing.RollingElementForm,
                         bearing.BearingAxis, bearing.GutterDepth, bearing.GutterWidth);
            DrawOuterRim(rimsDoc, bearing.BearingWidth, bearing.InnerRimDiam, bearing.OuterRimDiam,
                         bearing.RimsThickness, bearing.RollingElementDiam, bearing.RollingElementForm,
                         bearing.BearingAxis, bearing.GutterDepth, bearing.GutterWidth);
            //закончили редактировать эскиз
            rimsSketchDef.EndEdit();

            ksPart             ball          = doc.GetPart((short)Kompas6Constants3D.Part_Type.pTop_Part);
            ksEntity           planeXOY1     = ball.GetDefaultEntity((short)Kompas6Constants3D.Obj3dType.o3d_planeXOY);
            ksEntity           ballSketch    = ball.NewEntity((short)Kompas6Constants3D.Obj3dType.o3d_sketch);
            ksSketchDefinition ballSketchDef = ballSketch.GetDefinition();

            ballSketchDef.SetPlane(planeXOY1);
            ballSketch.Create();
            ksDocument2D ballDoc = ballSketchDef.BeginEdit();

            DrawBalls(ballDoc, bearing.BearingWidth, bearing.InnerRimDiam, bearing.OuterRimDiam,
                      bearing.RimsThickness, bearing.RollingElementDiam, bearing.RollingElementForm,
                      bearing.BearingAxis, bearing.GutterDepth, bearing.GutterWidth);
            ballSketchDef.EndEdit();

            ksEntity planeXOZ = ball.GetDefaultEntity((short)Kompas6Constants3D.Obj3dType.o3d_planeXOZ);
            ksEntity planeYOZ = ball.GetDefaultEntity((short)Kompas6Constants3D.Obj3dType.o3d_planeXOY);

            BossRotatedExtrusion(rims, rimsSketch, (short)Direction_Type.dtNormal);
            BallsConcentricArray(ball, ballSketch, (short)Direction_Type.dtNormal, planeXOZ, planeYOZ);

            ksEntity mas = ball.NewEntity((short)Obj3dType.o3d_circularCopy);
        }