public static Electrode GetElectrode(Snap.NX.Body body) { Electrode result = null; var elecName = body.Name; var faces = body.Faces; //顶面 var topFace = faces.FirstOrDefault(u => u.MatchAttrValue(ATTR_NAME_MARK, BASE_BOT)); //基准面 var baseFace = faces.FirstOrDefault(u => u.MatchAttrValue(ATTR_NAME_MARK, BASE_TOP)); //基准台侧面 var baseSideFaces = faces.Where(u => u.MatchAttrValue(ATTR_NAME_MARK, BASE_SIDE)).ToList(); //基准点 var elecBasePoint = Snap.Globals.WorkPart.Points.Where(u => u.MatchAttrValue(ATTR_NAME_MARK, elecName) && u.MatchAttrValue(DIM_PT, DIM_PT)) .OrderBy(u => Snap.Compute.Distance(u.Position, body)).FirstOrDefault(); //象限面 var chamferFace = faces.FirstOrDefault(u => u.MatchAttrValue(ATTR_NAME_MARK, BASE_CHAMFER)); if (!string.IsNullOrEmpty(elecName) && topFace != null && baseFace != null && baseSideFaces.Count >= 4 //&& elecBasePoint != null ) { var model = new XKElectrode(); model.BaseFace = baseFace; model.TopFace = topFace; model.BaseSideFaces = baseSideFaces.ToList(); model.ElecBasePoint = elecBasePoint; model.ElecBody = body; model.ChamferFace = chamferFace; //model.ElecHeadFaces = Electrode.GetElecHeadFaces(faces.ToList(), baseFace, out baseSideFaces); result = model; model.AllObject.Add(body); model.AllObject.Add(elecBasePoint); } return(result); }
public static Electrode GetElectrode(Snap.NX.Body body) { Electrode result = null; result = XKElectrode.GetElectrode(body); if (result == null) { result = UPElectrode.GetElectrode(body); } if (result == null) { result = JYElectrode.GetElectrode(body); } if (result == null) { result = EactElectrode.GetElectrode(body); } return(result); }