private void CADTaskInit(CADTaskCode code) { //1 初始化任务信息 taskInstance = new Task(); taskInstance.TaskId = int.Parse(code.Para1); taskInstance.TaskName = code.Para2; taskInstance.UpdateDrwView = code.Para4; taskInstance.NewFileDir = code.Para3; taskInstance.WorkPath = stationInfo.WorkPath + "\\" + taskInstance.NewFileDir + "\\"; taskInstance.Properties = code.Para5; }
//运行cad编码 public CADTaskCode RunCADCode(CADTaskCode cadCode) { if (this.RunCADCodeEvent != null) { var runArgs = new RunCADCodeArgs { CADCode = cadCode }; this.RunCADCodeEvent(runArgs); return(runArgs.CADCode); } return(null); }
private void GetModelModifyItem(CADTaskCode code, Model mdl) { //1分析属性值 ParseItem(typeof(CAD3dSW.Controler.PropertyChange), code.Para1, mdl); //2尺寸列表 ParseItem(typeof(CAD3dSW.Controler.DimChange), code.Para2, mdl); //3特征列表 ParseItem(typeof(CAD3dSW.Controler.FeatureChange), code.Para3 + "," + code.Para4, mdl); //4组件列表 //string compList = code.Para4 + code.Para15; //解析相同件配置映射 ParseItem(typeof(CAD3dSW.Controler.ComponentChange), code.Para4, mdl); ParsePropertyItem(typeof(CAD3dSW.Controler.GetMass), taskInstance.Properties, mdl); }
private void TemplateInit(CADTaskCode code, Model mdl) { if (code.Para9 == null) { return; } string DXFFileName = code.Para9.Trim(); //Para9: 格式, Y或N\文件名(不包含路径) if (DXFFileName == string.Empty) { mdl.CreateDXF = false; return; } bool dxf = false; if (DXFFileName.Substring(0, 2) == "Y\\") { dxf = true; } mdl.CreateDXF = dxf && stationInfo.bMakeDXF; if (mdl.CreateDXF) { mdl.DXFFileName = taskInstance.WorkPath + DXFFileName.Substring(2); } mdl.refConfig = code.Para4; if (string.IsNullOrEmpty(code.Para5)) { mdl.newConfig = code.Id.ToString(); } else { mdl.newConfig = code.Para5; } mdl.PartId = code.PartId; }
//获得任务编码列表 public List <CADTaskCode> GetTaskCadCodeList() { if (this.formCADTaskServer == null) { return(null); } List <TaskCadCode> taskCadCodes = null; try { taskCadCodes = this.formCADTaskServer.GetTaskCadCodeList(); } catch (Exception e) { MessageBox.Show(e.Message); } var listCADTaskCode = new List <CADTaskCode>(); if (taskCadCodes != null) { foreach (TaskCadCode taskCadcode in taskCadCodes) { var taskCode = new CADTaskCode { Id = taskCadcode.Id, TaskId = taskCadcode.TaskId, SortId = taskCadcode.SortId, PartId = taskCadcode.PartId, CadCodeId = taskCadcode.CadCodeId, Para1 = taskCadcode.Para1, Para2 = taskCadcode.Para2, Para3 = taskCadcode.Para3, Para4 = taskCadcode.Para4, Para5 = taskCadcode.Para5, Para6 = taskCadcode.Para6, Para7 = taskCadcode.Para7, Para8 = taskCadcode.Para8, Para9 = taskCadcode.Para9, Para10 = taskCadcode.Para10, Para11 = taskCadcode.Para11, Para12 = taskCadcode.Para12, Para13 = taskCadcode.Para13, Para14 = taskCadcode.Para14, Para15 = taskCadcode.Para15, Para16 = taskCadcode.Para16, Para17 = taskCadcode.Para17, Para18 = taskCadcode.Para18, Para19 = taskCadcode.Para19, Para20 = taskCadcode.Para20 }; listCADTaskCode.Add(taskCode); } this.formCADTaskServer.TaskRunning = true; if (this.formCADTaskServer.isAuto) { if (listCADTaskCode.Count > 0) { this.GetTaskTimer.Stop(); this.GetTaskTimerOnTaskRunEnd.Stop(); } else { this.GetTaskTimer.Start(); } } return(listCADTaskCode); } return(null); }
private void RunCadCode(CADTaskCode code) { switch (code.CadCodeId) { case Const.CAD_MSG_OPEN_MODEL: { System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); // Model mdl = new Model(iSwApp, code.Para1, string.Empty); mdl.OpenModel(); stopwatch.Stop(); WriteLog("打开模型耗时:" + stopwatch.ElapsedTicks.ToString(), 2); } break; case Const.CAD_MSG_GET_CFGS: { //CADCFGS cfgs; //cfgs.nModelID = _wtoi(stuComm.m_pstrPC_PARA1); //res = ::SendMessage (m_wndCad,nCadRunMessage,CAD_MSG_GET_CFGS,LPARAM(&cfgs)); //if(!res) return FALSE; //ArrayToString2(cfgs.arrayCfgs,stuComm.m_pstrPC_PARA2); } break; case Const.CAD_MSG_GET_ITEMS: { System.Diagnostics.Stopwatch stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); String resault = string.Empty; ReadModelInfo RMI = new ReadModelInfo(); if (code.Para2 == "2") { //读取模型中的尺寸列表 resault = RMI.getdimlist(iSwApp, null); } else if (code.Para2 == "4") { //读取模型中的特征列表 resault = RMI.getFeatureList(iSwApp, null); } else if (code.Para2 == "5") { //读取模型中的零部件列表 resault = RMI.getFeatureList(iSwApp, null); } else if (code.Para2 == "50") { //图层列表 resault = string.Empty; } code.Para3 = resault; stopwatch.Stop(); WriteLog(string.Format("读取模型属性{0}耗时:{1}", code.Para2, stopwatch.ElapsedTicks.ToString()), 2); } break; default: break; } }
private void RunCadTask() { //递归 1.CAD_MSG_TASK_INIT, 装配CAD_MSG_MODIFY_INIT, 装配子件1CAD_MSG_MODIFY_INIT,装配子件1CAD_MSG_MODIFY,...装配CAD_MSG_MODIFY List <CADTaskCode> ls = taskServer.GetTaskCadCodeList(); if (ls == null) { taskInstance = null; return; } Stack <Model> modelStack = new Stack <Model>(); #region 处理CAD代码 for (int i = 0; i < ls.Count; i++) { switch (ls[i].CadCodeId) { case Const.CAD_MSG_TASK_INIT: { ModelID = ls[i].Para1; CADTaskInit(ls[i]); //找跟模型 CADTaskCode code = ls.FirstOrDefault(p => p.CadCodeId == Const.CAD_MSG_MODIFY_INIT); if (code == null) { WriteLog(string.Format("任务{0}初始化失败,缺少初始化信息“命令ID=1200”!", taskInstance.TaskId), 2); taskServer.UpdateTaskPartPropWithModel(taskInstance.TaskId, ModelProperties); modelStack.Clear(); return; } rootModelFile = code.Para3.Trim("\\".ToCharArray()); WriteLog(string.Format("任务{0}初始化完成,开始驱动模板…", taskInstance.TaskId), 1); try { Directory.CreateDirectory(taskInstance.WorkPath); } catch (Exception) { WriteLog(string.Format("文件夹:{0}创建失败,请检查是否有对该目录写的权限!", taskInstance.WorkPath), 2); throw; } string modelFile = stationInfo.PdsPath + "\\" + rootModelFile; try { WriteLog("备份模型", 1); BackUpFile(modelFile, taskInstance.WorkPath); } catch (Exception ex) { WriteLog(string.Format("备份模型失败!", ex.Message), 2); } CloseAllModel(); //string rootModelPath = taskInstance.WorkPath.TrimEnd("\\".ToArray()); Model mdl = new Model(iSwApp, taskInstance.WorkPath + Path.GetFileName(rootModelFile), string.Empty); mdl.OpenModel(); } break; case Const.CAD_MSG_MODIFY_INIT: { string mdlName = ls[i].Para3; ModelID = ls[i].Para1; if (mdlName == null) { mdlName = string.Empty; } if (mdlName.Contains('\\')) { mdlName = mdlName.Split('\\')[mdlName.Split('\\').Count() - 1]; } //hying 2012/3/15 测试代码 //if (mdlName == "13502633.SLDPRT") //{ // break; //} //hying 2012/3/15 测试代码 以上可删 Model mdl = new Model(iSwApp, taskInstance.WorkPath + mdlName, ModelID, taskInstance.TaskId, taskServer); TemplateInit(ls[i], mdl); //mdl.OpenModel(); //2012/02/22 yyg modelStack.Push(mdl); // WriteLog(string.Format("CAD_MSG_MODIFY_INIT:{0}",mdlName),1); } break; case Const.CAD_MSG_MODIFY: { Model mdl = modelStack.Peek(); GetModelModifyItem(ls[i], mdl); mdl.Change(); SaveReturnProperties(mdl, mdl.GetProperties()); //if (modelStack.Count() > 1) //判断是否为 root //{ mdl.Close(); //ClearMemory(); //hying 2012/3/8 测试 //} modelStack.Pop(); } break; default: break; } } #endregion taskServer.UpdateTaskPartPropWithModel(taskInstance.TaskId, ModelProperties); modelStack.Clear(); ModelID = ls[0].Para1; }
public CADTaskCode RunCADCode(CADTaskCode cadTask) { var cadTaskCode = cad.RunCADCode(cadTask); return(cadTaskCode); }