/// <summary>
        /// Основание ручки
        /// </summary>
        /// <param name="doorParameters"></param>
        /// <param name="doorPart"></param>
        /// <param name="eyePlaneOffset"></param>
        private void HandleBase(DoorParameters doorParameters,
                                ksPart doorPart, ksEntity eyePlaneOffset)
        {
            ksEntity keyPlaneOffset = doorPart.NewEntity((short)
                                                         Obj3dType.o3d_planeOffset);
            ksPlaneOffsetDefinition pod5 =
                keyPlaneOffset.GetDefinition();

            pod5.SetPlane(eyePlaneOffset);
            pod5.offset = 25;
            keyPlaneOffset.Create();
            ksEntity keySketch = doorPart.NewEntity((short)
                                                    Obj3dType.o3d_sketch);
            ksSketchDefinition keySketchDefinition =
                keySketch.GetDefinition();

            keySketchDefinition.SetPlane(keyPlaneOffset);
            keySketch.Create();
            ksDocument2D key = keySketchDefinition.BeginEdit();

            DrawRectangle(key, doorParameters.YKey / 2.0,
                          doorParameters.WidthDoor - 450, 200, 26, -90);
            keySketchDefinition.EndEdit();
            Extrude(doorPart, keySketch, 5,
                    (short)Direction_Type.dtNormal);
        }
        /// <summary>
        /// Добавление элементов на полотно двери
        /// </summary>
        /// <param name="doorParameters"></param>
        /// <param name="doorPart"></param>
        /// <param name="planeXoY"></param>
        private void DoorModification(DoorParameters doorParameters,
                                      ksPart doorPart, ksEntity planeXoY)
        {
            ksEntity eyePlaneOffset = doorPart.NewEntity((short)
                                                         Obj3dType.o3d_planeOffset);
            ksPlaneOffsetDefinition eyeDefinition =
                eyePlaneOffset.GetDefinition();

            eyeDefinition.SetPlane(planeXoY);
            eyeDefinition.offset = doorParameters.WeigthDoor;
            eyePlaneOffset.Create();
            ksEntity eyeSketch = doorPart.NewEntity((short)
                                                    Obj3dType.o3d_sketch);
            ksSketchDefinition eyeSketchDefinition =
                eyeSketch.GetDefinition();

            eyeSketchDefinition.SetPlane(eyePlaneOffset);
            eyeSketch.Create();
            ksDocument2D eye = eyeSketchDefinition.BeginEdit();

            eye.ksCircle(doorParameters.YEye / 2.0, 0, 15, 1);
            eyeSketchDefinition.EndEdit();
            Cut(doorPart, eyeSketch, doorParameters.WeigthDoor);
            AnimalDoor(doorParameters, doorPart, eyePlaneOffset);
            DoorKnob(doorParameters, doorPart, eyePlaneOffset);
        }
Exemple #3
0
        /// <summary>
        /// Создать эскиз
        /// </summary>
        /// <param name="iSketch">Эскиз</param>
        /// <param name="iDefinitionSketch">Определение эскиза</param>
        /// <param name="offset">Смещение от начальной плоскости</param>
        private void CreateSketch(out ksEntity iSketch, out ksSketchDefinition iDefinitionSketch, double offset = 0)
        {
            #region Создание смещенную плоскость -------------------------
            // интерфейс смещенной плоскости
            ksEntity iPlane = (ksEntity)iPart.NewEntity((short)Obj3dType.o3d_planeOffset);

            // Получаем интрефейс настроек смещенной плоскости
            ksPlaneOffsetDefinition iPlaneDefinition = (ksPlaneOffsetDefinition)iPlane.GetDefinition();

            // Настройки : начальная позиция, направление смещения, расстояние от плоскости, принять все настройки (create)
            iPlaneDefinition.SetPlane(iPart.GetDefaultEntity((short)Obj3dType.o3d_planeXOY));
            iPlaneDefinition.direction = true;
            iPlaneDefinition.offset    = offset;
            iPlane.Create();
            #endregion --------------------------------------------------

            // Создаем обьект эскиза
            iSketch = (ksEntity)iPart.NewEntity((short)Obj3dType.o3d_sketch);

            // Получаем интерфейс настроек эскиза
            iDefinitionSketch = iSketch.GetDefinition();

            // Устанавливаем плоскость эскиза
            iDefinitionSketch.SetPlane(iPlane);

            // Теперь когда св-ва эскиза установлены можно его создать
            iSketch.Create();
        }
Exemple #4
0
        /// <summary>
        /// построение среднего цилиндра детали
        /// </summary>
        /// <param name="param"></param>
        public void MiddleCircle(Parameters param)
        {
            double Radios1 = param.Radios1;
            double Lenght1 = param.Lenght1;
            double Angle2  = param.Angle2;
            var    doc     = (ksDocument3D)_kompas.ActiveDocument3D();
            ksPart part1   = (ksPart)doc.GetPart((short)Part_Type.pTop_Part); // новый компонент

            if (part1 != null)
            {
                ksEntity entityOffsetPlane1 = (ksEntity)part1.NewEntity((short)Obj3dType.o3d_planeOffset);
                ksEntity entitySketch1      = (ksEntity)part1.NewEntity((short)Obj3dType.o3d_sketch);
                if (entityOffsetPlane1 != null)
                {
                    // интерфейс свойств смещенной плоскости
                    ksPlaneOffsetDefinition offsetDef1 = (ksPlaneOffsetDefinition)entityOffsetPlane1.GetDefinition();
                    if (offsetDef1 != null)
                    {
                        offsetDef1.offset = Lenght1;                       // расстояние от базовой плоскости
                        ksEntity basePlane1 = (ksEntity)part1.GetDefaultEntity((short)Obj3dType.o3d_planeXOY);
                        basePlane1.name = "Смещенная плоскость";           // название для плоскости

                        offsetDef1.SetPlane(basePlane1);                   // базовая плоскость
                        entityOffsetPlane1.name   = "Смещенная плоскость"; // имя для смещенной плоскости
                        entityOffsetPlane1.hidden = true;
                        entityOffsetPlane1.Create();                       // создать смещенную плоскость

                        if (entitySketch1 != null)
                        {
                            ksSketchDefinition sketchDef1 = (ksSketchDefinition)entitySketch1.GetDefinition();
                            if (sketchDef1 != null)
                            {
                                sketchDef1.SetPlane(entityOffsetPlane1); // установим плоскость XOY базовой для эскиза
                                entitySketch1.Create();                  // создадим эскиз

                                // интерфейс редактора эскиза
                                ksDocument2D sketchEdit1 = (ksDocument2D)sketchDef1.BeginEdit();
                                sketchEdit1.ksCircle(0, 0, Radios1, 1);
                                sketchDef1.EndEdit();                    // завершение редактирования эскиза
                                ksEntity entityExtr1 = (ksEntity)part1.NewEntity((short)Obj3dType.o3d_baseExtrusion);
                                if (entityExtr1 != null)
                                {
                                    ksBaseExtrusionDefinition extrusionDef1 = (ksBaseExtrusionDefinition)entityExtr1.GetDefinition();
                                    if (extrusionDef1 != null)
                                    {
                                        extrusionDef1.directionType = (short)Direction_Type.dtNormal;
                                        extrusionDef1.SetSideParam(true, (short)End_Type.etBlind, 5, Angle2, true);
                                        extrusionDef1.SetSketch(entitySketch1);  // эскиз операции выдавливания
                                        entityExtr1.Create();                    // создать операцию
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #5
0
        /// <summary>
        /// построение верхней части цилиндра
        /// </summary>
        /// <param name="param"></param>
        public void UpCircle(Parameters param)
        {
            double Radios2 = param.Radios2;
            double Lenght1 = param.Lenght1;
            double Lenght2 = param.Lenght2;
            var    doc     = (ksDocument3D)_kompas.ActiveDocument3D();
            ksPart part2   = (ksPart)doc.GetPart((short)Part_Type.pTop_Part); // новый компонент

            if (part2 != null)
            {
                ksEntity entityOffsetPlane2 = (ksEntity)part2.NewEntity((short)Obj3dType.o3d_planeOffset);
                ksEntity entitySketch2      = (ksEntity)part2.NewEntity((short)Obj3dType.o3d_sketch);
                if (entityOffsetPlane2 != null)
                {
                    ksPlaneOffsetDefinition offsetDef2 = (ksPlaneOffsetDefinition)entityOffsetPlane2.GetDefinition();
                    if (offsetDef2 != null)
                    {
                        offsetDef2.offset = Lenght1 + 5;                   // расстояние от базовой плоскости
                        ksEntity basePlane2 = (ksEntity)part2.GetDefaultEntity((short)Obj3dType.o3d_planeXOY);
                        basePlane2.name = "Смещенная плоскость";           // название для плоскости

                        offsetDef2.SetPlane(basePlane2);                   // базовая плоскость
                        entityOffsetPlane2.name   = "Смещенная плоскость"; // имя для смещенной плоскости
                        entityOffsetPlane2.hidden = true;
                        entityOffsetPlane2.Create();                       // создать смещенную плоскость

                        if (entitySketch2 != null)
                        {
                            ksSketchDefinition sketchDef2 = (ksSketchDefinition)entitySketch2.GetDefinition();
                            if (sketchDef2 != null)
                            {
                                sketchDef2.SetPlane(entityOffsetPlane2); // установим плоскость XOY базовой для эскиза
                                entitySketch2.Create();                  // создадим эскиз

                                ksDocument2D sketchEdit2 = (ksDocument2D)sketchDef2.BeginEdit();
                                sketchEdit2.ksCircle(0, 0, Radios2, 1);
                                sketchDef2.EndEdit();                    // завершение редактирования эскиза
                                ksEntity entityExtr2 = (ksEntity)part2.NewEntity((short)Obj3dType.o3d_baseExtrusion);
                                if (entityExtr2 != null)
                                {
                                    ksBaseExtrusionDefinition extrusionDef2 = (ksBaseExtrusionDefinition)entityExtr2.GetDefinition();
                                    if (extrusionDef2 != null)
                                    {
                                        extrusionDef2.directionType = (short)Direction_Type.dtNormal;
                                        extrusionDef2.SetSideParam(true, (short)End_Type.etBlind, Lenght2, 0, false);
                                        extrusionDef2.SetSketch(entitySketch2);  // эскиз операции выдавливания
                                        entityExtr2.Create();                    // создать операцию
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Создание смещёной плоскости
        /// </summary>
        /// <param name="offset">сдвиг</param>
        /// <param name="plane">плоскость</param>
        /// <param name="ksEntityPlaneOffset">сдвиг плосости</param>
        private void CreatPlaneOffset(double offset, short plane, ksEntity ksEntityPlaneOffset)
        {
            ksEntity ksEntityPlaneXOY = (ksEntity)_ksPart.GetDefaultEntity(plane);
            ksPlaneOffsetDefinition ksPlaneOffsetDefinition =
                (ksPlaneOffsetDefinition)ksEntityPlaneOffset.GetDefinition();

            ksPlaneOffsetDefinition.SetPlane(ksEntityPlaneXOY);
            ksPlaneOffsetDefinition.direction = true;
            ksPlaneOffsetDefinition.offset    = offset;
            ksEntityPlaneOffset.Create();
        }
Exemple #7
0
            protected override ksEntity GetPlane()
            {
                ksEntity xoyPlane = Part.GetDefaultEntity((short)Obj3dType.o3d_planeXOY);
                ksEntity plane    = Part.NewEntity((short)Obj3dType.o3d_planeOffset);
                ksPlaneOffsetDefinition definition = plane.GetDefinition();

                definition.direction = true;
                definition.offset    = 12;
                definition.SetPlane(xoyPlane);
                plane.Create();
                return(plane);
            }
        /// <summary>
        /// Создане выреза крепления
        /// </summary>
        /// <param name="diameterBracing">Диаметр крепления</param>
        /// <param name="lengthBracing">Длина крепления</param>
        /// <param name="lengthLeg">Длина ножки</param>
        /// <param name="lengthHead">Длина головки</param>
        private void BuildBracingCut(double diameterBracing, double lengthBracing, double lengthLeg, double lengthHead)
        {
            #region Константы для выреза крепления
            const int part           = -1;
            const int sketch         = 5;
            const int planeXOY       = 1;
            const int planeOffset    = 14;
            const int rectangleParam = 91;
            const int shaded         = 3;
            const int etBlind        = 0;
            const int cutExtrusion   = 26;
            #endregion

            _part = _doc3D.GetPart(part);
            ksEntity EntityPlane = _part.GetDefaultEntity(planeXOY);

            //Смещение плоскости
            ksEntity PlaneOffSet = _part.NewEntity(planeOffset);
            ksPlaneOffsetDefinition planeOffDefinition = PlaneOffSet.GetDefinition();
            planeOffDefinition.direction = true;
            planeOffDefinition.offset    = lengthLeg + lengthHead + lengthBracing;
            planeOffDefinition.SetPlane(EntityPlane);
            PlaneOffSet.Create();

            //Эскиз
            ksEntity           EntityRectangle           = _part.NewEntity(sketch);
            ksSketchDefinition sketchDefinitionRectangle = EntityRectangle.GetDefinition();
            sketchDefinitionRectangle.SetPlane(PlaneOffSet);
            EntityRectangle.Create();
            ksDocument2D     Document2 = sketchDefinitionRectangle.BeginEdit();
            ksRectangleParam _par;
            _par        = _kompas.GetParamStruct(rectangleParam);
            _par.height = diameterBracing / 2;
            _par.width  = diameterBracing;
            _par.x      = -(diameterBracing / 2);
            _par.y      = -(diameterBracing / 4);
            _par.ang    = 0;
            _par.style  = 1;
            Document2.ksRectangle(_par, 0);
            sketchDefinitionRectangle.EndEdit();

            //Вырезание
            ksEntity EntityCutExtrusion = _part.NewEntity(cutExtrusion);
            ksCutExtrusionDefinition CutExtrusionDefinition = EntityCutExtrusion.GetDefinition();
            CutExtrusionDefinition.cut           = true;
            CutExtrusionDefinition.directionType = 0;
            CutExtrusionDefinition.SetSideParam(true, etBlind, lengthBracing / 2, 0, false);
            CutExtrusionDefinition.SetSketch(EntityRectangle);
            EntityCutExtrusion.Create();
            _doc3D.drawMode        = shaded;
            _doc3D.shadedWireframe = true;
        }
        /// <summary>
        /// Создание сдвинутой плоскости
        /// </summary>
        /// <param name="part">Компонент сборки</param>
        /// <param name="basePlane">Исходная плоскость</param>
        /// <param name="offset">Величина сдвига</param>
        /// <returns>Возвращает сдвинутую плоскость</returns>
        private ksEntity CreateShiftedPlane(ksPart part, ksEntity basePlane,
                                            double offset)
        {
            ksEntity planeFormSurface =
                part.NewEntity((short)Obj3dType.o3d_planeOffset);
            ksPlaneOffsetDefinition planeDefinition =
                planeFormSurface.GetDefinition();

            planeDefinition.SetPlane(basePlane);
            planeDefinition.offset = offset;
            planeFormSurface.Create();
            return(planeFormSurface);
        }
Exemple #10
0
        /// <summary>
        /// Метод смещает базовую плоскость по оси OY на заданное расстояние
        /// </summary>
        public void MovingBasePlaneByYAxis(double offset, bool direction)
        {
            ksEntity plane = (ksEntity)_app.Part.NewEntity((short)Obj3dType.o3d_planeOffset);
            ksPlaneOffsetDefinition planeDef = (ksPlaneOffsetDefinition)plane.GetDefinition();

            if (planeDef != null)
            {
                planeDef.SetPlane(_app.BasePlane);
                planeDef.direction = direction;
                planeDef.offset    = offset;
                plane.Create();
            }
            _app.BasePlane = plane;
        }
Exemple #11
0
        /// <summary>
        ///     Создание плоскости с отступом
        /// </summary>
        /// <param name="windowPart">указатель на деталь</param>
        /// <param name="planeXoy">координаты плоскости</param>
        /// <param name="weigthNotch">Толщина выреза</param>
        /// <returns>возвращение отступа плоскости</returns>
        private static ksEntity CreateOffsetPlane(ksPart windowPart,
                                                  ksEntity planeXoy, double weigthNotch)
        {
            ksEntity planeOffsetSection =
                windowPart.NewEntity((short)Obj3dType
                                     .o3d_planeOffset);
            ksPlaneOffsetDefinition
                planeOffsetDefinition =
                planeOffsetSection.GetDefinition();

            planeOffsetDefinition.SetPlane(planeXoy);
            planeOffsetDefinition.offset =
                weigthNotch;
            planeOffsetSection.Create();
            return(planeOffsetSection);
        }
        /// <summary>
        /// Создание отверстия крепления
        /// </summary>
        /// <param name="diameterBracing">Диаметр крепления</param>
        /// <param name="lengthBracing">Длина крепления</param>
        /// <param name="lengthLeg">Длина ножки</param>
        /// <param name="lengthHead">Длина головки</param>
        private void BuildBracingHole(double diameterBracing, double lengthBracing, double lengthLeg, double lengthHead)
        {
            #region Константы отверстия крепления
            const int part         = -1;
            const int sketch       = 5;
            const int planeXOY     = 1;
            const int planeOffset  = 14;
            const int shaded       = 3;
            const int etBlind      = 0;
            const int planeXOZ     = 2;
            const int cutExtrusion = 26;
            #endregion

            ksEntity EntityPlane = _part.GetDefaultEntity(planeXOY);
            _part = _doc3D.GetPart(part);
            ksEntity EntityPlane3 = _part.GetDefaultEntity(planeXOZ);

            //Смещение плоскости
            ksEntity PlaneOffHole = _part.NewEntity(planeOffset);
            ksPlaneOffsetDefinition planeOffsetDefinitionHole = PlaneOffHole.GetDefinition();
            planeOffsetDefinitionHole.direction = true;
            planeOffsetDefinitionHole.offset    = diameterBracing / 2;
            planeOffsetDefinitionHole.SetPlane(EntityPlane3);
            PlaneOffHole.Create();

            //Эскиз отверстия крепения
            ksEntity           EntityHole           = _part.NewEntity(sketch);
            ksSketchDefinition sketchDefinitionHole = EntityHole.GetDefinition();
            sketchDefinitionHole.SetPlane(PlaneOffHole);
            EntityHole.Create();
            ksDocument2D DocumentHole = sketchDefinitionHole.BeginEdit();
            DocumentHole.ksCircle(0, -(0.75 * lengthBracing + lengthLeg + lengthHead), diameterBracing / 6, 1);
            sketchDefinitionHole.EndEdit();

            //Выдавливание отверстия крепления
            ksEntity EntityCutExtrusionHole = _part.NewEntity(cutExtrusion);
            ksCutExtrusionDefinition CutExtrusionDefinitionHole = EntityCutExtrusionHole.GetDefinition();
            CutExtrusionDefinitionHole.cut           = true;
            CutExtrusionDefinitionHole.directionType = 0;
            CutExtrusionDefinitionHole.SetSideParam(true, etBlind, diameterBracing, 0, false);
            CutExtrusionDefinitionHole.SetSketch(EntityHole);
            EntityCutExtrusionHole.Create();
            _doc3D.drawMode        = shaded;
            _doc3D.shadedWireframe = true;
        }
        /// <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);
        }
        /// <summary>
        /// Создание крепления
        /// </summary>
        /// <param name="diameterBracing">Диаметр крепления</param>
        /// <param name="lengthBracing">Длина крепления</param>
        /// <param name="lengthLeg">Длина ножки</param>
        /// <param name="lengthHead">Длина головки</param>
        private void BuildBracing(double diameterBracing, double lengthBracing, double lengthLeg, double lengthHead)
        {
            #region Константы для крепления
            const int part          = -1;
            const int sketch        = 5;
            const int planeXOY      = 1;
            const int planeOffset   = 14;
            const int baseExtrusion = 24;
            const int shaded        = 3;
            const int etBlind       = 0;
            #endregion

            _part = _doc3D.GetPart(part);
            ksEntity EntityPlane = _part.GetDefaultEntity(planeXOY);

            ///Смещение плоскости
            ksEntity PlaneOff = _part.NewEntity(planeOffset);
            ksPlaneOffsetDefinition planeOffsetDefinition = PlaneOff.GetDefinition();
            planeOffsetDefinition.direction = true;
            planeOffsetDefinition.offset    = lengthLeg + lengthHead;
            planeOffsetDefinition.SetPlane(EntityPlane);
            PlaneOff.Create();

            //Эскиз крепления
            ksEntity           Entity           = _part.NewEntity(sketch);
            ksSketchDefinition sketchDefinition = Entity.GetDefinition();
            sketchDefinition.SetPlane(PlaneOff);
            Entity.Create();
            ksDocument2D Document2D = sketchDefinition.BeginEdit();
            Document2D.ksCircle(0, 0, diameterBracing / 2, 1);
            sketchDefinition.EndEdit();

            //Выдавливание крепления
            ksEntity EntityExtrusion = _part.NewEntity(baseExtrusion);
            ksBaseExtrusionDefinition BaseExtrusionDefinition = EntityExtrusion.GetDefinition();
            BaseExtrusionDefinition.SetSideParam(true, etBlind, lengthBracing, 0, true);
            BaseExtrusionDefinition.SetSketch(Entity);
            EntityExtrusion.Create();
            _doc3D.drawMode        = shaded;
            _doc3D.shadedWireframe = true;
        }
Exemple #15
0
        ///<summary>
        /// Создание отверстий в верхнем  ободе
        ///</summary>
        private void CreateHolesInRim2(double kadloHeight, double thicknessTopDrumhead, double rimCenter, int numberMounting)
        {
            if (_part != null)
            {
                // интерфейс свойств эскиза
                ksEntity rimHoles = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_sketch);
                if (rimHoles != null)
                {
                    // Получение интерфейса свойств эскиза
                    ksSketchDefinition rimSketch1 = (ksSketchDefinition)rimHoles.GetDefinition();
                    if (rimSketch1 != null)
                    {
                        ksEntity basePlane;
                        // Получение интерфейса базовой плоскости XOY
                        basePlane = (ksEntity)_part.GetDefaultEntity((short)Obj3dType.o3d_planeXOY);
                        ksEntity entityOffsetPlane = _part.NewEntity((short)Obj3dType.o3d_planeOffset);

                        ksPlaneOffsetDefinition offsetDef1 = (ksPlaneOffsetDefinition)entityOffsetPlane.GetDefinition();
                        // Расстояние смещения
                        offsetDef1.offset    = kadloHeight + thicknessTopDrumhead + 0.1;
                        offsetDef1.direction = true;
                        offsetDef1.SetPlane(basePlane);
                        // создаем смещенную плоскость
                        entityOffsetPlane.Create();
                        // установим плоскость базовой для эскиза
                        rimSketch1.SetPlane(offsetDef1);
                        // создадим эскиз
                        rimHoles.Create();
                        // интерфейс редактора эскиза
                        ksDocument2D sketchEdit = (ksDocument2D)rimSketch1.BeginEdit();
                        if (sketchEdit != null)
                        {
                            int i = 1;
                            for (double phi = 0; phi < 2 * Math.PI; phi += 2 * Math.PI / numberMounting)
                            {
                                double x = rimCenter * Math.Cos(phi);
                                double y = rimCenter * Math.Sin(phi);
                                //круглое отверстие
                                sketchEdit.ksCircle(x, y, 2.5, 1);
                                if (i < numberMounting)
                                {
                                    i++;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            // завершение редактирования эскиза
                            rimSketch1.EndEdit();
                            // вырежим выдавливанием
                            ksEntity entityCutExtr = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_cutExtrusion);
                            if (entityCutExtr != null)
                            {
                                ksCutExtrusionDefinition cutExtrDef = (ksCutExtrusionDefinition)entityCutExtr.GetDefinition();
                                if (cutExtrDef != null)
                                {
                                    cutExtrDef.cut           = true;
                                    cutExtrDef.directionType = (short)Direction_Type.dtReverse;
                                    cutExtrDef.SetSideParam(false, (short)End_Type.etThroughAll);
                                    cutExtrDef.SetSketch(rimSketch1);
                                    entityCutExtr.Create();
                                }
                            }
                        }
                    }
                }
            }
        }
        /// <summary>
        /// CСоздание резьбы на ножке
        /// </summary>
        /// <param name="diameterLeg">Диаметр ножки</param>
        /// <param name="lengthLeg">Длина ножки</param>
        /// <param name="diameterBracing">Диаметр крепления</param>
        /// <param name="lengthHead">Длина головки</param>
        private void BuildThreadLeg(double diameterLeg, double lengthLeg, double diameterBracing, double lengthHead)
        {
            #region Константы для резьбы
            const int part            = -1;
            const int planeOffset     = 14;
            const int sketch          = 5;
            const int planeXOY        = 1;
            const int cylindricspiral = 56;
            const int cutEvolution    = 47;
            const int planeXOZ        = 2;
            #endregion

            //Смещенеие плоскости
            _part = _doc3D.GetPart(part);
            ksEntity entityOffset = _part.NewEntity(planeOffset);
            ksPlaneOffsetDefinition planeDefinition = entityOffset.GetDefinition();
            planeDefinition.offset    = lengthHead;
            planeDefinition.direction = true;
            ksEntity EntityPlaneOffset = _part.GetDefaultEntity(planeXOY);
            planeDefinition.SetPlane(EntityPlaneOffset);
            entityOffset.Create();

            //Построение спирали
            ksEntity entityCylinderic = _part.NewEntity(cylindricspiral);
            ksCylindricSpiralDefinition cylindricSpiral = entityCylinderic.GetDefinition();
            cylindricSpiral.SetPlane(entityOffset);
            cylindricSpiral.buildDir   = true;
            cylindricSpiral.buildMode  = 1;
            cylindricSpiral.height     = lengthLeg;
            cylindricSpiral.diam       = diameterLeg;
            cylindricSpiral.firstAngle = 0;
            cylindricSpiral.turnDir    = true;
            cylindricSpiral.step       = 0.5;
            entityCylinderic.Create();

            //Эскиз треуголника
            ksEntity           Entity2          = _part.NewEntity(sketch);
            ksSketchDefinition sketchDefinition = Entity2.GetDefinition();
            ksEntity           Entity           = _part.GetDefaultEntity(planeXOZ);
            sketchDefinition.SetPlane(Entity);
            Entity2.Create();

            Document2D document2D = sketchDefinition.BeginEdit();
            var        StartX     = diameterLeg / 2 - (diameterLeg / 100); //
            var        StartY     = -0.5 / 2 + 0.01;
            document2D.ksLineSeg(StartX, -lengthHead, diameterLeg - StartX, -lengthHead + StartY, 1);
            document2D.ksLineSeg(StartX, -lengthHead, diameterLeg - StartX, -lengthHead - StartY, 1);
            document2D.ksLineSeg(diameterLeg - StartX, -lengthHead + StartY, diameterLeg - StartX, -lengthHead - StartY, 1);
            sketchDefinition.EndEdit();

            //Кинематическое вырезание
            ksEntity entityCutEvolution = _part.NewEntity(cutEvolution);
            ksCutEvolutionDefinition cutEvolutionDefinition = entityCutEvolution.GetDefinition();
            cutEvolutionDefinition.cut             = true;
            cutEvolutionDefinition.sketchShiftType = 1;
            cutEvolutionDefinition.SetSketch(sketchDefinition);
            ksEntityCollection EntityCollection = (cutEvolutionDefinition.PathPartArray());
            EntityCollection.Clear();
            EntityCollection.Add(entityCylinderic);
            entityCutEvolution.Create();
        }
Exemple #17
0
        ///<summary>
        /// Процедура построениея верхнего и нижнего пластиков
        ///</summary>
        private void CreateDrumhead(double kadloHeight, double kadloRadius, double thicknessTopDrumhead, double thicknessBottomDrumhead)
        {
            // Создание плоскости для верхнего пластика
            #region
            ksSketchDefinition definitionSketch = null;
            // Проверка на существование компонента сборки
            if (_part != null)
            {
                // создадим новый эскиз
                var DrumheadSketch = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_sketch);
                if (DrumheadSketch != null)
                {
                    // Получение интерфейса свойств эскиза
                    definitionSketch = (ksSketchDefinition)DrumheadSketch.GetDefinition();
                    if (definitionSketch != null)
                    {
                        // Получение интерфейса базовой плоскости XOY
                        var basePlane = (ksEntity)_part.GetDefaultEntity((short)Obj3dType.o3d_planeXOY);
                        // создаем эскиз для смещенной плоскости
                        ksEntity entityOffsetPlane = _part.NewEntity((short)Obj3dType.o3d_planeOffset);
                        // получение интерфейса свойств эскиза для смещенной плоскости
                        ksPlaneOffsetDefinition offsetDef = (ksPlaneOffsetDefinition)entityOffsetPlane.GetDefinition();
                        // расстояние смещение
                        offsetDef.offset = kadloHeight;
                        // направление смещения
                        offsetDef.direction = true;
                        // назначение плоскости переноса
                        offsetDef.SetPlane(basePlane);
                        // создание смещенной плоскости
                        entityOffsetPlane.Create();

                        ksEntity _sketch    = _part.NewEntity((short)Obj3dType.o3d_sketch);
                        var      sketchDef2 = (ksSketchDefinition)_sketch.GetDefinition();
                        sketchDef2.SetPlane(entityOffsetPlane);
                        _sketch.Create();

                        ksDocument2D sketchEdit2 = (ksDocument2D)sketchDef2.BeginEdit(); //начало редактирования эскиза
                        sketchEdit2.ksCircle(0, 0, kadloRadius, 1);                      //рисуем окружность для пластика
                        sketchDef2.EndEdit();                                            // завершение редактирования
                        #endregion
                        // Выдавливание верхнего пластика
                        #region
                        ksEntity entityBossExtr1 = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_bossExtrusion);
                        if (entityBossExtr1 != null)
                        {
                            ksBossExtrusionDefinition bossExtrDef = (ksBossExtrusionDefinition)entityBossExtr1.GetDefinition();
                            if (bossExtrDef != null)
                            {
                                // интерфейс структуры параметров выдавливания
                                ksExtrusionParam extrProp = (ksExtrusionParam)bossExtrDef.ExtrusionParam();
                                // интерфейс структуры параметров тонкой стенки
                                ksThinParam thinProp = (ksThinParam)bossExtrDef.ThinParam();
                                if (extrProp != null)
                                {
                                    // эскиз операции выдавливания
                                    bossExtrDef.SetSketch(_sketch);
                                    // направление выдавливания (прямое)
                                    extrProp.direction = (short)Direction_Type.dtNormal;
                                    // тип выдавливания (строго на глубину)
                                    extrProp.typeNormal = (short)End_Type.etBlind;
                                    // глубина выдавливания
                                    extrProp.depthNormal = thicknessTopDrumhead;
                                    // создадим операцию
                                    entityBossExtr1.Create();
                                }
                            }
                        }
                    }
                    #endregion
                    // Создание плоскости для нижнего пластика
                    #region
                    // получим интерфейс базовой плоскости XOY
                    ksEntity planeXOY = (ksEntity)_part.GetDefaultEntity((short)Obj3dType.o3d_planeXOY);
                    ksEntity iSketch  = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_sketch);
                    if (iSketch != null)
                    {
                        ksEntity entitySketch1 = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_sketch);
                        if (entitySketch1 != null)
                        {
                            // интерфейс свойств эскиза
                            ksSketchDefinition sketchDef1 = (ksSketchDefinition)entitySketch1.GetDefinition();
                            if (sketchDef1 != null)
                            {
                                // установим плоскость
                                sketchDef1.SetPlane(planeXOY);
                                // создадим эскиз
                                entitySketch1.Create();

                                // интерфейс редактора эскиза
                                ksDocument2D sketchEdit1 = (ksDocument2D)sketchDef1.BeginEdit();
                                sketchEdit1.ksCircle(0, 0, kadloRadius, 1);
                                // завершение редактирования эскиза
                                sketchDef1.EndEdit();
                                #endregion

                                // Выдавливание нижнего пластика
                                #region
                                ksEntity entityBossExtr2 = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_bossExtrusion);
                                if (entityBossExtr2 != null)
                                {
                                    ksBossExtrusionDefinition bossExtrDef1 = (ksBossExtrusionDefinition)entityBossExtr2.GetDefinition();
                                    if (bossExtrDef1 != null)
                                    {
                                        // интерфейс структуры параметров выдавливания
                                        ksExtrusionParam extrProp1 = (ksExtrusionParam)bossExtrDef1.ExtrusionParam();
                                        // интерфейс структуры параметров тонкой стенки
                                        ksThinParam thinProp1 = (ksThinParam)bossExtrDef1.ThinParam();
                                        if (extrProp1 != null)
                                        {
                                            // эскиз операции выдавливания
                                            bossExtrDef1.SetSketch(entitySketch1);
                                            // направление выдавливания (обратное)
                                            extrProp1.direction = (short)Direction_Type.dtReverse;
                                            // тип выдавливания (строго на глубину)
                                            extrProp1.typeReverse = (short)End_Type.etBlind;
                                            // глубина выдавливания
                                            extrProp1.depthReverse = thicknessBottomDrumhead;
                                            // создадим операцию
                                            entityBossExtr2.Create();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #18
0
        ///<summary>
        ///Создание подструнника
        ///</summary>
        private void CreateSnare(bool ExistSnare, int stringSnare, double kadloRadius, double thicknessBottomDrumhead)
        {
            // Проверка на существование компонента сборки
            if (_part != null)
            {
                // создадим новый эскиз
                var SnareSketch = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_sketch);
                if (SnareSketch != null)
                {
                    // Получение интерфейса свойств эскиза
                    var definitionSnare = (ksSketchDefinition)SnareSketch.GetDefinition();
                    if (definitionSnare != null)
                    {
                        // Получение интерфейса базовой плоскости XOY
                        var      basePlane                = (ksEntity)_part.GetDefaultEntity((short)Obj3dType.o3d_planeXOY);
                        ksEntity entityOffsetPlane        = _part.NewEntity((short)Obj3dType.o3d_planeOffset);
                        ksPlaneOffsetDefinition offsetDef = (ksPlaneOffsetDefinition)entityOffsetPlane.GetDefinition();
                        offsetDef.offset    = thicknessBottomDrumhead;
                        offsetDef.direction = false;
                        offsetDef.SetPlane(basePlane);
                        // создаем смещенную плоскость
                        entityOffsetPlane.Create();
                        ksEntity snare    = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_sketch);
                        var      defSnare = (ksSketchDefinition)snare.GetDefinition();
                        defSnare.SetPlane(offsetDef);
                        snare.Create();
                        ksDocument2D SnareEdit = (ksDocument2D)defSnare.BeginEdit();
                        // Рисуем основание подструнника
                        SnareEdit.ksLineSeg(-15, kadloRadius - 5, 15, kadloRadius - 5, 1);
                        SnareEdit.ksLineSeg(15, kadloRadius - 5, 15, kadloRadius - 10, 1);
                        SnareEdit.ksLineSeg(15, kadloRadius - 10, -15, kadloRadius - 10, 1);
                        SnareEdit.ksLineSeg(-15, kadloRadius - 10, -15, kadloRadius - 5, 1);

                        SnareEdit.ksLineSeg(-15, -kadloRadius + 5, 15, -kadloRadius + 5, 1);
                        SnareEdit.ksLineSeg(15, -kadloRadius + 5, 15, -kadloRadius + 10, 1);
                        SnareEdit.ksLineSeg(15, -kadloRadius + 10, -15, -kadloRadius + 10, 1);
                        SnareEdit.ksLineSeg(-15, -kadloRadius + 10, -15, -kadloRadius + 5, 1);

                        defSnare.EndEdit();

                        // Выдавливание подструнника
                        ksEntity entityBossExtr3 = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_bossExtrusion);
                        if (entityBossExtr3 != null)
                        {
                            ksBossExtrusionDefinition bossExtrDef3 = (ksBossExtrusionDefinition)entityBossExtr3.GetDefinition();
                            if (bossExtrDef3 != null)
                            {
                                // интерфейс структуры параметров выдавливания
                                ksExtrusionParam extrProp3 = (ksExtrusionParam)bossExtrDef3.ExtrusionParam();
                                if (extrProp3 != null)
                                {
                                    // эскиз операции выдавливания
                                    bossExtrDef3.SetSketch(snare);
                                    // направление выдавливания (обратное)
                                    extrProp3.direction = (short)Direction_Type.dtReverse;
                                    // тип выдавливания (строго на глубину)
                                    extrProp3.typeReverse = (short)End_Type.etBlind;
                                    // глубина выдавливания
                                    extrProp3.depthReverse = 4;
                                    // создадим операцию
                                    entityBossExtr3.Create();
                                }
                            }
                        }
                        // Создание струн подструнника
                        var StringSketch = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_sketch);
                        if (StringSketch != null)
                        {
                            // Получение интерфейса свойств эскиза
                            var definitionString = (ksSketchDefinition)StringSketch.GetDefinition();
                            if (definitionString != null)
                            {
                                // Получение интерфейса базовой плоскости XOZ
                                var      stringPlane    = (ksEntity)_part.GetDefaultEntity((short)Obj3dType.o3d_planeXOZ);
                                ksEntity stSnare        = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_sketch);
                                var      defStringSnare = (ksSketchDefinition)stSnare.GetDefinition();
                                defStringSnare.SetPlane(stringPlane);
                                stSnare.Create();
                                ksDocument2D stringSnareEdit = (ksDocument2D)defStringSnare.BeginEdit();
                                // В ряд рисуются круги (сечение струн)
                                int k = 1;
                                for (double x = -11; x < 12; x += 3)
                                {
                                    stringSnareEdit.ksCircle(x, thicknessBottomDrumhead + 2, 1, 1);
                                    if (k < stringSnare)
                                    {
                                        k++;
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                defStringSnare.EndEdit();

                                // Выдавливание струн подструнника
                                ksEntity entityBossExtr4 = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_bossExtrusion);
                                if (entityBossExtr4 != null)
                                {
                                    ksBossExtrusionDefinition bossExtrDef3 = (ksBossExtrusionDefinition)entityBossExtr4.GetDefinition();
                                    if (bossExtrDef3 != null)
                                    {
                                        // интерфейс структуры параметров выдавливания
                                        ksExtrusionParam extrProp3 = (ksExtrusionParam)bossExtrDef3.ExtrusionParam();
                                        if (extrProp3 != null)
                                        {
                                            // эскиз операции выдавливания
                                            bossExtrDef3.SetSketch(stSnare);
                                            // направление выдавливания (обе стороны)
                                            extrProp3.direction = (short)Direction_Type.dtBoth;
                                            // тип выдавливания (до ближайшей поверхности)
                                            extrProp3.typeReverse = (short)End_Type.etUpToNearSurface;
                                            extrProp3.typeNormal  = (short)End_Type.etUpToNearSurface;
                                            // создадим операцию
                                            entityBossExtr4.Create();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #19
0
        ///<summary>
        /// Создание ободов
        ///</summary>
        private void CreateRim(double kadloHeight, double thicknessTopDrumhead, double thicknessBottomDrumhead, double rimRadius, double rimWidth, double rimHeight)
        {
            #region Создание смещенной плоскости для верхнего обода

            ksSketchDefinition rimSketch = null;
            // Проверка на существование компонента сборки
            if (_part != null)
            {
                // создадим новый эскиз
                var RimSketch = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_sketch);
                if (RimSketch != null)
                {
                    // Получение интерфейса свойств эскиза
                    rimSketch = (ksSketchDefinition)RimSketch.GetDefinition();
                    if (rimSketch != null)
                    {
                        // Получение интерфейса базовой плоскости XOY
                        var      basePlane1                = (ksEntity)_part.GetDefaultEntity((short)Obj3dType.o3d_planeXOY);
                        ksEntity entityOffsetPlane1        = _part.NewEntity((short)Obj3dType.o3d_planeOffset);
                        ksPlaneOffsetDefinition offsetDef1 = (ksPlaneOffsetDefinition)entityOffsetPlane1.GetDefinition();
                        // Высота кадла + толщина пластика+0.1
                        offsetDef1.offset = kadloHeight + thicknessTopDrumhead + 0.1;
                        // Направление смещения
                        offsetDef1.direction = true;
                        offsetDef1.SetPlane(basePlane1);
                        // Создаем смещенную плоскость
                        entityOffsetPlane1.Create();

                        ksEntity _rimSketch = _part.NewEntity((short)Obj3dType.o3d_sketch);

                        var sketchDef3 = (ksSketchDefinition)_rimSketch.GetDefinition();
                        sketchDef3.SetPlane(entityOffsetPlane1);
                        _rimSketch.Create();

                        ksDocument2D sketchEdit3 = (ksDocument2D)sketchDef3.BeginEdit();
                        //рисуем окружность
                        sketchEdit3.ksCircle(0, 0, rimRadius, 1);
                        sketchDef3.EndEdit();

                        #endregion // Создание смещенной плоскости для верхнего обода

                        #region  Выдавливание верхнего обода
                        ksEntity entityBossExtr3 = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_bossExtrusion);
                        if (entityBossExtr3 != null)
                        {
                            ksBossExtrusionDefinition bossExtrDef3 = (ksBossExtrusionDefinition)entityBossExtr3.GetDefinition();
                            if (bossExtrDef3 != null)
                            {
                                // интерфейс структуры параметров выдавливания
                                ksExtrusionParam extrProp3 = (ksExtrusionParam)bossExtrDef3.ExtrusionParam();
                                // интерфейс структуры параметров тонкой стенки
                                ksThinParam thinProp3 = (ksThinParam)bossExtrDef3.ThinParam();
                                if (extrProp3 != null && thinProp3 != null)
                                {
                                    // эскиз операции выдавливания
                                    bossExtrDef3.SetSketch(_rimSketch);
                                    // направление выдавливания (прямое)
                                    extrProp3.direction = (short)Direction_Type.dtNormal;
                                    // тип выдавливания (строго на глубину)
                                    extrProp3.typeNormal = (short)End_Type.etBlind;
                                    // глубина выдавливания  ВЫСОТА ОБОДА
                                    extrProp3.depthNormal = rimHeight;
                                    thinProp3.thin        = true;
                                    // Толщина стенки в обратном направлении
                                    thinProp3.reverseThickness = rimWidth;
                                    // Направление формирования тонкой стенки
                                    thinProp3.thinType = (short)Direction_Type.dtBoth;
                                    // создадим операцию
                                    entityBossExtr3.Create();
                                }
                            }
                        }
                    }
                    #endregion Выдавливание верхнего обода

                    #region Создание плоскости для нижнего обода
                    ksEntity           entityBossExtr4 = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_bossExtrusion);
                    ksSketchDefinition rimSketch2      = null;
                    if (entityBossExtr4 != null)
                    {
                        // создадим новый эскиз
                        var RimSketch2 = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_sketch);
                        if (RimSketch2 != null)
                        {
                            // Получение интерфейса свойств эскиза
                            rimSketch2 = (ksSketchDefinition)RimSketch2.GetDefinition();

                            if (rimSketch2 != null)
                            {
                                // Получение интерфейса базовой плоскости XOY
                                var      basePlane2                = (ksEntity)_part.GetDefaultEntity((short)Obj3dType.o3d_planeXOY);
                                ksEntity entityOffsetPlane2        = _part.NewEntity((short)Obj3dType.o3d_planeOffset);
                                ksPlaneOffsetDefinition offsetDef1 = (ksPlaneOffsetDefinition)entityOffsetPlane2.GetDefinition();
                                // толщина пластика + 0.1
                                offsetDef1.offset    = thicknessBottomDrumhead + 0.1;
                                offsetDef1.direction = false;
                                offsetDef1.SetPlane(basePlane2);
                                // создаем смещенную плоскость
                                entityOffsetPlane2.Create();

                                ksEntity _rimSketch2 = _part.NewEntity((short)Obj3dType.o3d_sketch);
                                var      sketchDef4  = (ksSketchDefinition)_rimSketch2.GetDefinition();
                                sketchDef4.SetPlane(entityOffsetPlane2);
                                _rimSketch2.Create();

                                ksDocument2D sketchEdit4 = (ksDocument2D)sketchDef4.BeginEdit();
                                //рисуем окружность
                                sketchEdit4.ksCircle(0, 0, rimRadius, 1);
                                sketchDef4.EndEdit();
                                #endregion Создание плоскости для нижнего обода

                                #region Выдавливание нижнего обода
                                ksEntity entityBossExtr5 = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_bossExtrusion);
                                if (entityBossExtr4 != null)
                                {
                                    ksBossExtrusionDefinition bossExtrDef4 = (ksBossExtrusionDefinition)entityBossExtr4.GetDefinition();
                                    if (bossExtrDef4 != null)
                                    {
                                        // интерфейс структуры параметров выдавливания
                                        ksExtrusionParam extrProp4 = (ksExtrusionParam)bossExtrDef4.ExtrusionParam();
                                        // интерфейс структуры параметров тонкой стенки
                                        ksThinParam thinProp4 = (ksThinParam)bossExtrDef4.ThinParam();
                                        if (extrProp4 != null && thinProp4 != null)
                                        {
                                            // эскиз операции выдавливания
                                            bossExtrDef4.SetSketch(_rimSketch2);
                                            // направление выдавливания (обратное)
                                            extrProp4.direction = (short)Direction_Type.dtReverse;
                                            // тип выдавливания (строго на глубину)
                                            extrProp4.typeReverse = (short)End_Type.etBlind;
                                            // глубина выдавливания  ВЫСОТА ОБОДА
                                            extrProp4.depthReverse = rimHeight;
                                            thinProp4.thin         = true;
                                            // Толщина стенки в обратном направлении
                                            thinProp4.reverseThickness = rimWidth;
                                            // Направление формирования тонкой стенки
                                            thinProp4.thinType = (short)Direction_Type.dtBoth;
                                            // создадим операцию
                                            entityBossExtr4.Create();
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #20
0
        /// <summary>
        /// Создание модели шестерни
        /// </summary>
        /// <param name="properties">Передаваемые с формы параметры</param>
        public void CreateModel(Gear properties)
        {
            int teethCount    = properties.TeethCount;
            var angle         = properties.Angle;
            var thickness     = properties.Thickness;
            var shaftDiam     = properties.ShaftDiam;
            var diameterOut   = properties.DiameterOut;
            var diameterIn    = properties.DiameterIn;
            var diameterPitch = (diameterOut + diameterIn) / 2; // делительный диаметр колеса
            var alfa1         = 0.0;
            var alfa2         = 0.0;
            // интерфейсы ортогональных плоскостей
            ksPart iPart = _doc3.GetPart((int)Part_Type.pNew_Part) as ksPart;  //новый компонет

            if (iPart != null)
            {
                // интерфейсы ортогональных плоскостей
                ksEntity planeXoy = iPart.GetDefaultEntity((short)Obj3dType.o3d_planeXOY) as ksEntity;
                ksEntity planeXoz = iPart.GetDefaultEntity((short)Obj3dType.o3d_planeXOZ) as ksEntity;
                ksEntity planeYoz = iPart.GetDefaultEntity((short)Obj3dType.o3d_planeYOZ) as ksEntity;
                // интерфейс эскиза (половина контура сечения колеса)
                ksEntity iSketchEntity = iPart.NewEntity((short)Obj3dType.o3d_sketch) as ksEntity;
                if (iSketchEntity != null)
                {
                    // интерфейс параметров эскиза
                    ksSketchDefinition iSketchDef = iSketchEntity.GetDefinition() as ksSketchDefinition;
                    if (iSketchDef != null)
                    {
                        if (planeXoy != null)
                        {
                            // устанавливаем плоскость,
                            // на которой создается эскиз
                            iSketchDef.SetPlane(planeXoy);

                            iSketchEntity.Create();

                            // запускаем процесс редактирования эскиза
                            // doc – указатель на интерфейс ksDocument2D
                            _doc = iSketchDef.BeginEdit() as ksDocument2D;
                            if (_doc != null)
                            {
                                _doc.ksLineSeg(-thickness / 2, 00, thickness / 2, 0, 3); //3 - осевая линия
                                _doc.ksLineSeg(thickness / 2, shaftDiam / 2, -thickness / 2, shaftDiam / 2, 1);
                                _doc.ksLineSeg(thickness / 2, shaftDiam / 2, thickness / 2, diameterOut / 2, 1);
                                _doc.ksLineSeg(-thickness / 2, diameterOut / 2, -thickness / 2, shaftDiam / 2, 1);
                                _doc.ksLineSeg(-thickness / 2, diameterOut / 2, thickness / 2, diameterOut / 2, 1);
                            }
                            iSketchDef.EndEdit();
                        }
                    }
                }
                // интерфейс базовой операции вращения
                ksEntity iBaseRotatedEntity = iPart.NewEntity((short)Obj3dType.o3d_baseRotated) as ksEntity;
                if (iBaseRotatedEntity != null)
                {
                    // интерфейс параметров вращения
                    ksBaseRotatedDefinition iBaseRotatedDef =
                        iBaseRotatedEntity.GetDefinition() as ksBaseRotatedDefinition;
                    if (iBaseRotatedDef != null)
                    {
                        // настройка параметров вращения
                        iBaseRotatedDef.SetThinParam(false, (short)Direction_Type.dtNormal, 1, 1);
                        iBaseRotatedDef.SetSideParam(true, 360.0);
                        iBaseRotatedDef.toroidShapeType = false;
                        iBaseRotatedDef.SetSketch(iSketchEntity);
                        // создаем операцию вращения
                        // результат – заготовка зубчатого колеса
                        iBaseRotatedEntity.Create();
                    }
                }
                ksEntity iSketch1Entity = iPart.NewEntity((short)Obj3dType.o3d_sketch) as ksEntity;
                if (iSketch1Entity != null)
                {
                    ksSketchDefinition iSketch1Def = iSketch1Entity.GetDefinition() as ksSketchDefinition;
                    if (iSketch1Def != null)
                    {
                        if (planeYoz != null)
                        {
                            // размещаем эскиз на плоскости XOY
                            iSketch1Def.SetPlane(planeXoy);
                            iSketch1Entity.Create();
                            _doc = iSketch1Def.BeginEdit() as ksDocument2D;
                            if (_doc != null)
                            {
                                var width = properties.KeywayWidth;
                                _doc.ksLineSeg(thickness / 2, -width / 2, -thickness / 2, -width / 2, 1);
                                _doc.ksLineSeg(-thickness / 2, width / 2, -thickness / 2, -width / 2, 1);
                                _doc.ksLineSeg(-thickness / 2, width / 2, thickness / 2, width / 2, 1);
                                _doc.ksLineSeg(thickness / 2, width / 2, thickness / 2, -width / 2, 1);
                            }
                            iSketch1Def.EndEdit();
                        }
                    }
                }
                // интерфейс операции Вырезать выдавливанием
                ksEntity iCutExtrusion = iPart.NewEntity((short)Obj3dType.o3d_cutExtrusion) as ksEntity;
                if (iCutExtrusion != null)
                {
                    // интерфейс параметров вырезания
                    ksCutExtrusionDefinition iCutExtrusionDef =
                        iCutExtrusion.GetDefinition() as ksCutExtrusionDefinition;
                    if (iCutExtrusionDef != null)
                    {
                        // настройка параметров
                        iCutExtrusionDef.SetSketch(iSketch1Entity);
                        // направление
                        iCutExtrusionDef.directionType = (short)Direction_Type.dtNormal;
                        // величина вырезания по каждому из направлений
                        iCutExtrusionDef.SetSideParam(true, (short)ksEndTypeEnum.etBlind,
                                                      properties.KeywayDepth + shaftDiam / 2, 0, false);
                        iCutExtrusionDef.SetThinParam(false, 0, 0, 0);
                        iCutExtrusion.Create();
                    }
                }
                // интерфейс смещенной плоскости
                ksEntity iOffsetPlaneEntity = iPart.NewEntity((short)Obj3dType.o3d_planeOffset) as ksEntity;
                if (iOffsetPlaneEntity != null)
                {
                    // интерфейс параметров смещенной плоскости
                    ksPlaneOffsetDefinition iOffsetPlaneDef =
                        iOffsetPlaneEntity.GetDefinition() as ksPlaneOffsetDefinition;
                    if (iOffsetPlaneDef != null)
                    {
                        // величина, базовая плоскость и другие параметры смещения
                        iOffsetPlaneDef.offset = thickness / 2;
                        iOffsetPlaneDef.SetPlane(planeYoz);
                        iOffsetPlaneDef.direction = false;
                        // делаем плоскость скрытой
                        iOffsetPlaneEntity.hidden = true;
                        // создаем вспомогательную плоскость
                        iOffsetPlaneEntity.Create();
                    }
                }
                // эскиз первого выреза между зубьями
                ksEntity iSketch2Entity = iPart.NewEntity((short)Obj3dType.o3d_sketch) as ksEntity;
                if (iSketch2Entity != null)
                {
                    ksSketchDefinition iSketch2Def = iSketch2Entity.GetDefinition() as ksSketchDefinition;
                    if (iSketch2Def != null)
                    {
                        // базовая плоскость – вспомогательная iOffsetPlaneEntity
                        iSketch2Def.SetPlane(iOffsetPlaneEntity);
                        iSketch2Entity.Create();
                        _doc  = iSketch2Def.BeginEdit() as ksDocument2D;
                        alfa1 = 360.0 / teethCount;
                        _doc.ksMtr(0, 0, 90, 1, 1);
                        // вычерчивание изображения эскиза
                        // вместо эвольвент для простоты
                        // берем обычные дуги по трем точкам
                        _doc.ksArcBy3Points(-(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(0)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(0)),
                                            -diameterPitch / 2 * Math.Sin(DegToRad(alfa1 / 8)),
                                            -diameterPitch / 2 * Math.Cos(DegToRad(alfa1 / 8)),
                                            -diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 4)),
                                            -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 4)), 1);
                        _doc.ksArcByPoint(0, 0, diameterIn / 2, -diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 4)),
                                          -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 4)),
                                          -diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 2)),
                                          -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 2)), -1, 1);
                        _doc.ksArcBy3Points(-diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 2)),
                                            -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 2)),
                                            -diameterPitch / 2 * Math.Sin(DegToRad(0.625 * alfa1)),
                                            -diameterPitch / 2 * Math.Cos(DegToRad(0.625 * alfa1)),
                                            -(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(0.75 * alfa1)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(0.75 * alfa1)), 1);
                        _doc.ksArcBy3Points(-(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(0.75 * alfa1)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(0.75 * alfa1)),
                                            -(diameterOut / 2 + 2) * Math.Sin(DegToRad(0.375 * alfa1)),
                                            -(diameterOut / 2 + 2) * Math.Cos(DegToRad(0.375 * alfa1)),
                                            -(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(0)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(0)), 1);
                        _doc.ksDeleteMtr();
                        iSketch2Def.EndEdit();
                    }
                }
                // интерфейс второго эскиза выреза между зубьями
                ksEntity iSketch3Entity = iPart.NewEntity((short)Obj3dType.o3d_sketch) as ksEntity;
                if (iSketch3Entity != null)
                {
                    ksSketchDefinition iSketch3Def = iSketch3Entity.GetDefinition() as ksSketchDefinition;
                    if (iSketch3Def != null)
                    {
                        // строим на плоскости YOZ
                        iSketch3Def.SetPlane(planeYoz);
                        iSketch3Entity.Create();
                        _doc  = iSketch3Def.BeginEdit() as ksDocument2D;
                        alfa2 = -(180 / Math.PI * (thickness * Math.Tan(Math.PI * (angle) / 180) / diameterPitch));
                        _doc.ksMtr(0, 0, 90, 1, 1);
                        // вычерчивание изображения эскиза
                        // вместо эвольвент для простоты
                        // берем обычные дуги по трем точкам
                        _doc.ksArcBy3Points(-(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(alfa2)),
                                            -diameterPitch / 2 * Math.Sin(DegToRad(alfa1 / 8 + alfa2)),
                                            -diameterPitch / 2 * Math.Cos(DegToRad(alfa1 / 8 + alfa2)),
                                            -diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 4 + alfa2)),
                                            -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 4 + alfa2)), 1);
                        _doc.ksArcByPoint(0, 0, diameterIn / 2, -diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 4 + alfa2)),
                                          -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 4 + alfa2)),
                                          -diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 2 + alfa2)),
                                          -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 2 + alfa2)), -1, 1);
                        _doc.ksArcBy3Points(-diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 2 + alfa2)),
                                            -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 2 + alfa2)),
                                            -diameterPitch / 2 * Math.Sin(DegToRad(0.625 * alfa1 + alfa2)),
                                            -diameterPitch / 2 * Math.Cos(DegToRad(0.625 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(0.75 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(0.75 * alfa1 + alfa2)), 1);
                        _doc.ksArcBy3Points(-(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(0.75 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(0.75 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 2) * Math.Sin(DegToRad(0.375 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 2) * Math.Cos(DegToRad(0.375 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(alfa2)),
                                            1);
                        _doc.ksDeleteMtr();
                        iSketch3Def.EndEdit();
                    }
                }
                // вторая смещенная плоскость
                ksEntity iOffsetPlane1Entity = iPart.NewEntity((short)Obj3dType.o3d_planeOffset) as ksEntity;
                if (iOffsetPlane1Entity != null)
                {
                    ksPlaneOffsetDefinition iOffsetPlane1Def =
                        iOffsetPlane1Entity.GetDefinition() as ksPlaneOffsetDefinition;
                    if (iOffsetPlane1Def != null)
                    {
                        // величина смещения та же
                        iOffsetPlane1Def.offset = thickness / 2;
                        // направление противоположное
                        iOffsetPlane1Def.direction = true;
                        iOffsetPlane1Def.SetPlane(planeYoz);
                        // делаем плоскость скрытой
                        iOffsetPlane1Entity.hidden = true;
                        // создаем смещенную плоскость
                        iOffsetPlane1Entity.Create();
                    }
                }
                // третий (последний) эскиз выреза между зубьями
                ksEntity iSketch4Entity = iPart.NewEntity((short)Obj3dType.o3d_sketch) as ksEntity;
                if (iSketch4Entity != null)
                {
                    ksSketchDefinition iSketch4Def = iSketch4Entity.GetDefinition() as ksSketchDefinition;
                    if (iSketch4Def != null)
                    {
                        // базовая плоскость – только что созданная смещенная
                        iSketch4Def.SetPlane(iOffsetPlane1Entity);
                        iSketch4Entity.Create();
                        _doc  = iSketch4Def.BeginEdit() as ksDocument2D;
                        alfa2 = -(180 / Math.PI * (2 * thickness * Math.Tan(Math.PI * (angle) / 180) / diameterPitch));
                        _doc.ksMtr(0, 0, 90, 1, 1);
                        // вычерчивание изображения эскиза
                        // вместо эвольвент для простоты
                        // берем обычные дуги по трем точкам
                        _doc.ksArcBy3Points(-(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(alfa2)),
                                            -diameterPitch / 2 * Math.Sin(DegToRad(alfa1 / 8 + alfa2)),
                                            -diameterPitch / 2 * Math.Cos(DegToRad(alfa1 / 8 + alfa2)),
                                            -diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 4 + alfa2)),
                                            -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 4 + alfa2)), 1);
                        _doc.ksArcByPoint(0, 0, diameterIn / 2, -diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 4 + alfa2)),
                                          -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 4 + alfa2)),
                                          -diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 2 + alfa2)),
                                          -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 2 + alfa2)), -1, 1);
                        _doc.ksArcBy3Points(-diameterIn / 2 * Math.Sin(DegToRad(alfa1 / 2 + alfa2)),
                                            -diameterIn / 2 * Math.Cos(DegToRad(alfa1 / 2 + alfa2)),
                                            -diameterPitch / 2 * Math.Sin(DegToRad(0.625 * alfa1 + alfa2)),
                                            -diameterPitch / 2 * Math.Cos(DegToRad(0.625 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(0.75 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(0.75 * alfa1 + alfa2)), 1);
                        _doc.ksArcBy3Points(-(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(0.75 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(0.75 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 2) * Math.Sin(DegToRad(0.375 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 2) * Math.Cos(DegToRad(0.375 * alfa1 + alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Sin(DegToRad(alfa2)),
                                            -(diameterOut / 2 + 0.1) * Math.Cos(DegToRad(alfa2)),
                                            1);
                        _doc.ksDeleteMtr();
                        iSketch4Def.EndEdit();
                    }
                }
                // интерфейс операции Вырезать по сечениям
                ksEntity iCutLoftEntity = iPart.NewEntity((short)Obj3dType.o3d_cutLoft) as ksEntity;
                if (iCutLoftEntity != null)
                {
                    // интерфейс параметров операции по сечениям
                    ksCutLoftDefinition iCutLoftDef = iCutLoftEntity.GetDefinition() as ksCutLoftDefinition;
                    if (iCutLoftDef != null)
                    {
                        // интерфейс массива ksEntityCollection
                        // коллекции эскизов для вырезания по сечениям
                        ksEntityCollection collect = iCutLoftDef.Sketchs() as ksEntityCollection;
                        // добавляем эскизы в колекцию
                        collect.Add(iSketch2Entity);
                        collect.Add(iSketch3Entity);
                        collect.Add(iSketch4Entity);
                        // создаем операцию по сечениям
                        // результат – первый вырез между зубьями в венце колеса
                        iCutLoftEntity.Create();
                    }
                }
                // интерфейс вспомогательной оси на пересечении двух плоскостей
                ksEntity iAxis = iPart.NewEntity((short)Obj3dType.o3d_axis2Planes) as ksEntity;
                if (iAxis != null)
                {
                    // интерфейс параметров вспомогательной оси
                    // на пересечении плоскостей
                    ksAxis2PlanesDefinition iAxis2PlDef = iAxis.GetDefinition() as ksAxis2PlanesDefinition;
                    if (iAxis2PlDef != null)
                    {
                        // задаем плоскости
                        iAxis2PlDef.SetPlane(1, planeXoz);
                        iAxis2PlDef.SetPlane(2, planeXoy);
                        // делаем ось невидимой
                        iAxis.hidden = true;
                        // создаем вспомогательную ось
                        iAxis.Create();
                    }
                }
                // интерфейс операции Массив по концентрической сетке
                ksEntity iCircularCopy = iPart.NewEntity((short)Obj3dType.o3d_circularCopy) as ksEntity;
                if (iCircularCopy != null)
                {
                    // интерфейс параметров операции копирования по массиву
                    ksCircularCopyDefinition iCirCopyDef = iCircularCopy.GetDefinition() as ksCircularCopyDefinition;
                    if (iCirCopyDef != null)
                    {
                        // коллекция операций для копирования
                        ksEntityCollection collect1 = iCirCopyDef.GetOperationArray() as ksEntityCollection;
                        // операция всего лишь одна – вырезание зуба
                        collect1.Add(iCutLoftEntity);
                        // количество копий, равно количеству зубьев
                        iCirCopyDef.count2  = teethCount;
                        iCirCopyDef.factor2 = true;
                        // ось копирования
                        iCirCopyDef.SetAxis(iAxis);
                        // создаем концентрический массив – колесо готово!
                        iCircularCopy.Create();
                    }
                }
            }
        }
Exemple #21
0
        ///<summary>
        /// Создание креплений
        /// </summary>
        private void CreateMountong(double kadloHeight, double thicknessTopDrumhead, double thicknessBottomDrumhead, double rimCenter, int numberMounting)
        {
            if (_part != null)
            {
                // интерфейс свойств эскиза
                ksEntity mount = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_sketch);
                if (mount != null)
                {
                    // Получение интерфейса свойств эскиза
                    ksSketchDefinition rimSketch = (ksSketchDefinition)mount.GetDefinition();
                    if (rimSketch != null)
                    {
                        ksEntity basePlane;
                        // Получение интерфейса базовой плоскости XOY
                        basePlane = (ksEntity)_part.GetDefaultEntity((short)Obj3dType.o3d_planeXOY);
                        // установим плоскость базовой для эскиза
                        rimSketch.SetPlane(basePlane);
                        ksEntity entityOffsetPlane          = _part.NewEntity((short)Obj3dType.o3d_planeOffset);
                        ksPlaneOffsetDefinition offsetDef01 = (ksPlaneOffsetDefinition)entityOffsetPlane.GetDefinition();
                        // Расстояние смещения
                        offsetDef01.offset    = thicknessBottomDrumhead;
                        offsetDef01.direction = false;
                        offsetDef01.SetPlane(basePlane);
                        // создаем смещенную плоскость
                        entityOffsetPlane.Create();
                        // установим плоскость базовой для эскиза
                        rimSketch.SetPlane(offsetDef01);
                        // создадим эскиз
                        mount.Create();
                        // интерфейс редактора эскиза
                        ksDocument2D sketchEdit = (ksDocument2D)rimSketch.BeginEdit();
                        int          i          = 1;
                        for (double phi = 0; phi < 2 * Math.PI; phi += 2 * Math.PI / numberMounting)
                        {
                            double x = rimCenter * Math.Cos(phi);
                            double y = rimCenter * Math.Sin(phi);
                            //круглое отверстие
                            sketchEdit.ksCircle(x, y, 2.5, 1);

                            if (i < numberMounting)
                            {
                                i++;
                            }
                            else
                            {
                                break;
                            }
                        }

                        // завершение редактирования эскиза
                        rimSketch.EndEdit();
                        ksEntity entityBossExtr3 = (ksEntity)_part.NewEntity((short)Obj3dType.o3d_bossExtrusion);
                        if (entityBossExtr3 != null)
                        {
                            ksBossExtrusionDefinition bossExtrDef3 = (ksBossExtrusionDefinition)entityBossExtr3.GetDefinition();
                            if (bossExtrDef3 != null)
                            {
                                // интерфейс структуры параметров выдавливания
                                ksExtrusionParam extrProp3 = (ksExtrusionParam)bossExtrDef3.ExtrusionParam();
                                // интерфейс структуры параметров тонкой стенки
                                ksThinParam thinProp3 = (ksThinParam)bossExtrDef3.ThinParam();
                                if (extrProp3 != null)
                                {
                                    // эскиз операции выдавливания
                                    bossExtrDef3.SetSketch(rimSketch);
                                    // направление выдавливания
                                    extrProp3.direction = (short)Direction_Type.dtNormal;
                                    // тип выдавливания
                                    extrProp3.typeNormal = (short)End_Type.etBlind;
                                    // Высота выдавливания
                                    extrProp3.depthNormal = kadloHeight;
                                    // создадим операцию
                                    entityBossExtr3.Create();
                                }
                            }
                        }
                    }
                }
            }
        }