/// <summary> /// 获取隐藏 /// </summary> /// <returns></returns> public NXOpen.Assemblies.Component[] GetHideComp() { List <NXOpen.Assemblies.Component> hides = new List <NXOpen.Assemblies.Component>(); NXOpen.Assemblies.Component workComp = work.PartTag.ComponentAssembly.RootComponent; foreach (NXOpen.Assemblies.Component ct in workComp.GetChildren()) { NXOpen.Assemblies.Component[] edm = ct.GetChildren(); if (edm.Length != 0) { ct.Unblank(); foreach (NXOpen.Assemblies.Component cp in edm) { cp.Unblank(); if (!cp.Name.Equals(this.workpiece.Name)) { hides.Add(cp); } } } else { hides.Add(ct); } } return(hides.ToArray()); }
private void GetWorkpiece() { if (this.Edm != null) { NXOpen.Assemblies.Component edmComp = this.Edm.GetPartComp(Asm.PartTag); if (edmComp != null) { foreach (NXOpen.Assemblies.Component ct in edmComp.GetChildren()) { Workpieces.Add(ct.Prototype as Part); } } } }
public void Highlight(bool highlight) { Part workPart = Session.GetSession().Parts.Work; NXOpen.Assemblies.Component root = workPart.ComponentAssembly.RootComponent; if ((workPart.Tag != this.PartTag.Tag) && highlight && root != null) { foreach (NXOpen.Assemblies.Component ct in root.GetChildren()) { ct.Blank(); } NXOpen.Assemblies.Component eleComp = Basic.AssmbliesUtils.GetPartComp(workPart, this.PartTag); eleComp.Unblank(); } }
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> /// 复制work /// </summary> /// <param name="ct"></param> /// <param name="work"></param> /// <param name="workpieceNumber"></param> /// <param name="user"></param> /// <returns></returns> private List <string> CopyWork(NXOpen.Assemblies.Component ct, WorkModel work, string workpieceNumber, UserModel user) { List <string> err = new List <string>(); Matrix4 mat = new Matrix4(); mat.Identity(); MoldInfo mold = work.Info.MoldInfo.Clone() as MoldInfo; NXOpen.Assemblies.Component moveCt = null; try { moveCt = AssmbliesUtils.MoveCompCopyPart(ct, new Vector3d(), mat); } catch (NXException ex) { err.Add("无法移动工件!" + ex.Message); return(err); } mold.WorkpieceNumber = workpieceNumber; string name = work.WorkpieceDirectoryPath + mold.MoldNumber + "-" + mold.WorkpieceNumber + "-"; if (moveCt != null) { foreach (NXOpen.Assemblies.Component com in moveCt.GetChildren()) { if (ParentAssmblieInfo.IsParent(com)) { ParentAssmblieInfo info1 = ParentAssmblieInfo.GetAttribute(com); if (info1.Type == PartType.EDM) { string edmName = name + "EDM"; if (File.Exists(edmName + ".prt")) { edmName = edmName + "5"; } EDMInfo edm = new EDMInfo(mold, user); try { NXObject make = AssmbliesUtils.MakeUnique(com, edmName + ".prt"); edm.SetAttribute(com.Prototype as Part); break; } catch (NXException ex) { err.Add(name + "EDM.prt" + ex.Message + "无法创建唯一"); } } } } try { NXObject make1 = AssmbliesUtils.MakeUnique(moveCt, name + "WORK" + work.Info.WorkNumber.ToString() + ".prt"); WorkInfo wk = new WorkInfo(mold, user, work.Info.WorkNumber, work.Info.Matr); wk.SetAttribute(moveCt.Prototype as Part); } catch (NXException ex) { err.Add(name + "WORK" + work.Info.WorkNumber.ToString() + ".prt" + ex.Message + "无法创建唯一"); } } return(err); }