private void ExtractFace(Body toolBody, params Face[] face) { List <Body> bodys = new List <Body>(); try { bodys.AddRange(ExtraetUtils.ExtractFaceBuilder(face)); } catch { foreach (Face fe in face) { bodys.Add(ExtraetUtils.ExtraetFace(fe)); } } foreach (Body by in bodys) { try { Body[] bos = BooleanUtils.CreateBooleanFeature(by, false, true, NXOpen.Features.Feature.BooleanType.Intersect, toolBody).GetBodies(); foreach (Body bd in bos) { bd.Color = 6; bd.Layer = 251; } DeleteObject.DeleteParms(bos); } catch { } } }
/// <summary> /// 求和 /// </summary> /// <param name="body1"></param> /// <param name="bodys"></param> public Body CreateUnite(Body body1, List <Body> bodys, out string errs) { errs = ""; string[] err = null; NXOpen.Features.BooleanFeature bf = null; try { bf = BooleanUtils.CreateBooleanFeature(body1, false, false, NXOpen.Features.Feature.BooleanType.Unite, bodys.ToArray()); err = bf.GetFeatureWarningMessages(); } catch (NXException ex) { throw ex; } if (err != null) { foreach (string str in err) { if (str.Equals("One or more tools did not intersect the target.", StringComparison.CurrentCultureIgnoreCase)) { errs = ("一个或多个工具与目标不相交。"); } } } return(bf.GetBodies()[0]); }
/// <summary> /// 创建布尔减 /// </summary> /// <returns></returns> private NXOpen.Features.BooleanFeature CreateBooleanFeature() { Body toolBody = AskSelectParent(); if (toolBody != null && this.superBox.ToolingBoxFeature != null) { return(BooleanUtils.CreateBooleanFeature(this.superBox.ToolingBoxFeature.GetBodies()[0], false, true, NXOpen.Features.Feature.BooleanType.Subtract, toolBody)); } return(null); }
/// <summary> /// 更新Pitch /// </summary> private bool UpdatePitch() { Part workPart = Session.GetSession().Parts.Work; NXOpen.Features.ExtractFace ext; NXOpen.Features.MoveObject move; NXOpen.Features.PatternGeometry patt; List <Body> bodys = new List <Body>(); Body boolBody; List <NXOpen.Features.BooleanFeature> extBools; GetExtrudeBooleanBody(out boolBody, out extBools); GetFeature(out ext, out move, out patt); if (ext == null || move == null || patt == null || boolBody == null) { return(false); } if (extBools.Count > 0) { DeleteObject.Delete(extBools.ToArray()); } bodys.AddRange(ext.GetBodies()); bodys.AddRange(patt.GetAssociatedBodies()); try { MoveObject.CreateMoveObjToXYZ("moveX", "moveY", "moveZ", move as NXOpen.Features.MoveObject, bodys.ToArray()); } catch (NXException ex) { ClassItem.WriteLogFile("更新移动错误!" + ex.Message); return(false); } List <Body> bys = eleModel.PartTag.Bodies.ToArray().ToList(); bys.Remove(boolBody); SetHeadColour(newAllInfo.Pitch, newAllInfo.GapValue, bys); try { PartUtils.SetPartWork(AssmbliesUtils.GetPartComp(asm, eleModel.PartTag)[0]); Body elebody = BooleanUtils.CreateBooleanFeature(boolBody, false, false, NXOpen.Features.Feature.BooleanType.Unite, bys.ToArray()).GetBodies()[0]; SetEleColor(elebody); PartUtils.SetPartWork(null); } catch (NXException ex) { ClassItem.WriteLogFile("更新求和错误!" + ex.Message); return(false); } return(true); }
private bool CreateDatum() { Vector3d dir = new Vector3d(0, 0, -1); try { Body body1 = ExtrudeUtils.CreateExtrude(dir, "0", "DatumHeigth", null, sketch.LeiLine.ToArray()).GetBodies()[0]; CreateChamfer(body1.Tag); SetDatumAttr(body1); Body body2 = ExtrudeUtils.CreateExtrude(dir, "DatumHeigth", "extrudePreparation", null, sketch.WaiLine.ToArray()).GetBodies()[0]; this.DatumBody = BooleanUtils.CreateBooleanFeature(body1, false, false, NXOpen.Features.Feature.BooleanType.Unite, body2).GetBodies()[0]; return(true); } catch (NXException ex) { ClassItem.WriteLogFile("创建基准台错误!" + ex.Message); return(false); } }