Beispiel #1
0
            public override ksEntity Execute()
            {
                ksEntity cut = Part.NewEntity((short)Obj3dType.o3d_cutEvolution);
                ksCutEvolutionDefinition definition = cut.GetDefinition();

                definition.cut             = true;
                definition.sketchShiftType = 1;
                definition.SetSketch(_drawSectionCmd.Execute());

                ksEntityCollection entityCollection = definition.PathPartArray();

                entityCollection.Clear();
                entityCollection.Add(_drawTrajectoryCmd.Execute());
                cut.Create();
                return(cut);
            }
        /// <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();
        }