EPLAN API 入门系列- 提高篇(Common)

New Page:

View Code
1 public Page newPage(Project oProject, string strPageName)

2 {

3     return new Page(oProject, DocumentTypeManager.DocumentType.TitlePage,

4         new PagePropertyList { 

5             DESIGNATION_LOCATION = this.Location, 

6             DESIGNATION_PLANT = this.Plant, 

7             PAGE_COUNTER = strPageName 

8         });

9 }

set GraphicalLayerTable:

View Code
 1 public bool setGraphicalLayerTable(string layer, Project project)

 2 {

 3     try

 4     { 

 5         GraphicalLayerTable graphLayerTalbe = project.LayerTable;

 6         if (graphLayerTalbe.Layers.Length != 0)

 7         {

 8             this.Gplayer = graphLayerTalbe.Layers[0];

 9         }

10 

11         foreach (GraphicalLayer graphLayer in graphLayerTalbe.Layers)

12         {

13             if (graphLayer.Name == layer)

14             {

15                 this.Gplayer = graphLayer;

16             }

17         }

18 

19         return true;

20     }

21     catch

22     {

23         return false;

24     }

25 }

get SelectedProject:

View Code
 1 public static Project GetSelectedProject(bool bWithWindow)

 2 {

 3     Project oProject = new SelectionSet().GetCurrentProject(bWithWindow);

 4     if (oProject != null)

 5     {

 6         return oProject;

 7     }

 8 

 9     MessageBox.Show("check","name", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);

10 

11     return null;

12 }

get SelectedPages:

View Code
 1 public static ArrayList GetSelectedPages(Project project, out bool isProjectSelected)

 2 {

 3     ArrayList lPages = new ArrayList();

 4     SelectionSet oSelSet = new SelectionSet();

 5     StorableObject[] arrSel = oSelSet.Selection;

 6     isProjectSelected = false;

 7     foreach (StorableObject obj in arrSel)

 8     {

 9         if (obj is Project)

10         {

11             if ((obj as Project) == project)

12             {

13                 isProjectSelected = true;

14                 lPages.AddRange((obj as Project).Pages);

15                 return lPages;

16             }

17         }

18         else if (obj is Page)

19         {

20             if ((obj as Page).Project == project)

21             {

22                 lPages.Add(obj as Page);

23             }

24         }

25         else if (((obj is Placement) && ((obj as Placement).Project == project)) 

26             && !(((obj as Placement).Page == null) || lPages.Contains((obj as Placement).Page)))

27         {

28             lPages.Add((obj as Placement).Page);

29         }

30     }

31     return lPages;

32 }

get GuiLang:

View Code
 1 public static ISOCode.Language GetGuiLang()

 2 {

 3     ISOCode.Language lGui = new ISOCode(GetGuiLanguage()).GetNumber();

 4     switch (lGui)

 5     {

 6         case (ISOCode.Language.L_hr_BA | ISOCode.Language.L_am_AM):

 7         case ISOCode.Language.L___:

 8             return ISOCode.Language.L_en_US;

 9     }

10     return lGui;

11 }

setConnectionsToArray:

View Code
 1 ArrayList ConnArrList = new ArrayList();

 2 SelectionSet oSelSet = new SelectionSet();

 3 

 4 foreach (Eplan.EplApi.DataModel.Page page in oSelectionSet.GetSelectedPages())

 5 {

 6    DMObjectsFinder dmf = new DMObjectsFinder(oProject);

 7    ConnectionsFilter oConnF = new ConnectionsFilter();

 8    oConnF.Page = page;

 9    Connection[] arrConn = dmf.GetConnections(oConnF);

10    foreach (var conn in arrConn)

11    {

12          ConnArrList.Add(conn);

13     }

14 }

15 

16 Connection[] oConnections = (Connection[])ConnArrList.ToArray(typeof(Connection));

 

 

你可能感兴趣的:(com)