Beispiel #1
0
        /// <summary>
        /// 隐藏孔创建的草图并修改孔颜色
        /// </summary>
        /// <param name="Thole">目标孔</param>
        private void ChangeHoleColor(Hole Thole, RxHoleType HoleType)
        {
            //隐藏孔创建的草图并修改孔颜色
            Selection HoleSelection = CatActiveDoc.Selection;

            HoleSelection.Clear();
            VisPropertySet HoleSet    = HoleSelection.VisProperties;
            Sketch         HoleSketch = Thole.Sketch;

            HoleSelection.Add(HoleSketch);
            HoleSet.SetShow(CatVisPropertyShow.catVisPropertyNoShowAttr);
            HoleSelection.Clear();
            HoleSelection.Add(Thole);
            switch (HoleType)
            {
            case RxHoleType.PinHole:     //销孔
                HoleSet.SetVisibleColor(251, 146, 248, 0);
                break;

            case RxHoleType.NSmoothHole:     //光孔
                HoleSet.SetVisibleColor(167, 230, 182, 0);
                break;

            case RxHoleType.ISmoothHole:     //沉头孔
                HoleSet.SetVisibleColor(167, 230, 182, 0);
                break;

            case RxHoleType.ThreadHole:     //螺纹孔
                HoleSet.SetVisibleColor(128, 0, 255, 0);
                break;

            default:
                break;
            }
            HoleSelection.Clear();
        }
Beispiel #2
0
        /// <summary>
        /// 设置无尺寸约束的孔属性
        /// </summary>
        /// <param name="Nwhole">孔对象</param>
        /// <param name="LengthDis">孔距离长边距离</param>
        /// <param name="WeightDis">孔距离短边距离</param>
        /// <param name="Diameter">孔直径</param>
        /// <param name="HoleType">孔类型</param>
        /// <param name="Comstraints">1:宽边,2:长边</param>
        private void RxSetHoleType(Part Tpart, Hole Nwhole, double LengthDis, double WeightDis, double Diameter, RxHoleType HoleType, Edge WidthEdge, Edge LengthEdge)
        {
            Nwhole.Type       = CatHoleType.catSimpleHole;
            Nwhole.AnchorMode = CatHoleAnchorMode.catExtremPointHoleAnchor;
            Nwhole.BottomType = CatHoleBottomType.catVHoleBottom;
            Limit BottomLimit = Nwhole.BottomLimit;

            BottomLimit.LimitMode    = CatLimitMode.catOffsetLimit;
            Nwhole.Diameter.Value    = Diameter;
            Nwhole.BottomAngle.Value = 120;
            Nwhole.ThreadingMode     = CatHoleThreadingMode.catSmoothHoleThreading;
            Sketch Hosketch = Nwhole.Sketch;

            MECMOD.Constraints HoleConstraint = Hosketch.Constraints;
            int       Cont            = Hosketch.GeometricElements.Count;
            string    Type            = Hosketch.GeometricElements.Item(2).get_Name();
            Point2D   HoleCenterPoint = (Point2D)Hosketch.GeometricElements.Item(2);
            Reference refPoint        = Tpart.CreateReferenceFromObject(HoleCenterPoint);

            if (HoleConstraint.Count < 3)
            {
                Tpart.InWorkObject = Hosketch;
                Factory2D         factory2D     = Hosketch.OpenEdition();
                GeometricElements geWidthEdge   = factory2D.CreateProjections(WidthEdge);
                GeometricElements geLengthEdge  = factory2D.CreateProjections(LengthEdge);
                Geometry2D        geoWidthEdge  = (Geometry2D)geWidthEdge.Item("标记.1");
                Geometry2D        geoLengthEdge = (Geometry2D)geLengthEdge.Item("标记.1");
                geoWidthEdge.Construction  = true;
                geoLengthEdge.Construction = true;
                Reference EpWidth  = Tpart.CreateReferenceFromObject(geoWidthEdge);
                Reference EpLength = Tpart.CreateReferenceFromObject(geoLengthEdge);
                //geo1.Construction = true;
                Constraint holeConstraintL = HoleConstraint.AddBiEltCst(CatConstraintType.catCstTypeDistance, refPoint, EpWidth);
                Constraint holeConstraintW = HoleConstraint.AddBiEltCst(CatConstraintType.catCstTypeDistance, refPoint, EpLength);
                holeConstraintL.Dimension.Value = WeightDis; //孔距离宽边的距离
                holeConstraintW.Dimension.Value = LengthDis; //孔距离长边的距离
                Hosketch.CloseEdition();
            }
            else
            {
                HoleConstraint.Item(1).Dimension.Value = WeightDis; //孔距离宽边的距离
                HoleConstraint.Item(2).Dimension.Value = LengthDis; //孔距离长边的距离
            }

            //HoleConstraint.Item(2).Dimension.Value = 10;
            Nwhole.ThreadSide     = CatHoleThreadSide.catRightThreadSide;
            BottomLimit.LimitMode = CatLimitMode.catUpThruNextLimit;
            ChangeHoleColor(Nwhole, HoleType);
        }
Beispiel #3
0
        /// <summary>
        ///  瑞祥API设置孔属性
        /// </summary>
        /// <param name="Nwhole">孔对象</param>
        /// <param name="LengthDis">孔距离长边距离</param>
        /// <param name="WeightDis">孔距离短边距离</param>
        /// <param name="Diameter">孔直径</param>
        /// <param name="HoleType">孔类型</param>
        private void RxSetHoleType(Hole Nwhole, double LengthDis, double WeightDis, double Diameter, RxHoleType HoleType)
        {
            Nwhole.Type       = CatHoleType.catSimpleHole;
            Nwhole.AnchorMode = CatHoleAnchorMode.catExtremPointHoleAnchor;
            Nwhole.BottomType = CatHoleBottomType.catVHoleBottom;
            Limit BottomLimit = Nwhole.BottomLimit;

            BottomLimit.LimitMode    = CatLimitMode.catOffsetLimit;
            Nwhole.Diameter.Value    = Diameter;
            Nwhole.BottomAngle.Value = 120;
            Nwhole.ThreadingMode     = CatHoleThreadingMode.catSmoothHoleThreading;
            Sketch Hosketch = Nwhole.Sketch;

            MECMOD.Constraints HoleConstraint = Hosketch.Constraints;
            HoleConstraint.Item(1).Dimension.Value = WeightDis; //孔距离宽边的距离
            HoleConstraint.Item(2).Dimension.Value = LengthDis; //孔距离长边的距离
            //HoleConstraint.Item(2).Dimension.Value = 10;
            Nwhole.ThreadSide     = CatHoleThreadSide.catRightThreadSide;
            BottomLimit.LimitMode = CatLimitMode.catUpThruNextLimit;
            ChangeHoleColor(Nwhole, HoleType);
        }