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); }
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); }
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); }
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); }
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); }
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); }