예제 #1
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);
        }
예제 #2
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);
        }