Exemplo n.º 1
0
        internal static Snap.NX.ProjectCurve CreateProjectCurve(Snap.NX.Curve[] curves, Snap.NX.Point[] points, Snap.NX.Face face)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.ProjectCurveBuilder featureBuilder = workPart.Features.CreateProjectCurveBuilder(null);
            featureBuilder.CurveFitData.Tolerance = Globals.DistanceTolerance;
            featureBuilder.AngleToProjectionVector.RightHandSide = "0";
            featureBuilder.SectionToProject.DistanceTolerance    = Globals.DistanceTolerance;
            featureBuilder.SectionToProject.ChainingTolerance    = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
            featureBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.CurvesAndPoints);
            featureBuilder.ProjectionDirectionMethod = NXOpen.Features.ProjectCurveBuilder.DirectionType.AlongFaceNormal;
            Snap.NX.Section sectionToProject = featureBuilder.SectionToProject;
            sectionToProject.AddICurve(curves);
            sectionToProject.AddPoints(points);
            ScCollector collector = workPart.ScCollectors.CreateCollector();

            NXOpen.Face[] faces = new NXOpen.Face[] { face };
            FaceDumbRule  rule  = workPart.ScRuleFactory.CreateRuleFaceDumb(faces);

            SelectionIntentRule[] rules = new SelectionIntentRule[] { rule };
            collector.ReplaceRules(rules, false);
            featureBuilder.FaceToProjectTo.Add(collector);
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.SectionToProject.CleanMappingData();
            featureBuilder.Destroy();
            return((NXOpen.Features.ProjectCurve)feature);
        }
Exemplo n.º 2
0
        internal static Snap.NX.FaceBlend CreateFaceBlend(Snap.NX.Face face1, Snap.NX.Face face2, Snap.Number radius)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.FaceBlendBuilder featureBuilder = workPart.Features.CreateFaceBlendBuilder(null);
            featureBuilder.Tolerance = Globals.DistanceTolerance;
            ScCollector collector = workPart.ScCollectors.CreateCollector();

            NXOpen.Face[]   boundaryFaces = new NXOpen.Face[0];
            FaceTangentRule rule          = workPart.ScRuleFactory.CreateRuleFaceTangent((NXOpen.Face)face1, boundaryFaces, 0.5);

            SelectionIntentRule[] rules = new SelectionIntentRule[] { rule };
            collector.ReplaceRules(rules, false);
            featureBuilder.FirstFaceCollector     = collector;
            featureBuilder.ReverseFirstFaceNormal = true;
            ScCollector collector2 = workPart.ScCollectors.CreateCollector();

            NXOpen.Face[]   faceArray2 = new NXOpen.Face[0];
            FaceTangentRule rule2      = workPart.ScRuleFactory.CreateRuleFaceTangent((NXOpen.Face)face2, faceArray2, 0.5);

            SelectionIntentRule[] ruleArray2 = new SelectionIntentRule[] { rule2 };
            collector2.ReplaceRules(ruleArray2, false);
            featureBuilder.SecondFaceCollector     = collector2;
            featureBuilder.ReverseSecondFaceNormal = true;
            featureBuilder.CircularCrossSection.SetRadius(radius.ToString());
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            return((NXOpen.Features.FaceBlend)feature);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 创建镜像几何体
        /// </summary>
        public static Body Geomcopy(NXOpen.Part workPart, NXOpen.Body body, NXOpen.Plane plane)
        {
            NXOpen.Features.Feature         nullFeatures_Feature = null;
            NXOpen.Features.GeomcopyBuilder geomcopyBuilder1;
            geomcopyBuilder1 = workPart.Features.CreateGeomcopyBuilder(nullFeatures_Feature);

            //选择对象
            geomcopyBuilder1.GeometryToInstance.Add(body);

            //选择平面
            geomcopyBuilder1.MirrorPlane = plane;

            geomcopyBuilder1.Type = NXOpen.Features.GeomcopyBuilder.TransformTypes.Mirror;

            Geomcopy feature1;

            feature1 = geomcopyBuilder1.CommitFeature() as Geomcopy;
            geomcopyBuilder1.Destroy();
            var b = feature1.GetBodies().FirstOrDefault();

            RemoveParameters(new List <Body> {
                b
            });
            return(b);
        }
Exemplo n.º 4
0
        internal static Snap.NX.Chamfer CreateChamfer(Snap.NX.Edge edge, Snap.Number distance1, Snap.Number distance2, bool offsetFaces)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.ChamferBuilder featureBuilder = workPart.Features.CreateChamferBuilder(null);
            featureBuilder.Option = NXOpen.Features.ChamferBuilder.ChamferOption.TwoOffsets;
            if (offsetFaces)
            {
                featureBuilder.Method = NXOpen.Features.ChamferBuilder.OffsetMethod.FacesAndTrim;
            }
            else
            {
                featureBuilder.Method = NXOpen.Features.ChamferBuilder.OffsetMethod.EdgesAlongFaces;
            }
            featureBuilder.FirstOffset  = distance1.ToString();
            featureBuilder.SecondOffset = distance2.ToString();
            //featureBuilder.Tolerance = Globals.DistanceTolerance;
            ScCollector     collector = workPart.ScCollectors.CreateCollector();
            EdgeTangentRule rule      = workPart.ScRuleFactory.CreateRuleEdgeTangent((NXOpen.Edge)edge, null, false, Globals.AngleTolerance, false, false);

            SelectionIntentRule[] rules = new SelectionIntentRule[] { rule };
            collector.ReplaceRules(rules, false);
            featureBuilder.SmartCollector = collector;
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            return((NXOpen.Features.Chamfer)feature);
        }
Exemplo n.º 5
0
        internal static Snap.NX.EdgeBlend CreateEdgeBlend(Snap.Number radius, Snap.NX.Edge[] edges)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.EdgeBlendBuilder featureBuilder = workPart.Features.CreateEdgeBlendBuilder(null);
            BlendLimitsData limitsListData = featureBuilder.LimitsListData;
            ScCollector     collector      = workPart.ScCollectors.CreateCollector();

            NXOpen.Edge[] seedEdges = new NXOpen.Edge[edges.Length];
            for (int i = 0; i < seedEdges.Length; i++)
            {
                seedEdges[i] = (NXOpen.Edge)edges[i];
            }
            EdgeMultipleSeedTangentRule rule = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges, Globals.AngleTolerance, true);

            SelectionIntentRule[] rules = new SelectionIntentRule[] { rule };
            collector.ReplaceRules(rules, false);
            featureBuilder.Tolerance              = Globals.DistanceTolerance;
            featureBuilder.AllInstancesOption     = false;
            featureBuilder.RemoveSelfIntersection = true;
            featureBuilder.ConvexConcaveY         = false;
            featureBuilder.RollOverSmoothEdge     = true;
            featureBuilder.RollOntoEdge           = true;
            featureBuilder.MoveSharpEdge          = true;
            featureBuilder.TrimmingOption         = false;
            featureBuilder.OverlapOption          = NXOpen.Features.EdgeBlendBuilder.Overlap.AnyConvexityRollOver;
            featureBuilder.BlendOrder             = NXOpen.Features.EdgeBlendBuilder.OrderOfBlending.ConvexFirst;
            featureBuilder.SetbackOption          = NXOpen.Features.EdgeBlendBuilder.Setback.SeparateFromCorner;
            featureBuilder.AddChainset(collector, radius.ToString());
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            return((NXOpen.Features.EdgeBlend)feature);
        }
Exemplo n.º 6
0
        internal Body(NXOpen.Features.Feature feature) : base(feature)
        {
            Tag tag2;
            Tag tag = feature.Tag;

            Globals.UFSession.Modl.AskFeatBody(tag, out tag2);
            NXOpen.Body objectFromTag = (NXOpen.Body)Snap.NX.NXObject.GetObjectFromTag(tag2);
            this.NXOpenBody = objectFromTag;
        }
Exemplo n.º 7
0
 public static Snap.NX.Feature Wrap(Tag nxopenFeatureTag)
 {
     if (nxopenFeatureTag == Tag.Null)
     {
         throw new ArgumentException("Input tag is NXOpen.Tag.Null");
     }
     NXOpen.Features.Feature objectFromTag = Snap.NX.NXObject.GetObjectFromTag(nxopenFeatureTag) as NXOpen.Features.Feature;
     if (objectFromTag == null)
     {
         throw new ArgumentException("Input tag doesn't belong to an NXOpen.Features.Feature object");
     }
     return(objectFromTag);
 }
Exemplo n.º 8
0
 internal static Snap.NX.DatumAxis CreateDatumAxis(Snap.Position startPoint, Snap.Position endPoint)
 {
     NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
     NXOpen.Features.DatumAxisBuilder featureBuilder = workPart.Features.CreateDatumAxisBuilder(null);
     featureBuilder.Type           = NXOpen.Features.DatumAxisBuilder.Types.TwoPoints;
     featureBuilder.IsAssociative  = true;
     featureBuilder.IsAxisReversed = false;
     featureBuilder.Point1         = workPart.Points.CreatePoint((Point3d)startPoint);
     featureBuilder.Point2         = workPart.Points.CreatePoint((Point3d)endPoint);
     NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
     featureBuilder.Destroy();
     return(new Snap.NX.DatumAxis((DatumAxisFeature)feature));
 }
Exemplo n.º 9
0
 internal static Snap.NX.DatumAxis CreateDatumAxis(Snap.Position origin, Vector direction)
 {
     NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
     NXOpen.Features.DatumAxisBuilder featureBuilder = workPart.Features.CreateDatumAxisBuilder(null);
     featureBuilder.Type = NXOpen.Features.DatumAxisBuilder.Types.PointAndDir;
     NXOpen.Direction direction2 = workPart.Directions.CreateDirection((Point3d)origin, (Vector3d)direction, SmartObject.UpdateOption.WithinModeling);
     featureBuilder.IsAssociative  = true;
     featureBuilder.IsAxisReversed = false;
     featureBuilder.Vector         = direction2;
     featureBuilder.Point          = workPart.Points.CreatePoint((Point3d)origin);
     NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
     featureBuilder.Destroy();
     return(new Snap.NX.DatumAxis((DatumAxisFeature)feature));
 }
Exemplo n.º 10
0
 internal static Snap.NX.OffsetCurve CreateOffsetLine(Snap.NX.ICurve icurve, Snap.NX.Point point, string distance, bool reverseDirection)
 {
     NXOpen.Features.OffsetCurveBuilder featureBuilder = Globals.WorkPart.NXOpenPart.Features.CreateOffsetCurveBuilder(null);
     featureBuilder.Type = NXOpen.Features.OffsetCurveBuilder.Types.Distance;
     featureBuilder.InputCurvesOptions.InputCurveOption = CurveOptions.InputCurve.Retain;
     featureBuilder.Tolerance = Globals.DistanceTolerance;
     featureBuilder.OffsetDistance.RightHandSide = distance;
     featureBuilder.ReverseDirection             = reverseDirection;
     featureBuilder.PointOnOffsetPlane           = (NXOpen.Point)point;
     ((Snap.NX.Section)featureBuilder.CurvesToOffset).AddICurve(new Snap.NX.ICurve[] { icurve });
     NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
     featureBuilder.CurvesToOffset.CleanMappingData();
     featureBuilder.Destroy();
     return(feature as NXOpen.Features.OffsetCurve);
 }
Exemplo n.º 11
0
 internal static Snap.NX.OffsetCurve CreateOffsetCurve(Snap.NX.ICurve[] curves, Snap.Number height, Snap.Number angle, Position helpPoint, Vector helpVector)
 {
     NXOpen.Features.OffsetCurveBuilder builder = Globals.WorkPart.NXOpenPart.Features.CreateOffsetCurveBuilder(null);
     builder.Type = NXOpen.Features.OffsetCurveBuilder.Types.Draft;
     builder.InputCurvesOptions.InputCurveOption = CurveOptions.InputCurve.Retain;
     builder.Tolerance = Globals.DistanceTolerance;
     builder.DraftHeight.RightHandSide = height.ToString();
     builder.DraftAngle.RightHandSide  = angle.ToString();
     ((Snap.NX.Section)builder.CurvesToOffset).AddICurve(curves);
     builder.ReverseDirection = IsReverseDirection(builder, curves, helpPoint, helpVector);
     NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(builder);
     builder.CurvesToOffset.CleanMappingData();
     builder.Destroy();
     return(feature as NXOpen.Features.OffsetCurve);
 }
Exemplo n.º 12
0
 internal static Snap.NX.DatumAxis CreateDatumAxis(Snap.NX.ICurve icurve, Snap.Number arcLength, CurveOrientations curveOrientation)
 {
     NXOpen.Features.DatumAxisBuilder featureBuilder = Globals.WorkPart.NXOpenPart.Features.CreateDatumAxisBuilder(null);
     featureBuilder.Type = NXOpen.Features.DatumAxisBuilder.Types.OnCurveVector;
     featureBuilder.ArcLength.IsPercentUsed            = true;
     featureBuilder.ArcLength.Expression.RightHandSide = arcLength.ToString();
     featureBuilder.CurveOrientation     = (NXOpen.Features.DatumAxisBuilder.CurveOrientations)curveOrientation;
     featureBuilder.IsAssociative        = true;
     featureBuilder.IsAxisReversed       = false;
     featureBuilder.Curve.Value          = icurve.NXOpenICurve;
     featureBuilder.ArcLength.Path.Value = icurve.NXOpenTaggedObject;
     featureBuilder.ArcLength.Update(OnPathDimensionBuilder.UpdateReason.Path);
     NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
     featureBuilder.Destroy();
     return(new Snap.NX.DatumAxis((DatumAxisFeature)feature));
 }
Exemplo n.º 13
0
 internal static Snap.NX.OffsetCurve CreateOffsetCurve(Snap.NX.ICurve[] curves, Snap.Number distance, Position helpPoint, Vector helpVector)
 {
     NXOpen.Features.OffsetCurveBuilder builder = Globals.WorkPart.NXOpenPart.Features.CreateOffsetCurveBuilder(null);
     builder.Type = NXOpen.Features.OffsetCurveBuilder.Types.Distance;
     builder.InputCurvesOptions.InputCurveOption = CurveOptions.InputCurve.Retain;
     builder.Tolerance = Globals.DistanceTolerance;
     //builder.CurveFitData.AngleTolerance = Globals.AngleTolerance;
     builder.CurvesToOffset.SetAllowedEntityTypes(NXOpen.SectionEx.AllowTypes.OnlyCurves);
     builder.CurvesToOffset.AllowSelfIntersection(true);
     builder.OffsetDistance.RightHandSide = distance.ToString();
     ((Snap.NX.Section)builder.CurvesToOffset).AddICurve(curves);
     builder.ReverseDirection = IsReverseDirection(builder, curves, helpPoint, helpVector);
     NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(builder);
     builder.Destroy();
     return(feature as NXOpen.Features.OffsetCurve);
 }
Exemplo n.º 14
0
        /// <summary>
        /// 创建拉伸体
        /// </summary>
        public static Extrude Extrude(Snap.NX.Face face, double height)
        {
            var     curves      = face.EdgeCurves;
            Session theSession  = Session.GetSession();
            Part    workPart    = theSession.Parts.Work;
            Part    displayPart = theSession.Parts.Display;

            var normal = face.Normal(face.BoxUV.MinU, face.BoxUV.MinV);
            var point  = face.Position(face.BoxUV.MinU, face.BoxUV.MinV);

            var curveList = new List <NXOpen.Curve>();

            curves.ToList().ForEach(u =>
            {
                curveList.Add(u);
            });

            //创建拉伸
            NXOpen.Features.Feature nullFeatures_Feature = null;
            ExtrudeBuilder          extrudeBuilder1;

            extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(nullFeatures_Feature);

            //方向
            extrudeBuilder1.Direction = workPart.Directions.CreateDirection(point, normal, SmartObject.UpdateOption.WithinModeling);

            //曲面
            Section section1;

            section1 = workPart.Sections.CreateSection();
            extrudeBuilder1.Section = section1;
            var curveDumbRule1 = workPart.ScRuleFactory.CreateRuleCurveDumb(curveList.ToArray());

            SelectionIntentRule[] rules1 = new SelectionIntentRule[1];
            rules1[0] = curveDumbRule1;
            section1.AddToSection(rules1, curves.FirstOrDefault(), null, null, new Point3d(), NXOpen.Section.Mode.Create);

            //开始值、结束值
            extrudeBuilder1.Limits.StartExtend.Value.Value = 0;
            extrudeBuilder1.Limits.EndExtend.Value.Value   = height;

            Extrude feature1;

            feature1 = (Extrude)extrudeBuilder1.CommitFeature();
            extrudeBuilder1.Destroy();
            return(feature1);
        }
Exemplo n.º 15
0
        internal static Snap.NX.ProjectCurve CreateProjectCurve2(Snap.NX.Curve[] curves, Snap.NX.Point[] points, Snap.NX.Face face)
        {
            NXOpen.Part work = Globals.Session.Parts.Work;
            NXOpen.Features.ProjectCurveBuilder featureBuilder = work.Features.CreateProjectCurveBuilder(null);
            featureBuilder.CurveFitData.Tolerance = Globals.DistanceTolerance;
            featureBuilder.AngleToProjectionVector.RightHandSide = "0";
            featureBuilder.SectionToProject.DistanceTolerance    = Globals.DistanceTolerance;
            featureBuilder.SectionToProject.ChainingTolerance    = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
            featureBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.CurvesAndPoints);
            if (curves != null)
            {
                Snap.NX.Section sectionToProject = featureBuilder.SectionToProject;
                for (int i = 0; i < curves.Length; i++)
                {
                    sectionToProject.AddICurve(new Snap.NX.ICurve[] { curves[i] });
                }
            }
            if (points != null)
            {
                NXOpen.Point[] pointArray = new NXOpen.Point[points.Length];
                for (int j = 0; j < pointArray.Length; j++)
                {
                    pointArray[j] = (NXOpen.Point)points[j];
                }
                CurveDumbRule rule = work.ScRuleFactory.CreateRuleCurveDumbFromPoints(pointArray);
                featureBuilder.SectionToProject.AllowSelfIntersection(true);
                SelectionIntentRule[] ruleArray = new SelectionIntentRule[] { rule };
                Point3d helpPoint = new Point3d(0.0, 0.0, 0.0);
                featureBuilder.SectionToProject.AddToSection(ruleArray, null, null, null, helpPoint, NXOpen.Section.Mode.Create, false);
            }
            ScCollector collector = work.ScCollectors.CreateCollector();

            NXOpen.Face[] faces = new NXOpen.Face[] { face };
            FaceDumbRule  rule2 = work.ScRuleFactory.CreateRuleFaceDumb(faces);

            SelectionIntentRule[] rules = new SelectionIntentRule[] { rule2 };
            collector.ReplaceRules(rules, false);
            featureBuilder.FaceToProjectTo.Add(collector);
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.SectionToProject.CleanMappingData();
            featureBuilder.Destroy();
            return((NXOpen.Features.ProjectCurve)feature);
        }
Exemplo n.º 16
0
 internal static Snap.NX.OffsetCurve CreateOffsetCurve(Snap.NX.ICurve[] icurves, Snap.Number height, Snap.Number angle, bool reverseDirection)
 {
     NXOpen.Features.OffsetCurveBuilder featureBuilder = Globals.WorkPart.NXOpenPart.Features.CreateOffsetCurveBuilder(null);
     featureBuilder.Type = NXOpen.Features.OffsetCurveBuilder.Types.Draft;
     featureBuilder.InputCurvesOptions.InputCurveOption = CurveOptions.InputCurve.Retain;
     featureBuilder.Tolerance = Globals.DistanceTolerance;
     featureBuilder.DraftHeight.RightHandSide = height.ToString();
     featureBuilder.DraftAngle.RightHandSide  = angle.ToString();
     featureBuilder.ReverseDirection          = reverseDirection;
     Snap.NX.Section curvesToOffset = featureBuilder.CurvesToOffset;
     for (int i = 0; i < icurves.Length; i++)
     {
         curvesToOffset.AddICurve(icurves);
     }
     NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
     featureBuilder.CurvesToOffset.CleanMappingData();
     featureBuilder.Destroy();
     return(feature as NXOpen.Features.OffsetCurve);
 }
Exemplo n.º 17
0
        internal static Snap.NX.Chamfer CreateChamfer(Snap.NX.Edge edge, Snap.Number distance, Snap.Number angle)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.ChamferBuilder featureBuilder = workPart.Features.CreateChamferBuilder(null);
            featureBuilder.Option      = NXOpen.Features.ChamferBuilder.ChamferOption.OffsetAndAngle;
            featureBuilder.FirstOffset = distance.ToString();
            featureBuilder.Angle       = angle.ToString();
            //featureBuilder.Tolerance = Globals.DistanceTolerance;
            ScCollector     collector = workPart.ScCollectors.CreateCollector();
            EdgeTangentRule rule      = workPart.ScRuleFactory.CreateRuleEdgeTangent((NXOpen.Edge)edge, null, true, Globals.AngleTolerance, false, false);

            SelectionIntentRule[] rules = new SelectionIntentRule[] { rule };
            collector.ReplaceRules(rules, false);
            featureBuilder.SmartCollector = collector;
            featureBuilder.AllInstances   = false;
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            return((NXOpen.Features.Chamfer)feature);
        }
Exemplo n.º 18
0
        internal static Snap.NX.ProjectCurve CreateProjectCurve2(Snap.NX.DatumPlane datumPlane, Snap.NX.Curve[] curves, Snap.NX.Point[] points)
        {
            NXOpen.Part work = Globals.Session.Parts.Work;
            NXOpen.Features.ProjectCurveBuilder featureBuilder = work.Features.CreateProjectCurveBuilder(null);
            //featureBuilder.CurveFitData.Tolerance = Globals.DistanceTolerance;
            featureBuilder.Tolerance = Globals.DistanceTolerance;
            featureBuilder.AngleToProjectionVector.RightHandSide = "0";
            featureBuilder.SectionToProject.DistanceTolerance    = Globals.DistanceTolerance;
            featureBuilder.SectionToProject.ChainingTolerance    = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
            featureBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.SectionEx.AllowTypes.CurvesAndPoints);
            if (curves != null)
            {
                Snap.NX.Section sectionToProject = featureBuilder.SectionToProject;
                for (int i = 0; i < curves.Length; i++)
                {
                    sectionToProject.AddICurve(new Snap.NX.ICurve[] { curves[i] });
                }
            }
            if (points != null)
            {
                NXOpen.Point[] pointArray = new NXOpen.Point[points.Length];
                for (int j = 0; j < pointArray.Length; j++)
                {
                    pointArray[j] = (NXOpen.Point)points[j];
                }
                CurveDumbRule rule = work.ScRuleFactory.CreateRuleCurveDumbFromPoints(pointArray);
                featureBuilder.SectionToProject.AllowSelfIntersection(true);
                SelectionIntentRule[] rules = new SelectionIntentRule[] { rule };
                Point3d helpPoint           = new Point3d(0.0, 0.0, 0.0);
                featureBuilder.SectionToProject.AddToSection(rules, null, null, null, helpPoint, NXOpen.Section.Mode.Create, false);
            }
            Position origin = datumPlane.Origin;
            Vector   normal = datumPlane.Normal;

            NXOpen.Plane plane = Globals.NXOpenWorkPart.Planes.CreatePlane((Point3d)origin, (Vector3d)normal, SmartObject.UpdateOption.WithinModeling);
            featureBuilder.PlaneToProjectTo = plane;
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.SectionToProject.CleanMappingData();
            featureBuilder.Destroy();
            return((NXOpen.Features.ProjectCurve)feature);
        }
Exemplo n.º 19
0
        internal static Snap.NX.ProjectCurve CreateProjectCurve(Snap.NX.Curve[] curves, Snap.NX.Point[] points, Snap.NX.DatumPlane datumPlane)
        {
            NXOpen.Features.ProjectCurveBuilder featureBuilder = Globals.WorkPart.NXOpenPart.Features.CreateProjectCurveBuilder(null);
            featureBuilder.CurveFitData.Tolerance = Globals.DistanceTolerance;
            featureBuilder.AngleToProjectionVector.RightHandSide = "0";
            featureBuilder.SectionToProject.DistanceTolerance    = Globals.DistanceTolerance;
            featureBuilder.SectionToProject.ChainingTolerance    = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
            featureBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.CurvesAndPoints);
            Snap.NX.Section sectionToProject = featureBuilder.SectionToProject;
            sectionToProject.AddICurve(curves);
            sectionToProject.AddPoints(points);
            Position origin = datumPlane.Origin;
            Vector   normal = datumPlane.Normal;

            NXOpen.Plane plane = Globals.NXOpenWorkPart.Planes.CreatePlane((Point3d)origin, (Vector3d)normal, SmartObject.UpdateOption.WithinModeling);
            featureBuilder.PlaneToProjectTo = plane;
            NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.SectionToProject.CleanMappingData();
            featureBuilder.Destroy();
            return((NXOpen.Features.ProjectCurve)feature);
        }
Exemplo n.º 20
0
        internal static ObjectTypes.Type GetTypeFromTag(Tag nxopenTag)
        {
            int num;
            int num2;

            Globals.UFSession.Obj.AskTypeAndSubtype(nxopenTag, out num, out num2);
            ObjectTypes.Type body = (ObjectTypes.Type)num;
            if (num == 70)
            {
                switch (num2)
                {
                case 0:
                    body = ObjectTypes.Type.Body;
                    break;

                case 2:
                    body = ObjectTypes.Type.Face;
                    break;

                case 3:
                    body = ObjectTypes.Type.Edge;
                    break;
                }
            }
            if (num == 0xcd)
            {
                NXOpen.Features.Feature objectFromTag = (NXOpen.Features.Feature)GetObjectFromTag(nxopenTag);
                if (objectFromTag is DatumAxisFeature)
                {
                    body = ObjectTypes.Type.DatumAxis;
                }
                if (objectFromTag is DatumPlaneFeature)
                {
                    body = ObjectTypes.Type.DatumPlane;
                }
            }
            return(body);
        }
Exemplo n.º 21
0
 internal static Snap.NX.OffsetCurve CreateOffsetCurve(Snap.NX.ICurve[] curves, Snap.Number distance, bool reverseDirection)
 {
     NXOpen.Features.OffsetCurveBuilder featureBuilder = Globals.WorkPart.NXOpenPart.Features.CreateOffsetCurveBuilder(null);
     featureBuilder.Type = NXOpen.Features.OffsetCurveBuilder.Types.Distance;
     featureBuilder.InputCurvesOptions.InputCurveOption = CurveOptions.InputCurve.Retain;
     featureBuilder.Tolerance  = Globals.DistanceTolerance;
     featureBuilder.TrimMethod = NXOpen.Features.OffsetCurveBuilder.TrimOption.ExtendTangents;
     featureBuilder.CurvesToOffset.DistanceTolerance = Globals.DistanceTolerance;
     featureBuilder.CurvesToOffset.AngleTolerance    = Globals.AngleTolerance;
     featureBuilder.CurvesToOffset.ChainingTolerance = (Globals.UnitType == Globals.Unit.Millimeter) ? 0.02413 : 0.00095;
     featureBuilder.CurvesToOffset.SetAllowedEntityTypes(NXOpen.SectionEx.AllowTypes.OnlyCurves);
     featureBuilder.CurvesToOffset.AllowSelfIntersection(true);
     featureBuilder.OffsetDistance.RightHandSide = distance.ToString();
     featureBuilder.ReverseDirection             = reverseDirection;
     Snap.NX.Section curvesToOffset = featureBuilder.CurvesToOffset;
     for (int i = 0; i < curves.Length; i++)
     {
         curvesToOffset.AddICurve(curves);
     }
     NXOpen.Features.Feature feature = (NXOpen.Features.Feature)Snap.NX.Feature.CommitFeature(featureBuilder);
     featureBuilder.Destroy();
     return(feature as NXOpen.Features.OffsetCurve);
 }
Exemplo n.º 22
0
 internal static Snap.NX.Feature CreateFeature(NXOpen.Features.Feature nxopenFeature)
 {
     if (nxopenFeature == null)
     {
         return(null);
     }
     if (nxopenFeature is NXOpen.Features.Block)
     {
         return(new Snap.NX.Block((NXOpen.Features.Block)nxopenFeature));
     }
     if (nxopenFeature is BooleanFeature)
     {
         return(new Snap.NX.Boolean((BooleanFeature)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.BoundedPlane)
     {
         return(new Snap.NX.BoundedPlane((NXOpen.Features.BoundedPlane)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.Chamfer)
     {
         return(new Snap.NX.Chamfer((NXOpen.Features.Chamfer)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.Cone)
     {
         return(new Snap.NX.Cone((NXOpen.Features.Cone)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.Cylinder)
     {
         return(new Snap.NX.Cylinder((NXOpen.Features.Cylinder)nxopenFeature));
     }
     if (nxopenFeature is DatumAxisFeature)
     {
         return(new Snap.NX.DatumAxis((DatumAxisFeature)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.DatumCsys)
     {
         return(new Snap.NX.DatumCsys((NXOpen.Features.DatumCsys)nxopenFeature));
     }
     if (nxopenFeature is DatumPlaneFeature)
     {
         return(new Snap.NX.DatumPlane((DatumPlaneFeature)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.EdgeBlend)
     {
         return(new Snap.NX.EdgeBlend((NXOpen.Features.EdgeBlend)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.ExtractFace)
     {
         return(new Snap.NX.ExtractFace((NXOpen.Features.ExtractFace)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.Extrude)
     {
         return(new Snap.NX.Extrude((NXOpen.Features.Extrude)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.FaceBlend)
     {
         return(new Snap.NX.FaceBlend((NXOpen.Features.FaceBlend)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.OffsetCurve)
     {
         return(new Snap.NX.OffsetCurve((NXOpen.Features.OffsetCurve)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.OffsetFace)
     {
         return(new Snap.NX.OffsetFace((NXOpen.Features.OffsetFace)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.ProjectCurve)
     {
         return(new Snap.NX.ProjectCurve((NXOpen.Features.ProjectCurve)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.Revolve)
     {
         Snap.NX.Revolve revolve = new Snap.NX.Revolve((NXOpen.Features.Revolve)nxopenFeature);
         Snap.NX.Face[]  faces   = revolve.Faces;
         if (((faces != null) && (faces.Length == 1)) && (faces[0].ObjectSubType == ObjectTypes.SubType.FaceTorus))
         {
             return(new Snap.NX.Torus((NXOpen.Features.Revolve)nxopenFeature));
         }
         return(revolve);
     }
     if (nxopenFeature is NXOpen.Features.Ruled)
     {
         return(new Snap.NX.Ruled((NXOpen.Features.Ruled)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.Sew)
     {
         return(new Snap.NX.Sew((NXOpen.Features.Sew)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.Sphere)
     {
         return(new Snap.NX.Sphere((NXOpen.Features.Sphere)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.SplitBody)
     {
         return(new Snap.NX.SplitBody((NXOpen.Features.SplitBody)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.TrimBody)
     {
         return(new Snap.NX.TrimBody((NXOpen.Features.TrimBody)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.Thicken)
     {
         return(new Snap.NX.Thicken((NXOpen.Features.Thicken)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.ThroughCurveMesh)
     {
         return(new Snap.NX.ThroughCurveMesh((NXOpen.Features.ThroughCurveMesh)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.ThroughCurves)
     {
         return(new Snap.NX.ThroughCurves((NXOpen.Features.ThroughCurves)nxopenFeature));
     }
     if (nxopenFeature is NXOpen.Features.Tube)
     {
         return(new Snap.NX.Tube((NXOpen.Features.Tube)nxopenFeature));
     }
     return(new Snap.NX.Feature(nxopenFeature));
 }
Exemplo n.º 23
0
 internal Feature(NXOpen.Features.Feature feature) : base(feature)
 {
     this.NXOpenFeature = feature;
 }
    //------------------------------------------------------------------------------
    // Callback Name: apply_cb
    // Following callback is associated with the "changeDialog" Styler item.
    // Input: eventObject - object of UIStyler.StylerEvent class
    //------------------------------------------------------------------------------
    //Following is Apply Callback - This function is responsible for creating Edge Blend.
    public NXOpen.UIStyler.DialogState apply_cb(NXOpen.UIStyler.StylerEvent eventObject)
    {
        try
        {
            Part workPart    = theSession.Parts.Work;
            Part displayPart = theSession.Parts.Display;

            // ----------------------------------------------
            //   Menu: Insert->Detail Feature->Edge Blend...
            // ----------------------------------------------
            Session.UndoMarkId      markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start");
            NXOpen.Features.Feature nullFeatures_Feature = null;

            NXOpen.Features.EdgeBlendBuilder edgeBlendBuilder1 = workPart.Features.CreateEdgeBlendBuilder(nullFeatures_Feature);

            theSession.SetUndoMarkName(markId1, "Edge Blend");
            Boolean featureAlerts1 = theSession.Preferences.Modeling.FeatureAlerts;

            ScCollector scCollector1 = workPart.ScCollectors.CreateCollector();

            NXOpen.Features.Block block1 = (NXOpen.Features.Block)workPart.Features.FindObject("BLOCK(1)");

            Boolean featureAlerts2 = theSession.Preferences.Modeling.FeatureAlerts;
            Boolean featureAlerts3 = theSession.Preferences.Modeling.FeatureAlerts;

            Edge[] seedEdges1        = new Edge[htEdges.Count];
            IDictionaryEnumerator en = htEdges.GetEnumerator();
            int EdgeIndex            = 0;
            while (en.MoveNext())
            {
                Edge edgeVar = (Edge)en.Value;;
                seedEdges1[EdgeIndex] = edgeVar;
                EdgeIndex            += 1;
            }

            EdgeMultipleSeedTangentRule edgeMultipleSeedTangentRule2 = workPart.ScRuleFactory.CreateRuleEdgeMultipleSeedTangent(seedEdges1, 0.5, true);

            SelectionIntentRule[] rules2 = new SelectionIntentRule[1];
            rules2[0] = edgeMultipleSeedTangentRule2;

            scCollector1.ReplaceRules(rules2, false);
            Boolean featureAlerts4 = theSession.Preferences.Modeling.FeatureAlerts;

            Boolean            featureAlerts5 = theSession.Preferences.Modeling.FeatureAlerts;
            Session.UndoMarkId markId2        = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Edge Blend");
            //Following can set the Tolerance for Edge Blend.
            edgeBlendBuilder1.Tolerance          = changeReal6.ItemValue;
            edgeBlendBuilder1.AllInstancesOption = false;
            //Following can set the Remove Self Intersection option for the Edge Blend.
            edgeBlendBuilder1.RemoveSelfIntersection = changeToggle6.ItemValue;
            edgeBlendBuilder1.ConvexConcaveY         = false;
            edgeBlendBuilder1.RollOverSmoothEdge     = true;
            edgeBlendBuilder1.RollOntoEdge           = true;
            edgeBlendBuilder1.MoveSharpEdge          = true;
            edgeBlendBuilder1.OverlapOption          = NXOpen.Features.EdgeBlendBuilder.Overlap.AnyConvexityRollOver;
            edgeBlendBuilder1.BlendOrder             = NXOpen.Features.EdgeBlendBuilder.OrderOfBlending.ConvexFirst;
            edgeBlendBuilder1.SetbackOption          = NXOpen.Features.EdgeBlendBuilder.Setback.SeparateFromCorner;

            //Following sets the value for Blend Radius.
            int csIndex1 = edgeBlendBuilder1.AddChainset(scCollector1, changeStr0.ItemValue);
            NXOpen.Features.Feature feature1 = edgeBlendBuilder1.CommitFeature();

            theSession.DeleteUndoMark(markId2, null);
            edgeBlendBuilder1.Destroy();
            htEdges.Clear();
            changeLabel1.SetLabel("Select Edges (0)");
        }
        catch (NXOpen.NXException ex)
        {
            // ---- Enter your exception handling code here -----
            theUI.NXMessageBox.Show("UI Styler", NXMessageBox.DialogType.Error, ex.Message);
        }
        // Callback acknowledged, do not terminate dialog
        // A return value of NXOpen.UIStyler.DialogState.ExitDialog will not be accepted
        // for this callback type. You must respond to your apply button.
        return(NXOpen.UIStyler.DialogState.ContinueDialog);
    }
Exemplo n.º 25
0
 internal Chamfer(NXOpen.Features.Feature chamfer) : base(chamfer)
 {
     this.NXOpenChamfer = chamfer;
 }