private void CreateExtrude(IBaseCurve[] curves, bool add, double distance, Vector3d vector) { SelectionIntentRule[] rules = new SelectionIntentRule[1] { workPart.ScRuleFactory.CreateRuleBaseCurveDumb(curves) }; NXOpen.Features.ExtrudeBuilder extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(null); NXOpen.Section section1 = workPart.Sections.CreateSection(0.0095, 0.01, 0.5); section1.AddToSection(rules, (Curve)curves[0], null, null, new Point3d(0, 0, 0), Section.Mode.Create, false); extrudeBuilder1.Section = section1; if (add) { extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Create; } else { extrudeBuilder1.BooleanOperation.Type = NXOpen.GeometricUtilities.BooleanOperation.BooleanType.Subtract; extrudeBuilder1.BooleanOperation.SetTargetBodies(new Body[1] { workPart.Bodies.ToArray()[0] }); } distance = distance / 2.0; extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = "-" + distance.ToString(); extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = distance.ToString(); NXOpen.Point3d origin1 = new NXOpen.Point3d(0.0, 0, 0); extrudeBuilder1.Direction = workPart.Directions.CreateDirection(origin1, vector, NXOpen.SmartObject.UpdateOption.WithinModeling); extrudeBuilder1.CommitFeature(); extrudeBuilder1.Destroy(); }
internal static Snap.NX.Section CreateSection(params Snap.NX.Point[] points) { NXOpen.Section section = Globals.WorkPart.NXOpenPart.Sections.CreateSection(0.02413, Globals.DistanceTolerance, Globals.AngleTolerance); section.AllowSelfIntersection(false); section.SetAllowedEntityTypes(NXOpen.SectionEx.AllowTypes.CurvesAndPoints); SelectionIntentRule[] rules = CreateSelectionIntentRule(points); section.AddToSection(rules, (NXOpen.NXObject)points[0].NXOpenTaggedObject, null, null, (Point3d)Position.Origin, NXOpen.Section.Mode.Create); return(section); }
internal void AddPoints(params Snap.NX.Point[] points) { if (points != null) { Snap.NX.Part workPart = Globals.WorkPart; NXOpen.Section nXOpenSection = this.NXOpenSection; nXOpenSection.AllowSelfIntersection(false); SelectionIntentRule[] rules = CreateSelectionIntentRule(points); nXOpenSection.AddToSection(rules, (NXOpen.NXObject)points[0].NXOpenTaggedObject, null, null, (Point3d)Position.Origin, NXOpen.Section.Mode.Create, false); } }
internal static Snap.NX.Section CreateSection(params Snap.NX.ICurve[] icurves) { NXOpen.Section section = Globals.WorkPart.NXOpenPart.Sections.CreateSection(0.02413, Globals.DistanceTolerance, Globals.AngleTolerance); section.AllowSelfIntersection(false); section.SetAllowedEntityTypes(NXOpen.SectionEx.AllowTypes.CurvesAndPoints); for (int i = 0; i < icurves.Length; i++) { SelectionIntentRule[] rules = CreateSelectionIntentRule(new Snap.NX.ICurve[] { icurves[i] }); section.AddToSection(rules, (NXOpen.NXObject)icurves[i].NXOpenTaggedObject, null, null, (Point3d)Position.Origin, NXOpen.Section.Mode.Create); } return(section); }
internal void AddICurve(params Snap.NX.ICurve[] icurves) { if (icurves != null) { Snap.NX.Part workPart = Globals.WorkPart; NXOpen.Section nXOpenSection = this.NXOpenSection; nXOpenSection.AllowSelfIntersection(false); for (int i = 0; i < icurves.Length; i++) { SelectionIntentRule[] rules = CreateSelectionIntentRule(new Snap.NX.ICurve[] { icurves[i] }); nXOpenSection.AddToSection(rules, (NXOpen.NXObject)icurves[i].NXOpenTaggedObject, null, null, (Point3d)Position.Origin, NXOpen.Section.Mode.Create, false); } } }
/// <summary> /// 创建拉伸特征 /// </summary> /// <param name="vec">向量</param> /// <param name="start">起始</param> /// <param name="end">终止</param> /// <param name="extrude">lastez</param> /// <param name="line">线</param> /// <returns></returns> public static NXOpen.Features.Feature CreateExtrude(Vector3d vec, string start, string end, NXOpen.Features.Feature extrude = null, params TaggedObject[] line) { Session theSession = Session.GetSession(); Part workPart = theSession.Parts.Work; SelectionRuleFactory rules = new SelectionRuleFactory(line.ToList()); NXOpen.Features.Feature nullNXOpen_Features_Feature = null; NXOpen.Features.ExtrudeBuilder extrudeBuilder1 = workPart.Features.CreateExtrudeBuilder(nullNXOpen_Features_Feature); NXOpen.Section section1 = workPart.Sections.CreateSection(); extrudeBuilder1.Section = section1; extrudeBuilder1.Limits.StartExtend.Value.RightHandSide = start; extrudeBuilder1.Limits.EndExtend.Value.RightHandSide = end; NXOpen.Point3d origin1 = new NXOpen.Point3d(0.0, 0.0, 0.0); NXOpen.Direction direction1; direction1 = workPart.Directions.CreateDirection(origin1, vec, NXOpen.SmartObject.UpdateOption.WithinModeling); NXOpen.NXObject nullNXOpen_NXObject = null; section1.AddToSection(rules.CreateSelectionRule().ToArray(), (NXObject)line[0], nullNXOpen_NXObject, nullNXOpen_NXObject, origin1, NXOpen.Section.Mode.Create, false); extrudeBuilder1.Direction = direction1; NXOpen.Session.UndoMarkId markId = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start Extruded"); try { return(extrudeBuilder1.CommitFeature()); } catch (NXException ex) { LogMgr.WriteLog("ExtrudedUtils:CreateExtruded:" + ex.Message); throw ex; } finally { extrudeBuilder1.Destroy(); theSession.UpdateManager.DoUpdate(markId); theSession.DeleteUndoMark(markId, "End Extruded"); } }