/// <summary> /// 干涉面 /// </summary> public void GetInterferenceOfFace() { List <Tag> outFace = new List <Tag>(); Body eleBody = GetOccsInBods(this.eleModel.PartTag)[0]; Body workpieceBody = GetOccsInBods(this.workpiece)[0]; List <Face> faces = AnalysisUtils.SetInterferenceOutFace(eleBody, workpieceBody); for (int i = 0; i < (faces.Count) / 2 - 1; i++) { FaceData data1 = FaceUtils.AskFaceData(faces[i * 2]); FaceData data2 = FaceUtils.AskFaceData(faces[i * 2 + 1]); if (data1.Equals(data2)) { Tag face3; NXOpen.Features.Feature feat1 = AssmbliesUtils.WaveFace(faces[i * 2]); NXOpen.Features.Feature feat2 = AssmbliesUtils.WaveFace(faces[i * 2 + 1]); Body[] bodys1 = (feat1 as NXOpen.Features.BodyFeature).GetBodies(); Body[] bodys2 = (feat2 as NXOpen.Features.BodyFeature).GetBodies(); Tag bodyTag1 = Intersect(bodys1[0], bodys2[0]); if (bodyTag1 != Tag.Null) { outFace.Add(bodyTag1); } } } SewSolidBody(outFace); }
public void GetInterferenceOfArea() { Body eleBody = GetOccsInBods(this.eleModel.PartTag)[0]; Body workpieceBody = GetOccsInBods(this.workpiece)[0]; List <Face> faces = AnalysisUtils.SetInterferenceOutFace(eleBody, workpieceBody); double minArea = 0; for (int i = 0; i < (faces.Count) / 2 - 1; i++) { FaceData data1 = FaceUtils.AskFaceData(faces[i * 2]); FaceData data2 = FaceUtils.AskFaceData(faces[i * 2 + 1]); if (data1.Equals(data2)) { double area1 = FaceUtils.GetFaceArea(faces[i * 2]); double area2 = FaceUtils.GetFaceArea(faces[i * 2 + 1]); if (area1 > area2) { minArea += area2; } else { minArea += area1; } } } AttributeUtils.AttributeOperation("Area", minArea, this.eleModel.PartTag); }
/// <summary> ///检查体 /// </summary> /// <returns></returns> public BodyInfo GetBodyInfoForInterference(bool extract, out List <string> err) { err = new List <string>(); List <Face> dischargeFace = new List <Face>(); List <Face> temp = new List <Face>(); List <Body> bodys = new List <Body>(); try { AnalysisUtils.SetInterferenceOutFace(this.eleBody, this.toolBody, out temp, out bodys); } catch (NXException ex) { err.Add("干涉检查错误!" + ex.Message); } if (bodys.Count > 0) { LayerUtils.MoveDisplayableObject(252, bodys.ToArray()); if (extract) { this.eleBody.Color = 186; } err.Add("电极头有过切,请检查!"); } dischargeFace = temp.Where(a => a.GetBody().Equals((this.eleBody))).Distinct().ToList(); //过滤电极面 List <Face> tt = temp.Where(a => a.GetBody().Equals((this.toolBody))).Distinct().ToList(); List <Face> faces = new List <Face>(); foreach (Face fe in dischargeFace) { FaceData data1 = FaceUtils.AskFaceData(fe); foreach (Face fa in tt) { FaceData fd = FaceUtils.AskFaceData(fa); if (UMathUtils.SelfDis(data1.Dir) == 0) { if (data1.FaceType == fd.FaceType && data1.IntNorm == -fd.IntNorm) { faces.Add(fe); break; } } else { double anlge = UMathUtils.Angle(data1.Dir, fd.Dir); if (data1.FaceType == fd.FaceType && data1.IntNorm == -fd.IntNorm && UMathUtils.IsEqual(anlge, Math.PI)) { faces.Add(fe); break; } } } } if (extract) { ExtractFace(this.toolBody, faces.ToArray()); } BodyInfo info = new BodyInfo(eleBody, faces); info.SetAttribute(csys, matr); return(info); }