コード例 #1
0
            /// <summary>
            /// Построить граненный стакан в САПР Компас 3D.
            /// </summary>
            /// <param name="glass">Граненный стакан.</param>
            public void Build(IGlass glass)
            {
                _builderBlank.Build(glass);

                _startX = 0;
                _startY = 0;

                _glass      = glass;
                _calcParams = new CalcParams(glass);

                var doc = _kompas.ActiveDocument3D;

                var part = (ksPart)doc.GetPart((short)Part_Type.pTop_Part);

                var basePlane = (ksEntity)part.GetDefaultEntity(
                    (short)Obj3dType.o3d_planeXOY);

                var offsetCutFacetedPlane = _kompas.CreateOffsetPlane(
                    part, basePlane, _calcParams.OffsetFacetedPlane);

                var sketchCutFaceted = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchCutFaceted.name = "Эскиз граней";

                var sketchDefCutFaceted =
                    (ksSketchDefinition)sketchCutFaceted.GetDefinition();

                sketchDefCutFaceted.SetPlane(offsetCutFacetedPlane);

                sketchCutFaceted.Create();

                GenerateCutFaceted2d(sketchDefCutFaceted);
                GenerateCutFaceted3d(sketchCutFaceted, part);
            }
コード例 #2
0
            /// <summary>
            /// Построить гофрированный стакан.
            /// </summary>
            /// <param name="glass">Гофрированный стакан.</param>
            public void Build(IGlass glass)
            {
                _builderBlank.Build(glass);

                _glass      = glass;
                _calcParams = new CalcParams(glass);

                var doc = _kompas.ActiveDocument3D;

                var part = (ksPart)doc.GetPart(
                    (short)Part_Type.pTop_Part);

                var basePlane = (ksEntity)part.GetDefaultEntity(
                    (short)Obj3dType.o3d_planeXOY);

                var offsetCrimpPlane = _kompas.CreateOffsetPlane(
                    part, basePlane, _calcParams.OffsetFacetedPlane);

                var sketchCrimp = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchCrimp.name = "Эскиз рефлёностей";

                var sketchDefCrimp =
                    (ksSketchDefinition)sketchCrimp.GetDefinition();

                sketchDefCrimp.SetPlane(offsetCrimpPlane);

                sketchCrimp.Create();

                GenerateExtrusionCrimp2d(sketchDefCrimp);
                GenerateExtrusionCrimp3d(sketchCrimp, part);
            }
コード例 #3
0
            /// <summary>
            /// Построить модель стакана в САПР Компас 3D.
            /// </summary>
            /// <param name="photoFrame">Шаблон стакана.</param>
            /// <exception cref="InvalidOperationException">
            ///     Вызывается тогда, когда параметры стакана
            ///     имеют недопустимые значения.</exception>
            public void Build(IGlass glass)
            {
                if (glass.IsValid == false)
                {
                    var msg = String.Format("Шаблон стакана имеет" +
                                            " недопустимые параметры для построения.");
                    throw new InvalidOperationException(msg);
                }

                _kompas.ShowCAD();

                _startX = 0;
                _startY = 0;

                _glass      = glass;
                _calcParams = new CalcParams(glass);

                var doc = _kompas.Document3D;

                doc.Create();

                var part = (ksPart)doc.GetPart((short)Part_Type.pTop_Part);

                var sketchBase = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchBase.name = "Эскиз основания";

                var basePlane = (ksEntity)part.GetDefaultEntity(
                    (short)Obj3dType.o3d_planeXOY);

                var sketchDefBase =
                    (ksSketchDefinition)sketchBase.GetDefinition();

                sketchDefBase.SetPlane(basePlane);

                sketchBase.Create();

                var sketchCutSide = (ksEntity)part.NewEntity(
                    (short)Obj3dType.o3d_sketch);

                sketchCutSide.name = "Эскиз вырезанных внутренностей";

                var offsetCutPlane = _kompas.CreateOffsetPlane(
                    part, basePlane, glass.Height);

                var sketchDefCutSide =
                    (ksSketchDefinition)sketchCutSide.GetDefinition();

                sketchDefCutSide.SetPlane(offsetCutPlane);

                sketchCutSide.Create();

                GenerateBlank2d(sketchDefBase);
                GenerateBlank3d(sketchBase, part);
                GenerateCutSide2d(sketchDefCutSide);
                GenerateCutSide3d(sketchCutSide, part);

                if (glass.Filleted)
                {
                    FilletedBottomAndTop(glass, part);
                }
            }