Example #1
0
        internal static Snap.NX.Revolve CreateRevolve(Snap.NX.ICurve[] icurves, Position axisPoint, Vector axisVector, Snap.Number[] extents, bool offset, Snap.Number[] offsetValues, bool createSheet)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.RevolveBuilder featureBuilder = workPart.Features.CreateRevolveBuilder(null);
            featureBuilder.Tolerance = Globals.DistanceTolerance;
            Snap.NX.Section section = Snap.NX.Section.CreateSection(icurves);
            featureBuilder.Section = (NXOpen.Section)section;
            section.NXOpenSection.DistanceTolerance = Globals.DistanceTolerance;
            section.NXOpenSection.ChainingTolerance = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
            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();
            }
            Direction direction = workPart.Directions.CreateDirection((Point3d)axisPoint, (Vector3d)axisVector, SmartObject.UpdateOption.WithinModeling);

            NXOpen.Point point = null;
            NXOpen.Axis  axis  = workPart.Axes.CreateAxis(point, direction, SmartObject.UpdateOption.WithinModeling);
            featureBuilder.Axis = axis;
            NXOpen.Features.Revolve revolve = (NXOpen.Features.Revolve)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            return(new Snap.NX.Revolve(revolve));
        }
Example #2
0
        internal static Snap.NX.Cone CreateConeFromDiametersHeight(Position axisPoint, Vector direction, Snap.Number baseDiameter, Snap.Number topDiameter, Snap.Number height)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.ConeBuilder featureBuilder = workPart.Features.CreateConeBuilder(null);
            featureBuilder.BooleanOption.Type = BooleanOperation.BooleanType.Create;
            featureBuilder.Type = NXOpen.Features.ConeBuilder.Types.DiametersAndHeight;
            Direction direction2 = workPart.Directions.CreateDirection((Point3d)axisPoint, (Vector3d)direction, SmartObject.UpdateOption.WithinModeling);

            NXOpen.Axis axis = featureBuilder.Axis;
            axis.Direction = direction2;
            axis.Point     = workPart.Points.CreatePoint((Point3d)axisPoint);
            featureBuilder.BaseDiameter.RightHandSide = baseDiameter.ToString();
            featureBuilder.TopDiameter.RightHandSide  = topDiameter.ToString();
            featureBuilder.Height.RightHandSide       = height.ToString();
            NXOpen.Features.Cone cone = (NXOpen.Features.Cone)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            return(new Snap.NX.Cone(cone));
        }