/// <summary> /// 自动选点 /// </summary> public static void AutoSelPoint(string filename) { //导入探针 var part = NXOpen.Session.GetSession().Parts.Work; if (part != null) { Snap.NX.Part.Wrap(part.Tag).Close(true, true); } Snap.NX.Part snapPart = Snap.NX.Part.OpenPart(filename); var name = Path.GetFileNameWithoutExtension(filename); Snap.Globals.WorkPart = snapPart; try { var body = snapPart.Bodies.FirstOrDefault(); var config = ImportProbePart(); Helper.ShowMsg(string.Format("{0}开始取点...", name)); var list = CMMBusiness.AutoSelPoint(body, config); Helper.ShowMsg(string.Format("{0}取点完成", name)); } catch (Exception ex) { Helper.ShowMsg(string.Format("{0}取点错误【{1}】", name, ex.Message)); Console.WriteLine("AutoSelPoint错误:{0}", ex.Message); throw ex; } finally { snapPart.Close(true, true); } }
/// <summary> /// 自动选点 /// </summary> public static void AutoSelPoint() { Helper.ShowMsg("正在匹配图档..."); var cmmConfig = CMMTool.CMMConfig.GetInstance(); if (cmmConfig.IsUploadDataBase) { try { CMMBusiness.InitDatabase(); DataAccess.BOM.IsConnect(); } catch (Exception ex) { Helper.ShowMsg("数据库连接异常:" + ex.Message); return; } } var ConfigData = EactConfig.ConfigData.GetInstance(); EactTool.FileHelper.InitFileMode(cmmConfig.IsAutoCmmFtpDir ? 1 : 0, ConfigData.FTP.Address, "", ConfigData.FTP.User, ConfigData.FTP.Pass, false); var path = cmmConfig.AutoCmmDir; var fileName = EactTool.FileHelper.FindFile(path); if (!string.IsNullOrEmpty(fileName)) { try { AutoSelPoint(fileName); EactTool.FileHelper.DeleteFile(path, fileName); } catch (Exception ex) { Helper.ShowMsg("自动取点异常:" + ex.Message, 1); EactTool.FileHelper.WriteErrorFile(path, fileName, ex.Message); } } }