Esempio n. 1
0
        /// <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);
        }
Esempio n. 2
0
        /// <summary>
        /// Создание двери
        /// </summary>
        /// <param name="doorParameters"></param>
        public void BuildDoor(DoorParameters doorParameters)
        {
            ConnectToKompas();

            ksDocument3D doc = Kompas3D.Document3D();

            doc.Create();

            ksPart doorPart = doc.GetPart((short)
                                          Part_Type.pTop_Part);
            ksEntity planeXoY = doorPart.GetDefaultEntity((short)
                                                          Obj3dType.o3d_planeXOY);
            ksEntity sketch = doorPart.NewEntity((short)
                                                 Obj3dType.o3d_sketch);
            ksSketchDefinition sd = sketch.GetDefinition();

            sd.SetPlane(planeXoY);
            sketch.Create();
            ksDocument2D topSketch = sd.BeginEdit();

            DrawRectangle(topSketch,
                          -doorParameters.HeightDoor / 2.0, -doorParameters.WidthDoor / 2.0,
                          doorParameters.HeightDoor, doorParameters.WidthDoor,
                          null);
            sd.EndEdit();
            Extrude(doorPart, sketch, doorParameters.WeigthDoor,
                    (short)Direction_Type.dtNormal);
            DoorModification(doorParameters, doorPart, planeXoY);
        }
Esempio n. 3
0
        /// <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);
        }
Esempio n. 4
0
        /// <summary>
        /// Собачья заслонка
        /// </summary>
        /// <param name="doorParameters"></param>
        /// <param name="doorPart"></param>
        /// <param name="eyePlaneOffset"></param>
        private void AnimalDoor(DoorParameters doorParameters,
                                ksPart doorPart, ksEntity eyePlaneOffset)
        {
            var x = -doorParameters.HeightDoor / 2;
            var y = -doorParameters.WidthDoor / 2 + 350;
            var animalHoleHeight = 200;

            if (doorParameters.IsOpen == true)
            {
                ksEntity animalDoorHoleSketch = doorPart.NewEntity((short)
                                                                   Obj3dType.o3d_sketch);
                ksSketchDefinition animalDoorHoleSketchDefinition =
                    animalDoorHoleSketch.GetDefinition();
                animalDoorHoleSketchDefinition.SetPlane(eyePlaneOffset);
                animalDoorHoleSketch.Create();

                ksDocument2D animalDoorHole =
                    animalDoorHoleSketchDefinition.BeginEdit();
                DrawRectangle(animalDoorHole, x, y,
                              animalHoleHeight,
                              animalHoleHeight, null);
                animalDoorHoleSketchDefinition.EndEdit();
                Cut(doorPart, animalDoorHoleSketch,
                    doorParameters.WeigthDoor);

                ksEntity animalDoorSketch = doorPart.NewEntity((short)
                                                               Obj3dType.o3d_sketch);
                ksSketchDefinition animalDoorSketchDefinition =
                    animalDoorSketch.GetDefinition();
                animalDoorSketchDefinition.SetPlane(eyePlaneOffset);
                animalDoorSketch.Create();

                ksDocument2D animalDoor =
                    animalDoorSketchDefinition.BeginEdit();
                DrawRectangle(animalDoor, x + animalHoleHeight, y,
                              animalHoleHeight / 10.0, animalHoleHeight,
                              null);
                animalDoorSketchDefinition.EndEdit();
                Extrude(doorPart, animalDoorSketch, animalHoleHeight,
                        (short)Direction_Type.dtNormal);
            }
            if (doorParameters.IsOpen == false)
            {
                ksEntity animalDoorHoleSketch = doorPart.NewEntity((short)
                                                                   Obj3dType.o3d_sketch);
                ksSketchDefinition animalDoorHoleSketchDefinition =
                    animalDoorHoleSketch.GetDefinition();
                animalDoorHoleSketchDefinition.SetPlane(eyePlaneOffset);
                animalDoorHoleSketch.Create();

                ksDocument2D animalDoorHole =
                    animalDoorHoleSketchDefinition.BeginEdit();
                DrawRectangle(animalDoorHole, x, y, animalHoleHeight,
                              animalHoleHeight, null);
                animalDoorHoleSketchDefinition.EndEdit();
                Cut(doorPart, animalDoorHoleSketch, 0.2);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Дверная ручка
        /// </summary>
        /// <param name="doorParameters"></param>
        /// <param name="doorPart"></param>
        /// <param name="eyePlaneOffset"></param>
        private void DoorKnob(DoorParameters doorParameters,
                              ksPart doorPart, ksEntity eyePlaneOffset)
        {
            ksEntity floorKeySketch = doorPart.NewEntity((short)
                                                         Obj3dType.o3d_sketch);
            ksSketchDefinition floorKeyDifinition =
                floorKeySketch.GetDefinition();

            floorKeyDifinition.SetPlane(eyePlaneOffset);
            floorKeySketch.Create();
            ksDocument2D floorKey = floorKeyDifinition.BeginEdit();

            DrawRectangle(floorKey, doorParameters.YKey / 2.0,
                          doorParameters.WidthDoor - 490, 18, 18,
                          null);
            floorKeyDifinition.EndEdit();
            Extrude(doorPart, floorKeySketch, 25,
                    (short)Direction_Type.dtNormal);
            HandleBase(doorParameters, doorPart,
                       eyePlaneOffset);
        }
Esempio n. 6
0
        /// <summary>
        /// Отправка данных в компас и проверка решений
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pushToKompas_Click(object sender, EventArgs e)
        {
            var heightDoor = int.Parse(doorHeight.Items
                                       [doorHeight.SelectedIndex].ToString());
            var widthDoor = int.Parse(doorWidth.Items
                                      [doorWidth.SelectedIndex].ToString());
            var weigthDoor = int.Parse(doorThickness.Items
                                       [doorThickness.SelectedIndex].ToString());
            var yKey = int.Parse(doorHandle.Items
                                 [doorHandle.SelectedIndex].ToString());
            var yEye = int.Parse(doorPeephole.Items
                                 [doorPeephole.SelectedIndex].ToString());
            bool?isOpen = null;

            if (checkAnimal.Checked)
            {
                if (openAnimalDoor.Checked)
                {
                    isOpen = true;
                }
                if (closeAnimalDoor.Checked)
                {
                    isOpen = false;
                }
            }

            var door = new DoorParameters(weigthDoor, yKey,
                                          yEye, isOpen, heightDoor, widthDoor);

            if (_kompas3D.Kompas3D == null)
            {
                _kompas3D.StartKompas();
            }

            _kompas3D.BuildDoor(door);
        }