Ejemplo n.º 1
0
        /// <summary>
        /// 创建单边偏置的拉伸
        /// </summary>
        /// <param name="features"></param>
        /// <param name="curves"></param>
        /// <param name="extrudeDirection"></param>
        /// <param name="startDistance"></param>
        /// <param name="endDistance"></param>
        /// <param name="bodyStyle"></param>
        /// <param name="offsetValue"></param>
        /// <returns></returns>
        public static Extrude CreateExtrude(this FeatureCollection features, IBaseCurve[] curves, Vector3d extrudeDirection, double startDistance, double endDistance, NXOpen.GeometricUtilities.FeatureOptions.BodyStyle bodyStyle, double offsetValue)
        {
            NXOpen.Features.ExtrudeBuilder extrudeBuilder = features.CreateExtrudeBuilder(null);

            Section section1 = WorkPart.Sections.CreateSection(0.0095, 0.01, 0.5);

            extrudeBuilder.Section = section1;

            extrudeBuilder.AllowSelfIntersectingSection(true);

            extrudeBuilder.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create;

            extrudeBuilder.Offset.Option = NXOpen.GeometricUtilities.Type.SingleOffset;

            extrudeBuilder.Offset.EndOffset.Value = offsetValue;

            extrudeBuilder.Draft.DraftOption = NXOpen.GeometricUtilities.SimpleDraft.SimpleDraftType.NoDraft;

            extrudeBuilder.FeatureOptions.BodyType = bodyStyle;

            section1.DistanceTolerance = 0.01;

            section1.ChainingTolerance = 0.0095;

            section1.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.OnlyCurves);

            extrudeBuilder.Direction = WorkPart.Directions.CreateDirection(new Point3d(0.0, 0.0, 0.0), extrudeDirection, NXOpen.SmartObject.UpdateOption.WithinModeling);

#if NX12
            CurveDumbRule curveDumbRule = (WorkPart as BasePart).ScRuleFactory.CreateRuleBaseCurveDumb(curves);
#else
            CurveDumbRule curveDumbRule = WorkPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves);
#endif
            section1.AllowSelfIntersection(true);

            SelectionIntentRule[] rules1 = new SelectionIntentRule[1] {
                curveDumbRule
            };

            section1.AddToSection(rules1, (NXObject)curves[0], null, null, new Point3d(0, 0, 0), NXOpen.Section.Mode.Create, false);

            extrudeBuilder.Limits.StartExtend.TrimType = NXOpen.GeometricUtilities.Extend.ExtendType.Value;

            extrudeBuilder.Limits.EndExtend.TrimType = NXOpen.GeometricUtilities.Extend.ExtendType.Value;

            extrudeBuilder.Limits.EndExtend.Value.RightHandSide = endDistance.ToString();

            extrudeBuilder.Limits.StartExtend.Value.RightHandSide = startDistance.ToString();

            extrudeBuilder.ParentFeatureInternal = false;

            Extrude extrude = (Extrude)extrudeBuilder.CommitFeature();
            extrudeBuilder.Destroy();
            return(extrude);
        }
Ejemplo n.º 2
0
        internal static Snap.NX.Extrude CreateExtrude(Snap.NX.Section section, Vector axis, Snap.Number[] extents, Snap.Number draftAngle, bool offset, Snap.Number[] offsetValues, bool createSheet)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.ExtrudeBuilder featureBuilder = workPart.Features.CreateExtrudeBuilder(null);
            featureBuilder.DistanceTolerance     = Globals.DistanceTolerance;
            featureBuilder.BooleanOperation.Type = BooleanOperation.BooleanType.Create;
            if (createSheet)
            {
                featureBuilder.FeatureOptions.BodyType = FeatureOptions.BodyStyle.Sheet;
            }
            featureBuilder.Limits.StartExtend.Value.RightHandSide = extents[0].ToString();
            featureBuilder.Limits.EndExtend.Value.RightHandSide   = extents[1].ToString();
            featureBuilder.Offset.Option = NXOpen.GeometricUtilities.Type.NoOffset;
            if (offset)
            {
                featureBuilder.Offset.Option = NXOpen.GeometricUtilities.Type.NonsymmetricOffset;
                featureBuilder.Offset.StartOffset.RightHandSide = offsetValues[0].ToString();
                featureBuilder.Offset.EndOffset.RightHandSide   = offsetValues[1].ToString();
            }
            double num = Snap.Number.Parse(Snap.Number.NullToZero(draftAngle).ToString());

            if (System.Math.Abs(num) < 0.001)
            {
                featureBuilder.Draft.DraftOption = SimpleDraft.SimpleDraftType.NoDraft;
            }
            else
            {
                featureBuilder.Draft.DraftOption = SimpleDraft.SimpleDraftType.SimpleFromProfile;
            }
            featureBuilder.Draft.FrontDraftAngle.RightHandSide = Snap.Number.ToString(num);
            featureBuilder.Section = (NXOpen.Section)section;
            Point3d  origin = new Point3d(30.0, 0.0, 0.0);
            Vector3d vector = new Vector3d(axis.X, axis.Y, axis.Z);

            NXOpen.Direction direction = workPart.Directions.CreateDirection(origin, vector, SmartObject.UpdateOption.WithinModeling);
            featureBuilder.Direction = direction;
            NXOpen.Features.Extrude extrude = (NXOpen.Features.Extrude)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            return(new Snap.NX.Extrude(extrude));
        }