Example #1
0
 /// <summary>
 /// Muffler parameters
 /// </summary>
 /// <param name="document3DPart">Part with detail in 3D document</param>
 /// <param name="basePlaneAxis">Axis of base plane of muffler</param>
 /// <param name="direction">Direction type of muffler</param>
 /// <param name="basePlanePoint">Point of base plane of muffler</param>
 public MufflerParameters(ksPart document3DPart, Obj3dType basePlaneAxis, Direction_Type direction, KompasPoint2D basePlanePoint)
 {
     Document3DPart = document3DPart;
     BasePlaneAxis  = basePlaneAxis;
     Direction      = direction;
     BasePlanePoint = basePlanePoint;
 }
Example #2
0
        public void TestCutBySketch(ErrorCodes errorCode, Obj3dType extrusionType, Direction_Type directionType)
        {
            var appTest = new KompasApplicationTest();
            var app     = appTest.CreateKompasApplication();
            var sketch  = CreateSketchWithCirle(app);

            var extrusionParameters = new KompasExtrusionParameters(app.ScrewPart, Obj3dType.o3d_baseExtrusion, sketch, directionType, 10);
            var extrusion           = new KompasExtrusion(extrusionParameters, ExtrusionType.ByEntity);

            Assert.AreEqual(extrusion.LastErrorCode, errorCode);

            Direction_Type cutExtrusionDirection = Direction_Type.dtBoth;

            if (directionType == Direction_Type.dtNormal)
            {
                cutExtrusionDirection = Direction_Type.dtReverse;
            }
            else if (directionType == Direction_Type.dtReverse)
            {
                cutExtrusionDirection = Direction_Type.dtNormal;
            }

            extrusionParameters = new KompasExtrusionParameters(app.ScrewPart, extrusionType, sketch, cutExtrusionDirection, 10);
            var cutExtrusion = new KompasExtrusion(extrusionParameters, ExtrusionType.ByEntity);

            Assert.AreEqual(cutExtrusion.LastErrorCode, errorCode);
        }
Example #3
0
        /// <summary>
        /// метод создания треугольника для крестообразного шлица
        /// </summary>
        /// <param name="width">длина </param>
        /// <param name="height">высота</param>
        /// <param name="planeType">плоскость</param>
        /// <param name="type">метод выдавливания</param>
        /// <param name="extrusionHeight">высота выдавливания</param>
        /// <returns></returns>
        private ksEntity DrawTriangle(
            Double width,
            Double height,
            Obj3dType planeType,
            Direction_Type type,
            Double extrusionHeight)
        {
            var regPolySketch     = new KompasSketch(_kompasApp.ScrewPart, planeType);
            var regPolySketchEdit = regPolySketch.BeginEntityEdit();

            regPolySketchEdit.ksLineSeg(0, width, 0, -width, 1);
            regPolySketchEdit.ksLineSeg(0, width, height, 0, 1);
            regPolySketchEdit.ksLineSeg(0, -width, height, 0, 1);
            regPolySketch.EndEntityEdit();

            var extrusionParameters = new KompasExtrusionParameters
                                      (
                _kompasApp.ScrewPart,
                Obj3dType.o3d_cutExtrusion,
                regPolySketch.Entity,
                type,
                extrusionHeight
                                      );

            var regPolyExtrusion = new KompasExtrusion(extrusionParameters,
                                                       ExtrusionType.ByEntity);

            return(regPolyExtrusion.ExtrudedEntity);
        }
Example #4
0
        public void CreateOnBasePlaneAxis(ErrorCodes errorCode, Obj3dType basePlaneAxis)
        {
            var appTest = new KompasApplicationTest();
            var app     = appTest.CreateKompasApplication();

            var sketch = new KompasSketch(app.ScrewPart, basePlaneAxis);

            Assert.AreEqual(sketch.LastErrorCode, errorCode);
        }
        /// <summary>
        /// Kompas extrusion parameters for extrusion by sketches collection
        /// </summary>
        /// <param name="document3DPart">Part with detail in 3d document</param>
        /// <param name="extrusionType">Type of extrusion</param>
        /// <param name="extrudableEntity">Extrudable (выдавливаЕМЫЙ) entity</param>
        /// <param name="sketchesCollection">Collection of extrudable sketches for types
        /// such as loft, evolution etc.</param>
        public KompasExtrusionParameters(ksPart document3DPart, Obj3dType extrusionType, ksEntity extrudableEntity, ksEntityCollection sketchesCollection)
        {
            Document3DPart     = document3DPart;
            ExtrusionType      = extrusionType;
            ExtrudableEntity   = extrudableEntity;
            SketchesCollection = sketchesCollection;

            Direction = Direction_Type.dtBoth;
            Depth     = default(double);
        }
        /// <summary>
        /// Kompas extrusion parameters for extrusion by entity
        /// </summary>
        /// <param name="document3DPart">Part with detail in 3d document</param>
        /// <param name="extrusionType">Type of extrusion</param>
        /// <param name="extrudableEntity">Extrudable (выдавливаЕМЫЙ) entity</param>
        /// <param name="direction">Type of direction of extrusion</param>
        /// <param name="depth">Depth of extrusion</param>
        public KompasExtrusionParameters(ksPart document3DPart, Obj3dType extrusionType, ksEntity extrudableEntity, Direction_Type direction, double depth)
        {
            Document3DPart   = document3DPart;
            ExtrusionType    = extrusionType;
            ExtrudableEntity = extrudableEntity;
            Direction        = direction;
            Depth            = depth;

            SketchesCollection = null;
        }
Example #7
0
        public void CutBySketchUnsupportedDirection(ErrorCodes errorCode, Obj3dType extrusionType, Direction_Type directionType)
        {
            var appTest = new KompasApplicationTest();
            var app     = appTest.CreateKompasApplication();
            var sketch  = CreateSketchWithCirle(app);

            var extrusionParameters = new KompasExtrusionParameters(app.ScrewPart, Obj3dType.o3d_baseExtrusion, sketch, directionType, 10);
            var extrusion           = new KompasExtrusion(extrusionParameters, ExtrusionType.ByEntity);

            Assert.AreEqual(extrusion.LastErrorCode, errorCode);
        }
Example #8
0
        /// <summary>
        ///     метод выреза/выдавливания фигуры
        /// </summary>
        /// <param name="part">Часть эскиза</param>
        /// <param name="sketch">Эскиз</param>
        /// <param name="heigth">Высота</param>
        /// <param name="type">принимаемое значение</param>
        private static void Extrusion(ksPart part, ksEntity sketch,
                                      double heigth, Obj3dType type)
        {
            ksEntity cutExtrude = part.NewEntity((short)type);
            var      cutextrDef = cutExtrude.GetDefinition();

            cutextrDef.directionType = (short)Direction_Type.dtNormal;
            cutextrDef.SetSketch(sketch);
            ksExtrusionParam cutExtrParam = cutextrDef.ExtrusionParam();

            cutExtrParam.depthNormal = heigth;
            cutExtrude.Create();
        }
Example #9
0
        /// <summary>
        /// Создание эскиза для вычитания полости.
        /// </summary>
        /// <param name="part">Указатель на деталь.</param>
        /// <param name="offset">Отстройка плоскости по высоте, равная толщине дна стакана.</param>
        /// <param name="plane">Плоскость.</param>
        public void MakeSketch(ksPart part, double offset, Obj3dType plane = Obj3dType.o3d_planeXOY)
        {
            var entityPlane           = (ksEntity)part.GetDefaultEntity((short)plane);
            var entityOffsetPlane     = (ksEntity)part.NewEntity((short)Obj3dType.o3d_planeOffset);
            var planeOffsetDefinition = (ksPlaneOffsetDefinition)entityOffsetPlane.GetDefinition();

            planeOffsetDefinition.direction = true;
            planeOffsetDefinition.offset    = offset;
            planeOffsetDefinition.SetPlane(entityPlane);
            entityOffsetPlane.Create();

            _entitySketch     = (ksEntity)part.NewEntity((short)Obj3dType.o3d_sketch);
            _sketchDefinition = (ksSketchDefinition)_entitySketch.GetDefinition();

            _sketchDefinition.SetPlane(planeOffsetDefinition);
            _entitySketch.Create();
        }
Example #10
0
        /// <summary>
        ///     Выдавливание конкретной секции
        /// </summary>
        /// <param name="height">Высота</param>
        /// <param name="width">Ширина</param>
        /// <param name="weigth">Толщина</param>
        /// <param name="windowPart">Часть окна</param>
        /// <param name="planeXoy">Плоскость</param>
        /// <param name="xStart">Начало оси Х</param>
        /// <param name="yStart">Начало оси Y</param>
        /// <param name="type"></param>
        private void ExtrudeOdject(double height, double width,
                                   double weigth, ksPart windowPart, ksEntity planeXoy,
                                   double xStart, double yStart, Obj3dType type)
        {
            ksEntity           sketch           = windowPart.NewEntity((short)Obj3dType.o3d_sketch);
            ksSketchDefinition sketchDefinition = sketch.GetDefinition();

            sketchDefinition.SetPlane(planeXoy);
            sketch.Create();

            ksDocument2D document2D = sketchDefinition.BeginEdit();

            DrawRectangle(document2D, xStart, yStart, height, width, null);
            sketchDefinition.EndEdit();

            Extrusion(windowPart, sketch, weigth, type);
        }
Example #11
0
        private void OffsetSketchSet(ksDocument3D document3D,
                                     KeyboardParametersStorage data, string sketchName,
                                     double offset, Obj3dType obj3DType)
        {
            SketchType sketchType = SketchType.BlackKeyCut;


            part = (ksPart)document3D.GetPart((short)Part_Type.pTop_Part);

            var entityOffsetPlane = (ksEntity)part.NewEntity((short)Obj3dType.o3d_planeOffset);
            var entitySketch      = (ksEntity)part.NewEntity((short)Obj3dType.o3d_sketch);

            entitySketch.name = sketchName;
            if (entityOffsetPlane != null)
            {
                var offsetDef = (ksPlaneOffsetDefinition)entityOffsetPlane.GetDefinition();
                if (offsetDef != null)
                {
                    offsetDef.direction = true;
                    offsetDef.offset    = offset;

                    var basePlane = (ksEntity)part.GetDefaultEntity((short)obj3DType);
                    basePlane.name = "Начальная плоскость";

                    offsetDef.SetPlane(basePlane);

                    entityOffsetPlane.name   = "Смещенная плоскость";
                    entityOffsetPlane.hidden = true;
                    entityOffsetPlane.Create();

                    var sketchDef = (ksSketchDefinition)entitySketch.GetDefinition();
                    if (sketchDef != null)
                    {
                        sketchDef.SetPlane(entityOffsetPlane);
                        entitySketch.Create();

                        var sketchEdit = (ksDocument2D)sketchDef.BeginEdit();

                        LineDraw(sketchEdit, data, sketchType);

                        sketchDef.EndEdit();
                        BlackKeyCut(part, entitySketch, data);
                    }
                }
            }
        }
        /// <summary>
        /// Создание деталей шасси
        /// </summary>
        /// <param name="xc"></param>
        /// <param name="yc"></param>
        /// <param name="r"></param>
        /// <param name="plane"></param>
        /// <param name="direction"></param>
        /// <param name="beginDetails"></param>
        /// <param name="endDetails"></param>
        /// <returns></returns>
        private ksEntity CreateShaftAndRack(double xc, double yc, double r, Obj3dType plane, bool direction, double beginDetails, double endDetails)
        {
            // Создание списка сечений для деталей шасси
            var entityCollection = new List <ksEntity>
            {
                // Создание сечения начала деталей шасси
                CreateCircle(-xc,
                             yc,
                             r,
                             MovePlane(GetPlane(plane), direction, beginDetails)),
                // Создание сечения конца деталей шасси
                CreateCircle(-xc,
                             yc,
                             r,
                             MovePlane(GetPlane(plane), direction, endDetails))
            };

            // Выдавливание детали шасси по сечениям
            return(ExtrudeLoft(entityCollection));
        }
Example #13
0
        /// <summary>
        /// Создать эскиз по базовой плоскости
        /// </summary>
        /// <param name="doc3DPart">Document 3D part</param>
        /// <param name="basePlaneAxis">Base plane axis</param>
        public KompasSketch(ksPart doc3DPart, Obj3dType basePlaneAxis)
        {
            if (doc3DPart == null)
            {
                LastErrorCode = ErrorCodes.ArgumentNull;
                return;
            }

            if (!(basePlaneAxis == Obj3dType.o3d_planeXOY ||
                  basePlaneAxis == Obj3dType.o3d_planeXOZ ||
                  basePlaneAxis == Obj3dType.o3d_planeYOZ)
                )
            {
                LastErrorCode = ErrorCodes.ArgumentInvalid;
                return;
            }

            _basePlaneAxis = basePlaneAxis; // ось базовой плоскости

            Entity = CreateEntity(doc3DPart);
        }
        /// <summary>
        /// Тип плоскости
        /// </summary>
        /// <param name="typePlane"></param>
        /// <returns></returns>
        private ksEntity GetPlane(Obj3dType typePlane)
        {
            var plane = (ksEntity)_part.GetDefaultEntity((short)typePlane);

            return(plane);
        }