hytos / DTI_PID / APIDConverter / Utils / APIDUtils.cs @ 2d09df82
이력 | 보기 | 이력해설 | 다운로드 (4.65 KB)
1 | 4e320fcb | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | 59184d1b | gaqhf | using System.IO; |
7 | using System.Reflection; |
||
8 | 14540282 | gaqhf | using Autodesk.AutoCAD.EditorInput; |
9 | 59184d1b | gaqhf | |
10 | using AVEVA.PID.Components; |
||
11 | using AVEVA.PID.GUI; |
||
12 | using AVEVA.PID.Common; |
||
13 | using AVEVA.PID.DWGSelector; |
||
14 | 4e320fcb | gaqhf | |
15 | 5aec7e24 | gaqhf | using AVEVA.PID.CustomizationUtility.DB; |
16 | using AVEVA.PID.CustomizationUtility.Model; |
||
17 | using AVEVA.PID.CustomizationUtility.Properties; |
||
18 | |||
19 | 4e320fcb | gaqhf | namespace AVEVA.PID.CustomizationUtility |
20 | { |
||
21 | public class APIDUtils |
||
22 | { |
||
23 | 32954c7f | gaqhf | #region APID Converter |
24 | 5aec7e24 | gaqhf | 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 | 4e320fcb | gaqhf | |
35 | 5aec7e24 | gaqhf | return null; |
36 | } |
||
37 | 32954c7f | gaqhf | 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 | 53344e2c | gaqhf | 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 | 016701e5 | gaqhf | public static SlopeType CalcSlope(double x1, double y1, double x2, double y2) |
68 | { |
||
69 | if (x1 - x2 == 0) |
||
70 | return SlopeType.VERTICAL; |
||
71 | else |
||
72 | { |
||
73 | double angle = Math.Atan(Math.Abs(y2 - y1) / Math.Abs(x2 - x1)) * 180 / Math.PI; |
||
74 | if (angle <= 15) |
||
75 | return SlopeType.HORIZONTAL; |
||
76 | else if (angle >= 75) |
||
77 | return SlopeType.VERTICAL; |
||
78 | else |
||
79 | return SlopeType.Slope; |
||
80 | } |
||
81 | } |
||
82 | 32954c7f | gaqhf | #endregion |
83 | 88cb9898 | gaqhf | |
84 | 32954c7f | gaqhf | #region Only AVEVA |
85 | 88cb9898 | gaqhf | public static void SetAvevaExplorer() |
86 | { |
||
87 | bool exist = false; |
||
88 | string sName = "APID Converter"; |
||
89 | for (int i = 0; i < Aveva.Command.AvevaCommands.projectExplorer.Count; i++) |
||
90 | { |
||
91 | if (Aveva.Command.AvevaCommands.projectExplorer[i].Name == sName) |
||
92 | { |
||
93 | exist = true; |
||
94 | Aveva.Command.AvevaCommands.projectExplorer.Remove(i); |
||
95 | break; |
||
96 | } |
||
97 | } |
||
98 | |||
99 | if (!exist) |
||
100 | { |
||
101 | Aveva.Command.AvevaCommands.projectExplorer.Add(sName, new APIDConverterExplorer()); |
||
102 | Aveva.Command.AvevaCommands.projectExplorer.Activate(Aveva.Command.AvevaCommands.projectExplorer.Count - 1); |
||
103 | } |
||
104 | 9ee9b61d | gaqhf | } |
105 | public static List<string> GetPipeStyle() |
||
106 | { |
||
107 | List<string> list = new List<string>(); |
||
108 | Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_PIPE_PANEL"); |
||
109 | object objPipeStyle = GUIUtils.FindItem(items, "PIPESTYLE"); |
||
110 | if (objPipeStyle != null) |
||
111 | { |
||
112 | Autodesk.Windows.RibbonCombo pipeStyleCombo = objPipeStyle as Autodesk.Windows.RibbonCombo; |
||
113 | foreach (var item in pipeStyleCombo.Items) |
||
114 | { |
||
115 | Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton; |
||
116 | list.Add(loop.AutomationName); |
||
117 | } |
||
118 | } |
||
119 | |||
120 | return list; |
||
121 | } |
||
122 | public static List<string> GetSignalStyle() |
||
123 | { |
||
124 | List<string> list = new List<string>(); |
||
125 | Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_SIGNAL_PANEL"); |
||
126 | object objPipeStyle = GUIUtils.FindItem(items, "SIGNALSTYLE"); |
||
127 | if (objPipeStyle != null) |
||
128 | { |
||
129 | Autodesk.Windows.RibbonCombo pipeStyleCombo = objPipeStyle as Autodesk.Windows.RibbonCombo; |
||
130 | foreach (var item in pipeStyleCombo.Items) |
||
131 | { |
||
132 | Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton; |
||
133 | list.Add(loop.AutomationName); |
||
134 | } |
||
135 | } |
||
136 | |||
137 | return list; |
||
138 | 88cb9898 | gaqhf | } |
139 | 32954c7f | gaqhf | #endregion |
140 | 4e320fcb | gaqhf | } |
141 | } |