public static string InsertMacro(ref Project refProject, ref Page refPage, EplMacroProperties eplMacroProperties) { string msg = EplDefinition.EPL_INSERT_MCR.ToString(); try { Insert insert = new Insert(); string macroType = eplMacroProperties.FilePath.Substring(eplMacroProperties.FilePath.LastIndexOf(".") + 1).Trim(); var offset = eplMacroProperties.Position.X; for (int i = 0; i < eplMacroProperties.Quantity; i++) { eplMacroProperties.Position.X = i * eplMacroProperties.Tollerence + offset; Logger.WriteLine(JsonConvert.SerializeObject(eplMacroProperties)); switch (macroType) { case "ema": //windows macro msg = EplDefinition.EPL_INSERT_WINDOW_MCR.ToString(); var windowMacro = eplMacroProperties.As <EplWindowMacroProperties>(); windowMacro.Position = eplMacroProperties.Position; msg = InsertWindowMacro(ref refPage, windowMacro); break; case "ems": // symbol macro msg = EplDefinition.EPL_INSERT_SYMBOL_MCR.ToString(); var symbolMacro = eplMacroProperties.As <EplSymbolMacroProperties>(); symbolMacro.Position = eplMacroProperties.Position; msg = InsertSymbolMacro(ref refPage, symbolMacro); break; case "emp": // page macro msg = EplDefinition.EPL_INSERT_PAGE_MCR.ToString(); var pageMacro = eplMacroProperties.As <EplPageMacroProperties>(); pageMacro.Position = eplMacroProperties.Position; msg = InsertPageMacro(ref refProject, ref refPage, pageMacro); break; default: break; } } } catch (Exception ex) { EplException("Insert macro error.", ex); msg = EplError.EPL_ERROR.ToString(); } return(msg); }
public int GetPageDetailDrawing(ref EplPageProperties EplPageProperties, int pageId, int row) { int PageId = 0; try { PageId = PageDetailSheet.GetCellValue <int>($"A{row}"); if (pageId != PageId) { return(PageId); } EplMacroProperties EplMacroProperties = new EplMacroProperties(); EplMacroProperties.FileName = PageDetailSheet.GetCellText($"B{row}"); EplMacroProperties.Position.X = PageDetailSheet.GetCellValue <double>($"C{row}"); EplMacroProperties.Position.Y = PageDetailSheet.GetCellValue <double>($"D{row}"); EplMacroProperties.Tollerence = PageDetailSheet.GetCellValue <double>($"E{row}"); EplMacroProperties.Quantity = PageDetailSheet.GetCellValue <int>($"H{row}"); string movekine = PageDetailSheet.GetCellText($"G{row}"); if (movekine.ToLower().IndexOf("relative") > -1) { EplMacroProperties.MoveKind = Eplan.EplApi.HEServices.Insert.MoveKind.Relative; } else { EplMacroProperties.MoveKind = Eplan.EplApi.HEServices.Insert.MoveKind.Absolute; } EplPageProperties.EplMacroProperties.Add(EplMacroProperties); } catch (Exception ex) { Logger.WriteLine("Get page detail drawing failed.", ex); } return(PageId); }