public bool Execute(ActionCallingContext oActionCallingContext) { String recordName = null; oActionCallingContext.GetParameter("recordname", ref recordName); SelectionSet selectionSet = new SelectionSet(); Project oProject = selectionSet.GetCurrentProject(true); oProject.LockObject(); List <PlaceHolder> pList = new List <PlaceHolder>(); foreach (Page page in oProject.Pages) { foreach (Placement gp in page.AllPlacements) { if (gp is PlaceHolder) { pList.Add((PlaceHolder)gp); } } } //System.Windows.Forms.MessageBox.Show(pList.Count.ToString()); foreach (PlaceHolder plh in pList) { if (plh.GetRecordNames().Contains(recordName)) { plh.Remove(); } } return(true); }
/// <summary> /// Returns the active project /// </summary> /// <returns>Active Project</returns> public static Project GetCurrentProject() { SelectionSet selectionSet = new SelectionSet(); selectionSet.LockProjectByDefault = true; selectionSet.LockSelectionByDefault = true; return selectionSet.GetCurrentProject(true); }
/// <summary> /// Получить текущий проект /// </summary> /// <returns>Проект</returns> public static Project GetProject() { SelectionSet selection = GetSelectionSet(); const bool useDialog = false; Project project = selection.GetCurrentProject(useDialog); return project; }
/// <summary> /// Returns the active project /// </summary> /// <returns>Active Project</returns> public static Project GetCurrentProject() { SelectionSet selectionSet = new SelectionSet(); selectionSet.LockProjectByDefault = false; selectionSet.LockSelectionByDefault = false; return(selectionSet.GetCurrentProject(false)); }
public bool Execute(ActionCallingContext oActionCallingContext) { SelectionSet Set = new SelectionSet(); Project CurrentProject = Set.GetCurrentProject(true); string ProjectName = CurrentProject.ProjectName; //DoWireMarking.DoWireMarking.MassageHandler(ProjectName); // Show ProgressBar Progress progress = new Progress("SimpleProgress"); progress.SetAllowCancel(true); progress.SetAskOnCancel(true); progress.SetTitle("DWG/PDF export"); progress.ShowImmediately(); progress.BeginPart(25.0, "ChangeFontType to GOST Type AU : "); try { ChangeDrawMode(CurrentProject, 2); ChangeFontType("??_??@GOST Type AU;"); progress.EndPart(); progress.BeginPart(25.0, "Export to DWG : "); ExportToDwg(); } catch (Exception ex) { progress.EndPart(true); DoWireMarking.DoWireMarking.ErrorHandler("Export to DWG", ex); return(false); } progress.EndPart(); progress.BeginPart(25.0, "ChangeFontType to GOST type A : "); progress.Step(1); try { ChangeFontType("??_??@GOST type A;"); progress.EndPart(); progress.BeginPart(25.0, "Export to PDF : "); ExportToPdf(ProjectName); ChangeDrawMode(CurrentProject, 3); } catch (Exception ex) { DoWireMarking.DoWireMarking.ErrorHandler("Export to PDF", ex); return(false); } finally { //ChangeFontType(CurrentProject, ""); progress.EndPart(true); } return(true); }
public bool Execute(ActionCallingContext oActionCallingContext) { Progress oProgress = new Progress("Состояние экспорта"); oProgress.SetAllowCancel(true); #region Прогресс бар 1 oProgress.BeginPart(60.0, ""); oProgress.SetActionText("Получение данных из проекта.."); oProgress.SetNeededSteps(1); oProgress.Step(1); #endregion //выбрать текущий проект SelectionSet Set = new SelectionSet(); Project CurrentProject = Set.GetCurrentProject(true); //пути файлов string exportXMLPath = CurrentProject.ProjectDirectoryPath + @"\Temp.xml"; string exportFilePath = CurrentProject.ProjectDirectoryPath + @"\DOC\Спецификация по шкафам.xlsx"; //выгрузка в XML PartsService partsService = new PartsService(); partsService.ExportPartsList(CurrentProject, exportXMLPath, 0); oProgress.EndPart(false); #region Прогресс бар 2 oProgress.BeginPart(25.0, ""); oProgress.SetActionText("Сортировка.."); oProgress.SetNeededSteps(1); oProgress.Step(1); #endregion //загрузка в лист ListOfDevices listOfDevices = new ListOfDevices(); List <Part> devices = listOfDevices.GetAllDevices(exportXMLPath); var partsFiltered = from p in devices where ((p.PartNo != "None") && (p.Quantity != 0) && (p.PartNo != "Шильд")) orderby p.PartNo select p; oProgress.EndPart(false); #region Прогресс бар 3 oProgress.BeginPart(15.0, ""); oProgress.SetActionText("Экспорт в Excel.."); oProgress.SetNeededSteps(1); oProgress.Step(1); #endregion XLSSerializer serializer = new XLSSerializer(); serializer.Serialize(exportFilePath, partsFiltered.ToList()); oProgress.EndPart(true); return(true); }
/// <summary> /// Синхронизация названий устройств и модулей /// </summary> /// <returns>Возвращает сообщения об ошибках во время выполнения. /// </returns> public string Execute() { ProjectConfiguration.GetInstance().ReadIO(); if (ProjectConfiguration.GetInstance().DevicesIsRead == true) { ProjectConfiguration.GetInstance().SynchronizeDevices(); } else { ProjectConfiguration.GetInstance().ReadDevices(); } ProjectConfiguration.GetInstance().ReadBinding(); ProjectConfiguration.GetInstance().Check(); IO.IOManager.GetInstance().CalculateIOLinkAdresses(); var selection = new SelectionSet(); Project project = selection.GetCurrentProject(true); var objectFinder = new DMObjectsFinder(project); var functionsFilter = new FunctionsFilter(); var properties = new FunctionPropertyList(); properties.FUNC_MAINFUNCTION = true; functionsFilter.SetFilteredPropertyList(properties); functionsFilter.Category = Function.Enums.Category.PLCBox; Function[] devicesFunctions = objectFinder. GetFunctions(functionsFilter); project.LockAllObjects(); Dictionary <string, string> deviceConnections = CollectIOModulesData(devicesFunctions); bool containsNewValveTerminal = GetProjectVersionFromDevices( deviceConnections); synchronizedDevices.Clear(); if (!containsNewValveTerminal) { SynchronizeAsOldProject(deviceConnections, devicesFunctions); } else { SynchronizeAsNewProject(deviceConnections, devicesFunctions); } ClearNotExistingBinding(); return(errorMessage); }
public bool Execute(ActionCallingContext oActionCallingContext) { SelectionSet Set = new SelectionSet(); Project CurrentProject = Set.GetCurrentProject(true); string ProjectName = CurrentProject.ProjectName; string ProjectCompanyName = CurrentProject.Properties.PROJ_COMPANYNAME; DateTime ProjectCreationDate = CurrentProject.Properties.PROJ_CREATIONDATE; MessageBox.Show("Название проекта: " + ProjectName + "\n" + "Название фирмы: " + ProjectCompanyName + "\n" + "Дата создания проекта: " + ProjectCreationDate.ToShortDateString() + "\n" + "Автор API: Спицын Дмитрий.", "О проекте"); return(true); }
void Update(object devin) { using (LockingStep oLS = new LockingStep()) { // ... доступ к данным P8 ... SelectionSet Set = new SelectionSet(); Project CurrentProject = Set.GetCurrentProject(true); projectname = CurrentProject.ProjectFullName; StorableObject[] storableObjects = Set.Selection; List <Page> Lpage = Set.GetSelectedPages().ToList(); DMObjectsFinder dmObjectsFinder = new DMObjectsFinder(CurrentProject); List <Function3D> place3d; //place3d = dmObjectsFinder.GetFunctions3D(null).ToList(); List <Function> place; //place = dmObjectsFinder.GetFunctions(null).ToList(); List <Terminal> ltermlist; functype devl = new functype(); ((List <functype>)devin).Clear(); int id = 0; int id3d = 0; bool placefind = false; progressBar1.Value = 0; progressBar1.Maximum = Lpage.Count; for (int i = 0; i < Lpage.Count; i++) { Type ltp = Lpage[i].GetType(); if (ltp.Name == "Page") { place = Lpage[i].Functions.ToList(); FunctionsFilter oterfilt = new FunctionsFilter(); oterfilt.Page = Lpage[i]; ltermlist = dmObjectsFinder.GetTerminals(oterfilt).ToList(); //MessageBox.Show(ltermlist.Count.ToString()); for (int j = 0; j < place.Count; j++) { id += 1; if (place[j].IsMainFunction != true) { continue; } //// Проверяем является ли функция главной //if (place[j].Properties.DESIGNATION_LOCATION.ToString() != listBox1.SelectedItem.ToString()) { continue; } Functions3DFilter f3d = new Functions3DFilter(); Function3DPropertyList oFunction3DPropertyList = new Function3DPropertyList(); oFunction3DPropertyList.DESIGNATION_LOCATION = place[j].Properties.DESIGNATION_LOCATION; f3d.SetFilteredPropertyList(oFunction3DPropertyList); place3d = dmObjectsFinder.GetFunctions3D(f3d).ToList(); id3d += place3d.Count; placefind = false; for (int l = 0; l < place3d.Count; l++) { //MessageBox.Show("F"+ place[j].ObjectIdentifier.ToString()+"F3D "+ place3d[l].ObjectIdentifier+"\n"+ place[j].Name+" "+place3d[l].Name); if (place[j].Properties.FUNC_IDENTDEVICETAGWITHOUTSTRUCTURES == place3d[l].Properties.FUNC_IDENTDEVICETAGWITHOUTSTRUCTURES) { placefind = true; break; } } if (placefind == false) { devl.Name = place[j].Name; devl.Page = Lpage[i].Name; devl.Designation = place[j].Properties.DESIGNATION_LOCATION; ((List <functype>)devin).Add(devl); } } for (int t = 0; t < ltermlist.Count; t++) { if (ltermlist[t].IsMainTerminal != true) { continue; } //// Проверяем является ли функция главной //if (place[j].Properties.DESIGNATION_LOCATION.ToString() != listBox1.SelectedItem.ToString()) { continue; } Functions3DFilter f3d = new Functions3DFilter(); Function3DPropertyList oFunction3DPropertyList = new Function3DPropertyList(); oFunction3DPropertyList.DESIGNATION_LOCATION = ltermlist[t].Properties.DESIGNATION_LOCATION; f3d.SetFilteredPropertyList(oFunction3DPropertyList); place3d = dmObjectsFinder.GetFunctions3D(f3d).ToList(); id3d += place3d.Count; // MessageBox.Show(ltermlist[t].Name.ToString()); placefind = false; for (int l = 0; l < place3d.Count; l++) { if (ltermlist[t].Name.ToString() == place3d[l].Name.ToString()) { placefind = true; break; } } if (placefind == false) { devl.Name = ltermlist[t].Name; devl.Page = Lpage[i].Name; devl.Designation = ltermlist[t].Properties.DESIGNATION_LOCATION; ((List <functype>)devin).Add(devl); } } } progressBar1.Value += 1; } label4.Text = id.ToString(); label7.Text = id3d.ToString(); } }
public bool Execute(ActionCallingContext oActionCallingContext) { // MessageBox.Show("Checkout Action"); SelectionSet selectionSet = new SelectionSet(); Project project = selectionSet.GetCurrentProject(true); //string creator = project.Properties[10013]; //MessageBox.Show(creator); //Location[] location = project.GetLocationObjects(Project.Hierarchy.Plant); //string strDesc1 = ISOCodeUtil.GetISOStringValue(location[0].Properties.LOCATION_DESCRIPTION_SUPPLEMENTARYFIELD[1]); //MessageBox.Show(strDesc1); Page[] pages = project.Pages; DMObjectsFinder finder = new DMObjectsFinder(project); PagePropertyList ppl = new PagePropertyList(); // ppl.DESIGNATION_LOCATION = "C1"; // ppl.DESIGNATION_DOCTYPE = "SINGLE"; // ppl.DESIGNATION_DOCTYPE = "MULTI"; ppl.PAGE_TYPE_NUMERIC = 1; PagesFilter pf = new PagesFilter(); pf.SetFilteredPropertyList(ppl); Page[] sPages = finder.GetPages(pf); // sPages[0]. //FunctionPropertyList fpl = new FunctionPropertyList(); //FunctionsFilter ff = new FunctionsFilter(); //ff.SetFilteredPropertyList() ArrayList list = new ArrayList(); Function[] ffss = finder.GetFunctions(null); foreach (Function f in ffss) { if (f.Category == Function.Enums.Category.Motor) { list.Add(f); ArticleReference[] ars = f.ArticleReferences; if (ars.Count() > 0) { int count = ars[0].Count; Article article = ars[0].Article; } } } ArticleReferencePropertyList arpl = new ArticleReferencePropertyList(); arpl.ARTICLE_MANUFACTURER = "RITTAL"; ArticleReferencesFilter arf = new ArticleReferencesFilter(); arf.SetFilteredPropertyList(arpl); ArticleReference[] fars = finder.GetArticleReferences(arf); foreach (ArticleReference item in fars) { // MessageBox.Show(string.Format("{0}[{1}]({2})", item.Properties.ARTICLEREF_PARTNO, item.Properties.ARTICLE_MANUFACTURER, item.Count)); } // ArticleReference[] farsws = finder.GetArticleReferencesWithFilterScheme("default"); // P8에서 정의한 스키마로 필터 //PagePropertyList newppl = new PagePropertyList(); //// newppl.DESIGNATION_LOCATION = "MULTI"; //newppl.DESIGNATION_DOCTYPE = "MULTI"; //newppl.PAGE_COUNTER = "11"; //newppl.PAGE_NOMINATIOMN = "Insert Macro By API"; //newppl.PAGE_IDENTNAME = "1011"; //newppl.PAGE_NUMBER = "11"; //newppl.PAGE_NAME = "Insert Macro By API"; //Page newPage = new Page(); //newPage.Create(project, DocumentTypeManager.DocumentType.Circuit, newppl); //Insert insert = new Insert(); //PointD point = new PointD(100, 250); //var resultObject = insert.WindowMacro(@"C:\Users\Public\EPLAN26\Data\Macros\EPlanKorea\m.ema", 0, newPage, point, Insert.MoveKind.Absolute); PagePropertyList newppl = new PagePropertyList(); newppl.DESIGNATION_DOCTYPE = "MULTI"; newppl.PAGE_COUNTER = "211"; newppl.PAGE_NOMINATIOMN = "Insert Page Macro By API"; newppl.PAGE_IDENTNAME = "2011"; newppl.PAGE_NUMBER = "211"; newppl.PAGE_NAME = "Insert Page Macro By API"; Page newPage = new Page(); newPage.Create(project, DocumentTypeManager.DocumentType.Circuit, newppl); Insert insert = new Insert(); var resultObject = insert.PageMacro(@"C:\Users\Public\EPLAN26\Data\Macros\EPlanKorea\mPage.emp", newPage, project, false, PageMacro.Enums.NumerationMode.Number); return(true); }
/// <summary> /// Execute Action /// </summary> /// <param name="oActionCallingContext"></param> /// <returns></returns> public bool Execute(ActionCallingContext oActionCallingContext) { SelectionSet Set = new SelectionSet(); Project CurrentProject = Set.GetCurrentProject(true); string ProjectName = CurrentProject.ProjectName; Debug.WriteLine(ProjectName); string xlsFileName = Path.GetDirectoryName(CurrentProject.ProjectFullName); xlsFileName = Path.Combine(xlsFileName, $"{ DateTime.Now.Year }.{ DateTime.Now.Month }.{ DateTime.Now.Day }_" + Settings.Default.outputFileName); // Show ProgressBar Progress progress = new Progress("SimpleProgress"); progress.SetAllowCancel(true); progress.SetAskOnCancel(true); progress.SetTitle("Wire mark export"); progress.ShowImmediately(); progress.BeginPart(25.0, "Export label : "); try { // Executing Action "label" ExportXML.Execute(xmlExportFileName); if (progress.Canceled()) { progress.EndPart(true); return(true); } } catch (Exception ex) { ErrorHandler("ExportXML", ex); return(false); } progress.EndPart(); progress.BeginPart(25.0, "Parse XML : "); try { // Getting object from XML ParseXMLWireFile(); if (progress.Canceled()) { progress.EndPart(true); return(true); } } catch (Exception ex) { ErrorHandler("ParseXMLWireFile", ex); return(false); } progress.EndPart(); progress.BeginPart(10.0, "Write data to Excel : " + xlsFileName); try { // Export to excel // Creating *.xls file ExportToExcel.Execute(listOfLines, xlsFileName, progress); if (progress.Canceled()) { progress.EndPart(true); return(true); } } catch (Exception ex) { ErrorHandler("ExportToExcel.Execute", ex); return(false); } finally { progress.EndPart(true); } return(true); }