/// <summary> /// 获取EDM /// </summary> /// <returns></returns> public EDMModel GetEDMModel() { EDMModel model = null; foreach (NXOpen.Assemblies.Component ct in this.workCt.GetChildren()) { if (ParentAssmblieInfo.IsEDM(ct)) { model = new EDMModel(ct.Prototype as Part); } } return(model); }
private List <string> CreateNewWork1(NXOpen.Assemblies.Component ct, WorkpieceModel workpiece, Matrix4 mat, UserModel user) { List <string> err = new List <string>(); MoldInfo moldInfo = workpiece.Info.MoldInfo; int num = asmColl.GetWorkCollection(moldInfo).Work.Count; WorkInfo workInfo = new WorkInfo(workpiece.Info.MoldInfo, user, num + 1, mat); string workName = workInfo.MoldInfo.MoldNumber + "-" + workInfo.MoldInfo.WorkpieceNumber + "-" + "WORK" + workInfo.WorkNumber.ToString(); EDMModel edm = GetEdm(ct); if (edm == null) { err.Add("获取EDM错误"); return(err); } NXOpen.Assemblies.Component comp = AssmbliesUtils.MoveCompCopyPart(ct.Parent.Parent, new Vector3d(0, 0, 0), mat); AssmbliesUtils.MakeUnique(comp, edm.WorkpieceDirectoryPath + workName + ".prt"); workInfo.SetAttribute(comp.Prototype as Part); WorkModel wm = new WorkModel(comp.Prototype as Part); if (wm != null) { wm.SaveCsys(workPart); } if (!edm.Info.MoldInfo.Equals(workInfo.MoldInfo)) { EDMInfo edmInfo = new EDMInfo(workInfo.MoldInfo, workInfo.UserModel); string edmName = edmInfo.MoldInfo.MoldNumber + "-" + edmInfo.MoldInfo.WorkpieceNumber + "-" + "EDM"; foreach (NXOpen.Assemblies.Component cp in comp.GetChildren()) { if (ParentAssmblieInfo.IsEDM(cp)) { AssmbliesUtils.MakeUnique(cp, edm.WorkpieceDirectoryPath + edmName + ".prt"); edmInfo.SetAttribute(cp.Prototype as Part); foreach (NXOpen.Assemblies.Component co in cp.GetChildren()) { if (!(co.Prototype as Part).Equals(workpiece.PartTag)) { AssmbliesUtils.DeleteComponent(co); } } } } } return(err); }
/// <summary> /// 获取工件Part /// </summary> /// <returns></returns> private List <NXOpen.Assemblies.Component> GetWorkpieces() { List <NXOpen.Assemblies.Component> workpiece = new List <NXOpen.Assemblies.Component>(); foreach (NXOpen.Assemblies.Component ct in this.workCt.GetChildren()) { if (ParentAssmblieInfo.IsEDM(ct)) { foreach (NXOpen.Assemblies.Component cp in ct.GetChildren()) { if (!workpiece.Exists(a => a.Equals(cp))) { workpiece.Add(cp); } } } } return(workpiece); }