/// <summary> /// 替换工件 /// </summary> /// <param name="ct"></param> private void AlterWorkpiece(NXOpen.Assemblies.Component ct, UserModel user) { MoldInfo mold; if (!ParentAssmblieInfo.IsParent(ct)) { mold = new MoldInfo() { MoldNumber = this.strMoldNumber.Value.ToUpper(), WorkpieceNumber = this.strWorkpieceNumber.Value.ToUpper(), EditionNumber = this.strEditionNumber.Value.ToUpper() }; } else { mold = MoldInfo.GetAttribute(ct); mold.MoldNumber = this.strMoldNumber.Value; mold.WorkpieceNumber = this.strWorkpieceNumber.Value; mold.EditionNumber = this.strEditionNumber.Value; } WorkPieceInfo wk = new WorkPieceInfo(mold, user); string newName = mold.MoldNumber + "-" + mold.WorkpieceNumber + "-" + mold.EditionNumber; Part pt = ct.Prototype as Part; ReplaceOther ot = new ReplaceOther(pt, wk); List <string> err = ot.Alter(newName); if (err.Count > 0) { ClassItem.Print(err.ToArray()); } }
private List <WorkpieceModel> CreateBulder(Part edmPart, List <string> openFiles, out List <string> err) { List <WorkpieceModel> workpiece = new List <WorkpieceModel>(); err = new List <string>(); EDMModel edm = new EDMModel(edmPart); MoldInfo moldInfo = edm.Info.MoldInfo.Clone() as MoldInfo; moldInfo.MoldNumber = this.strMoldNumber.Value.ToUpper(); moldInfo.EditionNumber = this.strEditionNumber.Value.ToUpper(); WorkPieceInfo info = new WorkPieceInfo(edm.Info.MoldInfo, user.CreatorUser); foreach (string st in openFiles) { MoldInfo temp = moldInfo.Clone() as MoldInfo; string name = Path.GetFileNameWithoutExtension(st); temp.WorkpieceNumber = name; WorkpieceModel model = new WorkpieceModel(new WorkPieceInfo(temp, user.CreatorUser)); if (model.CreatePart(edm.WorkpieceDirectoryPath, st)) { workpiece.Add(model); } else { err.Add(name + "没创建成功"); } } return(workpiece); }
/// <summary> /// 设置对话框显示 /// </summary> private void SetDisp(NXOpen.Assemblies.Component ct) { if (ParentAssmblieInfo.IsElectrode(ct)) { this.groupEle.Show = true; info = ElectrodeInfo.GetAttribute(ct); //this.strMoldNumber.Show = false; // this.strWorkpieceNumber.Show = false; // this.strEditionNumber.Show = false; this.groupWorkpiece.Show = false; this.groupWork.Show = false; ElectrodeInfo eleInfo = info as ElectrodeInfo; string temp = info.MoldInfo.MoldNumber + "-" + info.MoldInfo.WorkpieceNumber; this.strEleName.Value = temp; this.strEleName1.Value = eleInfo.AllInfo.Name.EleName.Substring(temp.Length, eleInfo.AllInfo.Name.EleName.Length - temp.Length); this.strEleEditionNumber.Value = eleInfo.AllInfo.Name.EleEditionNumber; } else if (ParentAssmblieInfo.IsWorkpiece(ct)) { info = WorkPieceInfo.GetAttribute(ct); this.groupWorkpiece.Show = true; this.groupEle.Show = false; this.groupWork.Show = false; this.strMoldNumber.Value = info.MoldInfo.MoldNumber; this.strWorkpieceNumber.Value = info.MoldInfo.WorkpieceNumber; this.strEditionNumber.Value = info.MoldInfo.EditionNumber; } else if (ParentAssmblieInfo.IsWork(ct)) { info = WorkInfo.GetAttribute(ct); this.groupWork.Show = true; this.groupEle.Show = false; this.groupWorkpiece.Show = false; this.intWorkNumber.Value = (info as WorkInfo).WorkNumber; } else if (!ParentAssmblieInfo.IsParent(ct)) { this.groupWorkpiece.Show = true; this.groupEle.Show = false; this.strWorkpieceNumber.Value = ct.Name; } }