Esempio n. 1
0
        /// <summary>
        /// 投影曲线
        /// </summary>
        /// <param name="features"></param>
        /// <param name="curves">要投影的曲线</param>
        /// <param name="originPoint">投影平面原点</param>
        /// <param name="normal">投影方向</param>
        /// <returns></returns>
        public static ProjectCurve CreateProjectCurve(this FeatureCollection features, IBaseCurve[] curves, Point3d originPoint, Vector3d normal)
        {
            NXOpen.Features.ProjectCurveBuilder projectCurveBuilder = features.CreateProjectCurveBuilder(null);
            Plane plane1 = WorkPart.Planes.CreatePlane(originPoint, normal, NXOpen.SmartObject.UpdateOption.WithinModeling);

            plane1.SetMethod(NXOpen.PlaneTypes.MethodType.Distance);
            plane1.SetFlip(false);
            plane1.SetReverseSide(false);
            plane1.SetAlternate(NXOpen.PlaneTypes.AlternateType.One);
            plane1.Evaluate();
            projectCurveBuilder.PlaneToProjectTo                      = plane1;
            projectCurveBuilder.CurveFitData.Tolerance                = 0.025;
            projectCurveBuilder.CurveFitData.AngleTolerance           = 0.5;
            projectCurveBuilder.ProjectionOption                      = NXOpen.Features.ProjectCurveBuilder.ProjectionOptionType.ProjectBothSides;
            projectCurveBuilder.AngleToProjectionVector.RightHandSide = "0";
            projectCurveBuilder.SectionToProject.DistanceTolerance    = 0.025;
            projectCurveBuilder.SectionToProject.ChainingTolerance    = 0.02375;
            projectCurveBuilder.SectionToProject.AngleTolerance       = 0.5;
            projectCurveBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.CurvesAndPoints);
#if NX12
            CurveDumbRule curveFeatureRule1 = (WorkPart as BasePart).ScRuleFactory.CreateRuleBaseCurveDumb(curves);
#else
            CurveDumbRule curveFeatureRule1 = WorkPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves);
#endif
            projectCurveBuilder.SectionToProject.AllowSelfIntersection(true);
            SelectionIntentRule[] rules1 = new SelectionIntentRule[1] {
                curveFeatureRule1
            };
            Point3d helpPoint1 = new Point3d(1614.13079321387, -713.841520793069, 769.877304064383);
            projectCurveBuilder.SectionToProject.AddToSection(rules1, (NXObject)curves[0], null, null, helpPoint1, NXOpen.Section.Mode.Create, false);
            ProjectCurve projectCurve = (ProjectCurve)projectCurveBuilder.CommitFeature();
            projectCurveBuilder.SectionToProject.CleanMappingData();
            projectCurveBuilder.Destroy();
            return(projectCurve);
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        /// <summary>
        /// 沿面的法向投影曲线
        /// </summary>
        /// <param name="features"></param>
        /// <param name="curves"></param>
        /// <param name="faces_to_project_to"></param>
        /// <returns></returns>
        public static ProjectCurve CreateProjectCurve(this FeatureCollection features, IBaseCurve[] curves, Face[] faces_to_project_to)
        {
            NXOpen.Features.ProjectCurveBuilder projectCurveBuilder = features.CreateProjectCurveBuilder(null);

            projectCurveBuilder.CurveFitData.Tolerance = 0.01;

            projectCurveBuilder.CurveFitData.AngleTolerance = 0.5;

            projectCurveBuilder.ProjectionDirectionMethod = NXOpen.Features.ProjectCurveBuilder.DirectionType.AlongFaceNormal;

            projectCurveBuilder.SectionToProject.DistanceTolerance = 0.01;

            projectCurveBuilder.SectionToProject.ChainingTolerance = 0.0094999999999999998;

            projectCurveBuilder.SectionToProject.AngleTolerance = 0.5;

            projectCurveBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.CurvesAndPoints);

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

            NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1] {
                curveDumbRule
            };
            projectCurveBuilder.SectionToProject.AddToSection(rules1, null, null, null, new Point3d(), NXOpen.Section.Mode.Create, false);

            NXOpen.ScCollector scCollector1 = WorkPart.ScCollectors.CreateCollector();
#if NX12
            NXOpen.FaceDumbRule faceDumbRule = (WorkPart as BasePart).ScRuleFactory.CreateRuleFaceDumb(faces_to_project_to);
#else
            NXOpen.FaceDumbRule faceDumbRule = WorkPart.ScRuleFactory.CreateRuleFaceDumb(faces_to_project_to);
#endif
            NXOpen.SelectionIntentRule[] rules2 = new NXOpen.SelectionIntentRule[1] {
                faceDumbRule
            };
            scCollector1.ReplaceRules(rules2, false);

            bool added1 = projectCurveBuilder.FaceToProjectTo.Add(scCollector1);

            ProjectCurve nXObject1 = (ProjectCurve)projectCurveBuilder.Commit();

            projectCurveBuilder.SectionToProject.CleanMappingData();

            projectCurveBuilder.Destroy();

            return(nXObject1);
        }
Esempio n. 4
0
        /// <summary>
        /// 投影点
        /// </summary>
        /// <param name="features"></param>
        /// <param name="point_to_project">要投影的点</param>
        /// <param name="originPoint">投影平面原点</param>
        /// <param name="normal">投影平面方向</param>
        public static ProjectCurve CreateProjectCurve(this FeatureCollection features, Point point_to_project, Point3d originPoint, Vector3d normal)
        {
            NXOpen.Features.ProjectCurveBuilder projectCurveBuilder = features.CreateProjectCurveBuilder(null);

            projectCurveBuilder.CurveFitData.Tolerance = 0.025399999999999999;

            projectCurveBuilder.CurveFitData.AngleTolerance = 0.5;

            projectCurveBuilder.ProjectionDirectionMethod = NXOpen.Features.ProjectCurveBuilder.DirectionType.AlongFaceNormal;

            projectCurveBuilder.AngleToProjectionVector.RightHandSide = "0";

            Plane plane_to_project_to = WorkPart.Planes.CreatePlane(originPoint, normal, NXOpen.SmartObject.UpdateOption.WithinModeling);

            plane_to_project_to.SetMethod(NXOpen.PlaneTypes.MethodType.Distance);
            plane_to_project_to.SetFlip(false);
            plane_to_project_to.SetReverseSide(false);
            plane_to_project_to.SetAlternate(NXOpen.PlaneTypes.AlternateType.One);
            plane_to_project_to.Evaluate();

            projectCurveBuilder.SectionToProject.DistanceTolerance = 0.025399999999999999;

            projectCurveBuilder.SectionToProject.ChainingTolerance = 0.024129999999999999;

            projectCurveBuilder.SectionToProject.AngleTolerance = 0.5;

            projectCurveBuilder.PlaneToProjectTo = plane_to_project_to;

            projectCurveBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.CurvesAndPoints);

#if NX12
            NXOpen.CurveDumbRule curveDumbRule = (WorkPart as BasePart).ScRuleFactory.CreateRuleCurveDumbFromPoints(new Point[] { point_to_project });
#else
            NXOpen.CurveDumbRule curveDumbRule = WorkPart.ScRuleFactory.CreateRuleCurveDumbFromPoints(new Point[] { point_to_project });
#endif
            projectCurveBuilder.SectionToProject.AllowSelfIntersection(true);

            NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1] {
                curveDumbRule
            };
            projectCurveBuilder.SectionToProject.AddToSection(rules1, null, null, null, new Point3d(), NXOpen.Section.Mode.Create, false);

            ProjectCurve projectCurve = (ProjectCurve)projectCurveBuilder.Commit();

            projectCurveBuilder.SectionToProject.CleanMappingData();

            projectCurveBuilder.Destroy();

            return(projectCurve);
        }
Esempio n. 5
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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        /// <summary>
        /// 投影点
        /// </summary>
        /// <param name="features"></param>
        /// <param name="point_to_project">要投影的点</param>
        /// <param name="faces_to_project_to">投影到的面</param>
        /// <param name="project_direction3d">投影方向,正反向均可</param>
        /// <returns></returns>
        public static ProjectCurve CreateProjectCurve(this FeatureCollection features, Point point_to_project, Face[] faces_to_project_to, Vector3d project_direction3d)
        {
            NXOpen.Features.ProjectCurveBuilder projectCurveBuilder = features.CreateProjectCurveBuilder(null);

            projectCurveBuilder.CurveFitData.Tolerance = 0.01;

            projectCurveBuilder.CurveFitData.AngleTolerance = 0.5;

            projectCurveBuilder.ProjectionDirectionMethod = NXOpen.Features.ProjectCurveBuilder.DirectionType.AlongVector;

            projectCurveBuilder.AngleToProjectionVector.RightHandSide = "0";

            projectCurveBuilder.SectionToProject.DistanceTolerance = 0.01;

            projectCurveBuilder.SectionToProject.ChainingTolerance = 0.0095;

            projectCurveBuilder.SectionToProject.AngleTolerance = 0.5;

            projectCurveBuilder.SectionToProject.SetAllowedEntityTypes(NXOpen.Section.AllowTypes.CurvesAndPoints);

#if NX12
            NXOpen.CurveDumbRule curveDumbRule1 = (WorkPart as BasePart).ScRuleFactory.CreateRuleCurveDumbFromPoints(new Point[] { point_to_project });
#else
            NXOpen.CurveDumbRule curveDumbRule1 = WorkPart.ScRuleFactory.CreateRuleCurveDumbFromPoints(new Point[] { point_to_project });
#endif

            projectCurveBuilder.SectionToProject.AllowSelfIntersection(true);

            NXOpen.SelectionIntentRule[] rules1 = new NXOpen.SelectionIntentRule[1] {
                curveDumbRule1
            };
            projectCurveBuilder.SectionToProject.AddToSection(rules1, null, null, null, new Point3d(), NXOpen.Section.Mode.Create, false);

            NXOpen.ScCollector scCollector = WorkPart.ScCollectors.CreateCollector();

#if NX12
            NXOpen.FaceDumbRule faceDumbRule = (WorkPart as BasePart).ScRuleFactory.CreateRuleFaceDumb(faces_to_project_to);
#else
            NXOpen.FaceDumbRule faceDumbRule = WorkPart.ScRuleFactory.CreateRuleFaceDumb(faces_to_project_to);
#endif

            NXOpen.SelectionIntentRule[] rules2 = new NXOpen.SelectionIntentRule[1] {
                faceDumbRule
            };
            scCollector.ReplaceRules(rules2, false);

            bool added1 = projectCurveBuilder.FaceToProjectTo.Add(scCollector);

            NXOpen.Direction direction = WorkPart.Directions.CreateDirection(new Point3d(), project_direction3d, NXOpen.SmartObject.UpdateOption.WithinModeling);

            projectCurveBuilder.ProjectionVector = direction;

            projectCurveBuilder.ProjectionOption = ProjectCurveBuilder.ProjectionOptionType.ProjectBothSides;

            ProjectCurve nXObject = (ProjectCurve)projectCurveBuilder.Commit();

            projectCurveBuilder.SectionToProject.CleanMappingData();

            projectCurveBuilder.Destroy();

            return(nXObject);
        }