/// <summary> /// 以属性得到实体 /// </summary> /// <param name="obj"></param> /// <returns></returns> public static ParentAssmblieInfo GetAttribute(NXObject obj) { try { string partType = AttributeUtils.GetAttrForString(obj, "PartType"); ParentAssmblieInfo info = new ParentAssmblieInfo(MoldInfo.GetAttribute(obj), UserModel.GetAttribute(obj)); info.Type = (PartType)Enum.Parse(typeof(PartType), partType); return(info); } catch (NXException ex) { throw ex; } }
/// <summary> /// 获取work /// </summary> /// <param name="model"></param> /// <param name="asmPart"></param> /// <returns></returns> private WorkModel GetWorkModel(ElectrodeModel model) { List <NXOpen.Assemblies.Component> eleComs = AssmbliesUtils.GetPartComp(this.asmPart, model.PartTag); List <WorkModel> works = new List <WorkModel>(); foreach (NXOpen.Assemblies.Component ct in eleComs) { NXOpen.Assemblies.Component parent = ct.Parent; if (parent != null) { Part pt = parent.Prototype as Part; if (WorkModel.IsWork(pt) && !works.Exists(a => a.PartTag.Equals(pt)) && ParentAssmblieInfo.GetAttribute(pt).MoldInfo.Equals(model.Info.MoldInfo)) { works.Add(new WorkModel(pt)); } } } works.Sort(); if (works.Count != 0) { return(works[0]); } else { return(null); } }
/// <summary> /// 判断当前部件是否是Electrode /// </summary> /// <param name="part"></param> /// <returns></returns> public static bool IsElectrode(Part part) { ParentAssmblieInfo info = ParentAssmblieInfo.GetAttribute(part); return(info.Type == PartType.Electrode); }
/// <summary> /// 判断当前部件是否是Workpiece /// </summary> /// <param name="part"></param> /// <returns></returns> public static bool IsWorkpiece(Part part) { ParentAssmblieInfo info = ParentAssmblieInfo.GetAttribute(part); return(info.Type == PartType.Workpiece); }
/// <summary> /// 判断当前部件是否是ASM /// </summary> /// <param name="part"></param> /// <returns></returns> public static bool IsAsm(Part part) { ParentAssmblieInfo info = ParentAssmblieInfo.GetAttribute(part); return(info.Type == PartType.ASM); }