private void butOK_Click(object sender, EventArgs e) { List <string> err = new List <string>(); if (this.fileSave.Equals("")) { this.fileSave = file.GetSaveFilePath(); } if (this.fileSave.Equals("")) { ClassItem.MessageBox("请选择保存文件位置", NXMessageBox.DialogType.Error); return; } foreach (CreateElectrodeCAMBuilder cb in this.camBd) { if (cb.Template.Type == ElectrodeTemplate.User) { err.AddRange(cb.CreateUserOperation()); } else { err.AddRange(cb.CreateOperation()); } cb.SetGenerateToolPath(this.checkBoxIsGenerate.Checked); err.AddRange(cb.ExportFile(this.fileSave, true)); elePart.Remove(cb.Pt); } if (err.Count > 0) { ClassItem.Print(err.ToArray()); } this.Close(); }
private static List <string> CreateBuider(string partPath) { List <string> err = new List <string>(); Tag ptTag = Tag.Null; UFPart.LoadStatus load; ElectrodeCAMFile file = new ElectrodeCAMFile(); List <string> newPath = file.CopyFile(partPath); try { theUfSession.Part.Open(newPath[0], out ptTag, out load); } catch (NXException ex) { err.Add("打开文件失败! " + ex.Message); return(err); } Part pt = NXObjectManager.Get(ptTag) as Part; string name = pt.Name; if (pt != null) { UserModel user = UserModel.GetAttribute(pt); ElectrodeCAMInfo cam = ElectrodeCAMInfo.GetAttribute(pt); CreateElectrodeCAMBuilder builder = new CreateElectrodeCAMBuilder(pt, user); builder.CreateOperationNameModel(GetTemplate(cam.CamTemplate)); err.AddRange(builder.CreateOperationExe()); builder.SetGenerateToolPath(true); string path = file.GetSaveFilePath(); if (path != null && path != "") { builder.ExportFile(path, false); } else { builder.ExportFile("C:\\temp\\Electrode\\", false); } err.Add("电极" + name + "*************导出成功!"); } return(err); }