public static string InsertConnectingPoint(this Page page, string lib, string symbolname, PointD location) { string msg = EplDefinition.EPL_INSERT_CONNECTING_POINT.ToString(); try { using (LockingStep oLS = new LockingStep()) { page.Project.LockAllObjects(); SymbolLibrary symboLib = new SymbolLibrary(page.Project, lib); Symbol symbol = new Symbol(symboLib, symbolname); SymbolVariant oSymbolVariant = new SymbolVariant(); oSymbolVariant.Initialize(symbol, 0); Function function = new Function(); function.Create(page, oSymbolVariant); function.Location = location; function.Properties.FUNC_CONNECTIONDESIGNATION[1] = "1"; } } catch (Exception ex) { EplExtension.EplException("Insert symbol error.", ex); msg = EplError.EPL_ERROR.ToString(); } return(msg); }
public void SetMainForm(IntPtr f) { starter.SetFrame(f); app = starter.APP; starter.SetFrame(f); this.app = starter.APP; Manager = new ProjectManager(); Locker = new LockingStep(); }
private void listBox2_MouseDoubleClick(object sender, MouseEventArgs e) { Edit oedit = new Edit(); using (LockingStep oLS = new LockingStep()) { if (projectname != "") { oedit.OpenPageWithName(projectname, devf[listBox2.SelectedIndex].Page); //oedit.OpenPageWithNameAndFunctionName(projectname, devf[listBox2.SelectedIndex].Page, devf[listBox2.SelectedIndex].Name); } } }
public static string InsertDevice(ref Page refPage, EplDeviceProperties deviceProperties) { string msg = EplDefinition.EPL_INSERT_DEVICE.ToString(); try { using (LockingStep oLS = new LockingStep()) { refPage.Project.LockAllObjects(); BoxedDevice oBoxedDevice = new BoxedDevice(); string slib = string.IsNullOrEmpty(deviceProperties.SymbolLibraryName) ? "GB_symbol" : deviceProperties.SymbolLibraryName; SymbolLibrary sLibrary = new SymbolLibrary(refPage.Project, slib); Symbol s = new Symbol(sLibrary, deviceProperties.SymbolName); SymbolVariant sv = new SymbolVariant(); sv.Initialize(s, 0); oBoxedDevice.Create(refPage); oBoxedDevice.SymbolVariant = sv; //oBoxedDevice.Properties.FUNC_DES = deviceProperties.SymbolDescription; if (!string.IsNullOrEmpty(deviceProperties.PartName)) { oBoxedDevice.AddArticleReference(deviceProperties.PartName); } oBoxedDevice.VisibleName = deviceProperties.DisplayText; oBoxedDevice.Properties.FUNC_TEXT = deviceProperties.FunctionText; oBoxedDevice.Location = deviceProperties.Location; oBoxedDevice.Properties.FUNC_GRAVINGTEXT = deviceProperties.EngravingText; oBoxedDevice.Properties.FUNC_TECHNICAL_CHARACTERISTIC = deviceProperties.Characteristics; if (deviceProperties.ConnectionDesignations != null) { for (int i = 0; i < deviceProperties.ConnectionDesignations.Length; i++) { oBoxedDevice.Properties.FUNC_CONNECTIONDESIGNATION[i + 1] = deviceProperties.ConnectionDesignations[i]; if (deviceProperties.ConnectionPointDescription != null) { if (deviceProperties.ConnectionPointDescription.Length > i) { oBoxedDevice.Properties.FUNC_CONNECTIONDESCRIPTION[i + 1] = deviceProperties.ConnectionPointDescription[i]; } } } } oBoxedDevice.Properties.FUNC_MOUNTINGLOCATION = deviceProperties.MountingSite; } } catch (Exception ex) { EplException("Insert device error.", ex); msg = EplError.EPL_ERROR.ToString(); } return(msg); }
public static string InsertSymbol(ref Page refPage, EplSymbolProperties symbolProperties) { string msg = EplDefinition.EPL_INSERT_SYMBOL_MCR.ToString(); try { using (LockingStep oLS = new LockingStep()) { refPage.Project.LockAllObjects(); SymbolLibrary symboLib = new SymbolLibrary(refPage.Project, symbolProperties.SymbolLibraryName); Symbol symbol = new Symbol(symboLib, symbolProperties.SymbolName); SymbolVariant oSymbolVariant = new SymbolVariant(); oSymbolVariant.Initialize(symbol, symbolProperties.SymbolVariant); Function function = new Function(); function.Create(refPage, oSymbolVariant); //function.Properties.FUNC_SYMB_DESC = symbolProperties.SymbolDescription; if (!string.IsNullOrEmpty(symbolProperties.PartName)) { function.AddArticleReference(symbolProperties.PartName); } function.VisibleName = symbolProperties.DisplayText; function.Properties.FUNC_TEXT = symbolProperties.FunctionText; function.Location = symbolProperties.Location; function.Properties.FUNC_GRAVINGTEXT = symbolProperties.EngravingText; function.Properties.FUNC_TECHNICAL_CHARACTERISTIC = symbolProperties.Characteristics; if (symbolProperties.ConnectionDesignations != null) { for (int i = 0; i < symbolProperties.ConnectionDesignations.Length; i++) { function.Properties.FUNC_CONNECTIONDESIGNATION[i + 1] = symbolProperties.ConnectionDesignations[i]; if (symbolProperties.ConnectionPointDescription != null) { if (symbolProperties.ConnectionPointDescription.Length > i) { function.Properties.FUNC_CONNECTIONDESCRIPTION[i + 1] = symbolProperties.ConnectionPointDescription[i]; } } } } function.Properties.FUNC_MOUNTINGLOCATION = symbolProperties.MountingSite; } } catch (Exception ex) { EplException("Insert symbol error.", ex); msg = EplError.EPL_ERROR.ToString(); } return(msg); }
public static void RunAction() { Trace.Listeners.Add(m_oTrace); using (LockingStep o = new LockingStep()) { //call all EPLAN code from here string m_strOpenProjectName = @"EPLAN-DEMO.elk"; string strProjectPath = new Settings().GetExpandedStringSetting("USER.TrDMProject.Masterdata.Pathnames.Projects", 0); strProjectPath += "\\" + m_strOpenProjectName; if (new ProjectManager().ExistsProject(strProjectPath)) { Project oOpenProject = new ProjectManager().OpenProject(strProjectPath); Trace.WriteLine("Opened project: " + strProjectPath); } else { Trace.WriteLine("Can not find project: " + strProjectPath); } } }
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(); } }