private void butOpen_Click(object sender, EventArgs e) { UFSession theUFSession = UFSession.GetUFSession(); Session theSession = Session.GetSession(); ClassItem.StatusMessge("选择电极文件"); List <string> elePath = new List <string>(); if (elePart.Count == 0) { elePath = file.CopyFile(); } else { string fileName = Path.GetDirectoryName(elePart[0].FullPath) + "\\"; elePath = file.AddFile(fileName); } List <string> errd = new List <string>(); if (elePath.Count > 0) { foreach (string st in elePath) { Tag partTag; UFPart.LoadStatus err; try { theUFSession.Part.Open(st, out partTag, out err); elePart.Add(NXObjectManager.Get(partTag) as Part); } catch (NXException ex) { errd.Add(st + " " + ex.Message); } } if (errd.Count != 0) { ClassItem.Print(errd.ToArray()); } SetEleInfo(); DispSeleteEle(); this.butTemplate.Enabled = true; } }
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); }