hytos / DTI_PID / APIDConverter / Utils / APIDUtils.cs @ 53344e2c
이력 | 보기 | 이력해설 | 다운로드 (4.11 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using System.IO; |
7 |
using System.Reflection; |
8 |
using Autodesk.AutoCAD.EditorInput; |
9 |
|
10 |
using AVEVA.PID.Components; |
11 |
using AVEVA.PID.GUI; |
12 |
using AVEVA.PID.Common; |
13 |
using AVEVA.PID.DWGSelector; |
14 |
|
15 |
using AVEVA.PID.CustomizationUtility.DB; |
16 |
using AVEVA.PID.CustomizationUtility.Model; |
17 |
using AVEVA.PID.CustomizationUtility.Properties; |
18 |
|
19 |
namespace AVEVA.PID.CustomizationUtility |
20 |
{ |
21 |
public class APIDUtils |
22 |
{ |
23 |
#region APID Converter |
24 |
public static object FindObjectByUID(Document document, string UID) |
25 |
{ |
26 |
if (!string.IsNullOrEmpty(UID) && UID != "None") |
27 |
{ |
28 |
foreach (PlantItem item in document.PlantItems) |
29 |
{ |
30 |
if (item.UID == UID) |
31 |
return item; |
32 |
} |
33 |
} |
34 |
|
35 |
return null; |
36 |
} |
37 |
public static bool ConvertPointBystring(string sPoint, ref double dX, ref double dY) |
38 |
{ |
39 |
try |
40 |
{ |
41 |
string[] pointArr = sPoint.Split(new char[] { ',' }); |
42 |
if (pointArr.Length == 2) |
43 |
{ |
44 |
dX = Convert.ToDouble(pointArr[0]); |
45 |
dY = Convert.ToDouble(pointArr[1]); |
46 |
} |
47 |
} |
48 |
catch (Exception) |
49 |
{ |
50 |
dX = 0; |
51 |
dY = 0; |
52 |
return false; |
53 |
} |
54 |
|
55 |
return true; |
56 |
} |
57 |
public static bool IsConnectedLine(Line line1, Line line2) |
58 |
{ |
59 |
bool result = false; |
60 |
|
61 |
if (line1.CONNECTORS.Find(x => x.ConnectedObject == line2) != null && |
62 |
line2.CONNECTORS.Find(x => x.ConnectedObject == line1) != null) |
63 |
result = true; |
64 |
|
65 |
return result; |
66 |
} |
67 |
#endregion |
68 |
|
69 |
#region Only AVEVA |
70 |
public static void SetAvevaExplorer() |
71 |
{ |
72 |
bool exist = false; |
73 |
string sName = "APID Converter"; |
74 |
for (int i = 0; i < Aveva.Command.AvevaCommands.projectExplorer.Count; i++) |
75 |
{ |
76 |
if (Aveva.Command.AvevaCommands.projectExplorer[i].Name == sName) |
77 |
{ |
78 |
exist = true; |
79 |
Aveva.Command.AvevaCommands.projectExplorer.Remove(i); |
80 |
break; |
81 |
} |
82 |
} |
83 |
|
84 |
if (!exist) |
85 |
{ |
86 |
Aveva.Command.AvevaCommands.projectExplorer.Add(sName, new APIDConverterExplorer()); |
87 |
Aveva.Command.AvevaCommands.projectExplorer.Activate(Aveva.Command.AvevaCommands.projectExplorer.Count - 1); |
88 |
} |
89 |
} |
90 |
public static List<string> GetPipeStyle() |
91 |
{ |
92 |
List<string> list = new List<string>(); |
93 |
Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_PIPE_PANEL"); |
94 |
object objPipeStyle = GUIUtils.FindItem(items, "PIPESTYLE"); |
95 |
if (objPipeStyle != null) |
96 |
{ |
97 |
Autodesk.Windows.RibbonCombo pipeStyleCombo = objPipeStyle as Autodesk.Windows.RibbonCombo; |
98 |
foreach (var item in pipeStyleCombo.Items) |
99 |
{ |
100 |
Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton; |
101 |
list.Add(loop.AutomationName); |
102 |
} |
103 |
} |
104 |
|
105 |
return list; |
106 |
} |
107 |
public static List<string> GetSignalStyle() |
108 |
{ |
109 |
List<string> list = new List<string>(); |
110 |
Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_SIGNAL_PANEL"); |
111 |
object objPipeStyle = GUIUtils.FindItem(items, "SIGNALSTYLE"); |
112 |
if (objPipeStyle != null) |
113 |
{ |
114 |
Autodesk.Windows.RibbonCombo pipeStyleCombo = objPipeStyle as Autodesk.Windows.RibbonCombo; |
115 |
foreach (var item in pipeStyleCombo.Items) |
116 |
{ |
117 |
Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton; |
118 |
list.Add(loop.AutomationName); |
119 |
} |
120 |
} |
121 |
|
122 |
return list; |
123 |
} |
124 |
#endregion |
125 |
} |
126 |
} |