hytos / DTI_PID / SPPIDAutoModeling / ItemObject.cs @ 07bf38e1
이력 | 보기 | 이력해설 | 다운로드 (28.5 KB)
1 | cdf18b83 | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | 07bf38e1 | gaqhf | using System.ComponentModel; |
4 | cdf18b83 | gaqhf | using System.Linq; |
5 | 07bf38e1 | gaqhf | using System.Runtime.InteropServices; |
6 | cdf18b83 | gaqhf | using System.Text; |
7 | using System.Threading.Tasks; |
||
8 | using Llama; |
||
9 | using Plaice; |
||
10 | |||
11 | namespace SPPIDAutoModeling |
||
12 | { |
||
13 | public enum SPPID_ITEM_TYPE |
||
14 | { |
||
15 | SYMBOL = 1, |
||
16 | LINE = 2, |
||
17 | LABEL = 3, |
||
18 | TEXT = 4, |
||
19 | } |
||
20 | |||
21 | 21be5063 | gaqhf | public class SymbolChild |
22 | { |
||
23 | private string _Arrow; |
||
24 | private string _Name; |
||
25 | private int _Index; |
||
26 | private string _SPPIDMAPPINGNAME; |
||
27 | private object _SPPID_ITEM_OBJECT; |
||
28 | |||
29 | public string Arrow { get => _Arrow; set => _Arrow = value; } |
||
30 | public string Name { get => _Name; set => _Name = value; } |
||
31 | public int Index { get => _Index; set => _Index = value; } |
||
32 | public string SPPIDMAPPINGNAME { get => _SPPIDMAPPINGNAME; set => _SPPIDMAPPINGNAME = value; } |
||
33 | public object SPPID_ITEM_OBJECT { get => _SPPID_ITEM_OBJECT; set => _SPPID_ITEM_OBJECT = value; } |
||
34 | } |
||
35 | |||
36 | |||
37 | 8056c558 | gaqhf | public class Group |
38 | { |
||
39 | 07bf38e1 | gaqhf | private List<object> _Items = new List<object>(); |
40 | private bool _Enable = true; |
||
41 | 8056c558 | gaqhf | |
42 | 07bf38e1 | gaqhf | public List<object> Items { get => _Items; set => _Items = value; } |
43 | public bool Enable { get => _Enable; set => _Enable = value; } |
||
44 | } |
||
45 | |||
46 | public class Association |
||
47 | { |
||
48 | private string _TYPE; |
||
49 | private string _TYPE_VALUE; |
||
50 | |||
51 | public string TYPE { get => _TYPE; set => _TYPE = value; } |
||
52 | public string TYPE_VALUE { get => _TYPE_VALUE; set => _TYPE_VALUE = value; } |
||
53 | 8056c558 | gaqhf | } |
54 | cdf18b83 | gaqhf | |
55 | 21be5063 | gaqhf | |
56 | |||
57 | cdf18b83 | gaqhf | public class Drawing |
58 | { |
||
59 | #region Property |
||
60 | private string _DWGNAME; |
||
61 | private string _SIZE; |
||
62 | private string _UNIT; |
||
63 | 8056c558 | gaqhf | private List<Symbol> _SYMBOLS = new List<Symbol>(); |
64 | private List<Line> _LINES = new List<Line>(); |
||
65 | private List<LineNumber> _LINENUMBERS = new List<LineNumber>(); |
||
66 | private List<Text> _TEXTS = new List<Text>(); |
||
67 | 07bf38e1 | gaqhf | private Dictionary<string, List<PointInfo>> _PipeRunPoint = new Dictionary<string, List<PointInfo>>(); |
68 | private List<Group> _GROUPS = new List<Group>(); |
||
69 | 8056c558 | gaqhf | |
70 | private double _WIDTH; |
||
71 | private double _HEIGHT; |
||
72 | cdf18b83 | gaqhf | |
73 | public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; } |
||
74 | 8056c558 | gaqhf | public string SIZE |
75 | { |
||
76 | get { return _SIZE; } |
||
77 | set |
||
78 | { |
||
79 | _SIZE = value; |
||
80 | SPPIDUtill.ConvertPointBystring(_SIZE, ref _WIDTH, ref _HEIGHT); |
||
81 | } |
||
82 | } |
||
83 | cdf18b83 | gaqhf | public string UNIT { get => _UNIT; set => _UNIT = value; } |
84 | 07bf38e1 | gaqhf | public Dictionary<string, List<PointInfo>> PipeRunPoint { get => _PipeRunPoint; set => _PipeRunPoint = value; } |
85 | cdf18b83 | gaqhf | public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; } |
86 | public List<Line> LINES { get => _LINES; set => _LINES = value; } |
||
87 | public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; } |
||
88 | public List<Text> TEXTS { get => _TEXTS; set => _TEXTS = value; } |
||
89 | 8056c558 | gaqhf | public double WIDTH { get => _WIDTH; set => _WIDTH = value; } |
90 | public double HEIGHT { get => _HEIGHT; set => _HEIGHT = value; } |
||
91 | 07bf38e1 | gaqhf | public List<Group> GROUPS { get => _GROUPS; set => _GROUPS = value; } |
92 | cdf18b83 | gaqhf | #endregion |
93 | } |
||
94 | 07bf38e1 | gaqhf | |
95 | public class PointInfo |
||
96 | cdf18b83 | gaqhf | { |
97 | 07bf38e1 | gaqhf | public PointInfo(double x, double y) |
98 | { |
||
99 | this.x = x; |
||
100 | this.y = y; |
||
101 | } |
||
102 | |||
103 | cdf18b83 | gaqhf | public enum PointType |
104 | { |
||
105 | 8056c558 | gaqhf | None = 0, |
106 | Run = 1, |
||
107 | Branch = 2, |
||
108 | cdf18b83 | gaqhf | } |
109 | #region Property |
||
110 | 07bf38e1 | gaqhf | private double x; |
111 | private double y; |
||
112 | cdf18b83 | gaqhf | private PointType _Type; |
113 | 07bf38e1 | gaqhf | private string _ConnectedItem; |
114 | cdf18b83 | gaqhf | private string _SP_ID; |
115 | 07bf38e1 | gaqhf | private SPPID_ITEM _ConnectedItemObject; |
116 | cdf18b83 | gaqhf | |
117 | 07bf38e1 | gaqhf | public double X { get { return x; } set { x = value; } } |
118 | public double Y { get { return y; } set { y = value; } } |
||
119 | cdf18b83 | gaqhf | public PointType Type { get => _Type; set => _Type = value; } |
120 | 07bf38e1 | gaqhf | public string ConnectedItem { get => _ConnectedItem; set => _ConnectedItem = value; } |
121 | public SPPID_ITEM ConnectedItemObject { get => _ConnectedItemObject; set => _ConnectedItemObject = value; } |
||
122 | cdf18b83 | gaqhf | public string SP_ID { get => _SP_ID; set => _SP_ID = value; } |
123 | #endregion |
||
124 | } |
||
125 | |||
126 | |||
127 | public abstract class SPPID_ITEM |
||
128 | { |
||
129 | #region Property |
||
130 | private string _UID; |
||
131 | private string _TYPE; |
||
132 | private string _NAME; |
||
133 | private SPPID_ITEM_TYPE _SPPID_TYPE ; |
||
134 | private string _SPPIDMAPPINGNAME; |
||
135 | 07bf38e1 | gaqhf | private bool _GROUPING; |
136 | cdf18b83 | gaqhf | private string _AREA; |
137 | 07bf38e1 | gaqhf | private List<ItemAttribute> _ATTRIBUTES = new List<ItemAttribute>(); |
138 | cdf18b83 | gaqhf | private object _SPPID_ITEM_OBJECT; |
139 | |||
140 | public string UID { get => _UID; set => _UID = value; } |
||
141 | public string TYPE { get => _TYPE; set => _TYPE = value; } |
||
142 | public string NAME { get => _NAME; set => _NAME = value; } |
||
143 | public string SPPIDMAPPINGNAME { get => _SPPIDMAPPINGNAME; set => _SPPIDMAPPINGNAME = value; } |
||
144 | public bool GROUPING { get => _GROUPING; set => _GROUPING = value; } |
||
145 | public string AREA { get => _AREA; set => _AREA = value; } |
||
146 | public object SPPID_ITEM_OBJECT { get => _SPPID_ITEM_OBJECT; set => _SPPID_ITEM_OBJECT = value; } |
||
147 | public SPPID_ITEM_TYPE SPPID_TYPE { get => _SPPID_TYPE; set => _SPPID_TYPE = value; } |
||
148 | 07bf38e1 | gaqhf | public List<ItemAttribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; } |
149 | cdf18b83 | gaqhf | #endregion |
150 | 8056c558 | gaqhf | |
151 | 07bf38e1 | gaqhf | public abstract bool Modeling(); |
152 | cdf18b83 | gaqhf | public abstract void AfterSetting(); |
153 | public abstract void SetAttribute(); |
||
154 | } |
||
155 | |||
156 | public class Symbol : SPPID_ITEM |
||
157 | { |
||
158 | #region Property |
||
159 | private string _ORIGINALPOINT; |
||
160 | 07bf38e1 | gaqhf | private List<Association> _ASSOCIATIONS = new List<Association>(); |
161 | 8056c558 | gaqhf | private List<Connector> _CONNECTORS = new List<Connector>(); |
162 | 21be5063 | gaqhf | private string _CONNECTIONPOINT; |
163 | cdf18b83 | gaqhf | private string _LOCATION; |
164 | private string _SIZE; |
||
165 | private double _ANGLE; |
||
166 | private string _PARENT; |
||
167 | 21be5063 | gaqhf | private string _CHILD; |
168 | private List<SymbolChild> _CHILD_LIST = new List<SymbolChild>(); |
||
169 | cdf18b83 | gaqhf | private string _HASINSTRUMENTLABEL; |
170 | private string _CURRENTPOINTMODEINDEX; |
||
171 | private bool _DRAWCHECKED; |
||
172 | private double _LOCATION_X; |
||
173 | private double _LOCATION_Y; |
||
174 | private int _MIRROR = 0; |
||
175 | |||
176 | public string ORIGINALPOINT { get => _ORIGINALPOINT; set => _ORIGINALPOINT = value; } |
||
177 | public string LOCATION { get => _LOCATION; set => _LOCATION = value; } |
||
178 | public string SIZE { get => _SIZE; set => _SIZE = value; } |
||
179 | public double ANGLE { get => _ANGLE; set => _ANGLE = value; } |
||
180 | public string PARENT { get => _PARENT; set => _PARENT = value; } |
||
181 | 21be5063 | gaqhf | public string CHILD { get => _CHILD; set => _CHILD = value; } |
182 | cdf18b83 | gaqhf | public string HASINSTRUMENTLABEL { get => _HASINSTRUMENTLABEL; set => _HASINSTRUMENTLABEL = value; } |
183 | public string CURRENTPOINTMODEINDEX { get => _CURRENTPOINTMODEINDEX; set => _CURRENTPOINTMODEINDEX = value; } |
||
184 | public bool DRAWCHECKED { get => _DRAWCHECKED; set => _DRAWCHECKED = value; } |
||
185 | public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; } |
||
186 | public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; } |
||
187 | public int MIRROR { get => _MIRROR; set => _MIRROR = value; } |
||
188 | public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; } |
||
189 | 21be5063 | gaqhf | public string CONNECTIONPOINT { get => _CONNECTIONPOINT; set => _CONNECTIONPOINT = value; } |
190 | public List<SymbolChild> CHILD_LIST { get => _CHILD_LIST; set => _CHILD_LIST = value; } |
||
191 | 07bf38e1 | gaqhf | public List<Association> ASSOCIATIONS { get => _ASSOCIATIONS; set => _ASSOCIATIONS = value; } |
192 | cdf18b83 | gaqhf | #endregion |
193 | public override void AfterSetting() |
||
194 | { |
||
195 | 21be5063 | gaqhf | // SPPIDMAPPINGNAME Setting |
196 | 07bf38e1 | gaqhf | SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(PARENT); |
197 | 21be5063 | gaqhf | // End |
198 | |||
199 | cdf18b83 | gaqhf | // Angle Setting |
200 | if (ANGLE == 1.57) |
||
201 | ANGLE = 90 * Math.PI / 180; |
||
202 | else if (ANGLE == 3.14) |
||
203 | ANGLE = Math.PI; |
||
204 | else if (ANGLE == 4.71) |
||
205 | ANGLE = 270 * Math.PI / 180; |
||
206 | else |
||
207 | ANGLE = 0; |
||
208 | // End |
||
209 | |||
210 | // Location Setting |
||
211 | 8056c558 | gaqhf | SPPIDUtill.ConvertPointBystring(_ORIGINALPOINT, ref _LOCATION_X, ref _LOCATION_Y); |
212 | SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT); |
||
213 | // End |
||
214 | cdf18b83 | gaqhf | |
215 | 21be5063 | gaqhf | // SPPID Type Setting |
216 | 8056c558 | gaqhf | SPPID_TYPE = SPPID_ITEM_TYPE.SYMBOL; |
217 | cdf18b83 | gaqhf | // End |
218 | 21be5063 | gaqhf | |
219 | // Child Setting |
||
220 | if (!string.IsNullOrEmpty(CHILD) && CHILD != "None") |
||
221 | { |
||
222 | 07bf38e1 | gaqhf | string[] array = CHILD.Split(new char[] { ',' }); |
223 | for (int i = 0; i < array.Length; i++) |
||
224 | 21be5063 | gaqhf | { |
225 | SymbolChild child = new SymbolChild() |
||
226 | { |
||
227 | 07bf38e1 | gaqhf | Arrow = array[0], |
228 | Name = array[1], |
||
229 | Index = i + 1, |
||
230 | 21be5063 | gaqhf | }; |
231 | child.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(child.Name); |
||
232 | CHILD_LIST.Add(child); |
||
233 | } |
||
234 | } |
||
235 | // End |
||
236 | |||
237 | 07bf38e1 | gaqhf | // ConnectionPoint Setting |
238 | if (!string.IsNullOrEmpty(CONNECTIONPOINT) && CONNECTIONPOINT != "None") |
||
239 | { |
||
240 | string[] array = CONNECTIONPOINT.Split(new char[] { '/' }); |
||
241 | for (int i = 0; i < array.Length; i++) |
||
242 | { |
||
243 | string[] arrConn = array[i].Split(new char[] { ',' }); |
||
244 | CONNECTORS[i].INDEX = Convert.ToInt32(arrConn[3]); |
||
245 | } |
||
246 | } |
||
247 | // End |
||
248 | |||
249 | 21be5063 | gaqhf | // Input Drawing |
250 | AutoModeling.DrawingItem.SYMBOLS.Add(this); |
||
251 | // End |
||
252 | cdf18b83 | gaqhf | } |
253 | |||
254 | 07bf38e1 | gaqhf | public override bool Modeling() |
255 | cdf18b83 | gaqhf | { |
256 | 8056c558 | gaqhf | try |
257 | { |
||
258 | Placement _placement = new Placement(); |
||
259 | LMSymbol lmSymbol = null; |
||
260 | SPPID_ITEM_OBJECT = null; |
||
261 | |||
262 | if (!string.IsNullOrEmpty(SPPIDMAPPINGNAME)) |
||
263 | { |
||
264 | LMSymbol connectedSymbol = null; |
||
265 | foreach (Connector connector in CONNECTORS) |
||
266 | { |
||
267 | if (!string.IsNullOrEmpty(connector.CONNECTEDITEM) || connector.CONNECTEDITEM != "None") |
||
268 | { |
||
269 | object _obj = SPPIDUtill.FindObjectByUID(connector.CONNECTEDITEM); |
||
270 | if (_obj != null && typeof(Symbol) == _obj.GetType()) |
||
271 | { |
||
272 | Symbol _symbol = _obj as Symbol; |
||
273 | if (_symbol.SPPID_ITEM_OBJECT != null) |
||
274 | connectedSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol; |
||
275 | } |
||
276 | } |
||
277 | } |
||
278 | |||
279 | if (connectedSymbol != null) |
||
280 | lmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Mirror: MIRROR, Rotation: ANGLE, TargetItem: connectedSymbol); |
||
281 | else |
||
282 | lmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Mirror: MIRROR, Rotation: ANGLE); |
||
283 | |||
284 | // Commit and input sppid item object |
||
285 | lmSymbol.Commit(); |
||
286 | SPPID_ITEM_OBJECT = lmSymbol; |
||
287 | // End |
||
288 | |||
289 | // Check Child And Modeling |
||
290 | 21be5063 | gaqhf | foreach (SymbolChild symoblChild in CHILD_LIST) |
291 | 8056c558 | gaqhf | { |
292 | try |
||
293 | { |
||
294 | 21be5063 | gaqhf | string sArrow = symoblChild.Arrow; |
295 | string sMappingName = symoblChild.SPPIDMAPPINGNAME; |
||
296 | 8056c558 | gaqhf | |
297 | double dChildAngle = 0; |
||
298 | if (sArrow == "UP") |
||
299 | dChildAngle = 0; |
||
300 | else if (sArrow == "RIGHT") |
||
301 | dChildAngle = 90 * Math.PI / 180; |
||
302 | else if (sArrow == "DOWN") |
||
303 | dChildAngle = Math.PI; |
||
304 | else |
||
305 | dChildAngle = 270 * Math.PI / 180; |
||
306 | |||
307 | LMSymbol _childLmSymbol = _placement.PIDPlaceSymbol(sMappingName, LOCATION_X, LOCATION_Y, Mirror: 0, Rotation: dChildAngle, TargetItem: SPPID_ITEM_OBJECT); |
||
308 | _childLmSymbol.Commit(); |
||
309 | 21be5063 | gaqhf | symoblChild.SPPID_ITEM_OBJECT = _childLmSymbol; |
310 | 8056c558 | gaqhf | } |
311 | 07bf38e1 | gaqhf | catch (Exception ex) |
312 | 8056c558 | gaqhf | { |
313 | 07bf38e1 | gaqhf | Console.WriteLine(ex.StackTrace); |
314 | } |
||
315 | } |
||
316 | // End |
||
317 | 21be5063 | gaqhf | |
318 | 07bf38e1 | gaqhf | // Association Modeling |
319 | try |
||
320 | { |
||
321 | foreach (Association item in ASSOCIATIONS) |
||
322 | { |
||
323 | object _obj = SPPIDUtill.FindObjectByUID(item.TYPE_VALUE); |
||
324 | if (_obj != null && typeof(Text) == _obj.GetType()) |
||
325 | { |
||
326 | Text text = _obj as Text; |
||
327 | if (text.NAME == "SIZE") |
||
328 | { |
||
329 | text.OWNER = UID; |
||
330 | text.Modeling(); |
||
331 | text.SetAttribute(); |
||
332 | } |
||
333 | } |
||
334 | 8056c558 | gaqhf | } |
335 | } |
||
336 | 07bf38e1 | gaqhf | catch (Exception ex) |
337 | { |
||
338 | Console.WriteLine(ex.StackTrace); |
||
339 | } |
||
340 | 8056c558 | gaqhf | // End |
341 | } |
||
342 | } |
||
343 | 07bf38e1 | gaqhf | catch (Exception ex) |
344 | 8056c558 | gaqhf | { |
345 | 07bf38e1 | gaqhf | Console.WriteLine(ex.StackTrace); |
346 | return false; |
||
347 | 8056c558 | gaqhf | } |
348 | 07bf38e1 | gaqhf | return true; |
349 | cdf18b83 | gaqhf | } |
350 | |||
351 | public override void SetAttribute() |
||
352 | { |
||
353 | throw new NotImplementedException(); |
||
354 | } |
||
355 | } |
||
356 | |||
357 | public class Line : SPPID_ITEM |
||
358 | { |
||
359 | 07bf38e1 | gaqhf | public enum SlopeType |
360 | cdf18b83 | gaqhf | { |
361 | NONE = 0, |
||
362 | VERTICAL = 1, |
||
363 | HORIZONTAL = 2, |
||
364 | SLOPE = 3, |
||
365 | } |
||
366 | #region Property |
||
367 | private string _STARTPOINT; |
||
368 | private string _ENDPOINT; |
||
369 | 8056c558 | gaqhf | private List<Connector> _CONNECTORS = new List<Connector>(); |
370 | 07bf38e1 | gaqhf | private SlopeType _SLOPTYPE; |
371 | cdf18b83 | gaqhf | private double _START_X; |
372 | private double _START_Y; |
||
373 | private double _END_X; |
||
374 | private double _END_Y; |
||
375 | |||
376 | public string STARTPOINT { get => _STARTPOINT; set => _STARTPOINT = value; } |
||
377 | public string ENDPOINT { get => _ENDPOINT; set => _ENDPOINT = value; } |
||
378 | public double START_X { get => _START_X; set => _START_X = value; } |
||
379 | public double START_Y { get => _START_Y; set => _START_Y = value; } |
||
380 | public double END_X { get => _END_X; set => _END_X = value; } |
||
381 | public double END_Y { get => _END_Y; set => _END_Y = value; } |
||
382 | public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; } |
||
383 | 07bf38e1 | gaqhf | public SlopeType SLOPTYPE { get => _SLOPTYPE; set => _SLOPTYPE = value; } |
384 | cdf18b83 | gaqhf | #endregion |
385 | public override void AfterSetting() |
||
386 | { |
||
387 | 21be5063 | gaqhf | // SPPIDMAPPINGNAME Setting |
388 | 07bf38e1 | gaqhf | SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(TYPE); |
389 | 21be5063 | gaqhf | // End |
390 | |||
391 | 8056c558 | gaqhf | // Point Setting |
392 | SPPIDUtill.ConvertPointBystring(_STARTPOINT, ref _START_X, ref _START_Y); |
||
393 | SPPIDUtill.ConvertSPPIDPoint(ref _START_X, ref _START_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT); |
||
394 | SPPIDUtill.ConvertPointBystring(_ENDPOINT, ref _END_X, ref _END_Y); |
||
395 | SPPIDUtill.ConvertSPPIDPoint(ref _END_X,ref _END_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT); |
||
396 | // End |
||
397 | |||
398 | // Slop Setting |
||
399 | 07bf38e1 | gaqhf | SLOPTYPE = SPPIDUtill.CalcSlop(new PointInfo(_START_X, _START_Y), new PointInfo(_END_X, _END_Y)); |
400 | 8056c558 | gaqhf | // End |
401 | |||
402 | // SPPID Type Setting |
||
403 | SPPID_TYPE = SPPID_ITEM_TYPE.LINE; |
||
404 | // End |
||
405 | 21be5063 | gaqhf | |
406 | // Input Drawing |
||
407 | AutoModeling.DrawingItem.LINES.Add(this); |
||
408 | // End |
||
409 | cdf18b83 | gaqhf | } |
410 | |||
411 | 07bf38e1 | gaqhf | public override bool Modeling() |
412 | cdf18b83 | gaqhf | { |
413 | 8056c558 | gaqhf | throw new MissingMethodException(); |
414 | cdf18b83 | gaqhf | } |
415 | |||
416 | public override void SetAttribute() |
||
417 | { |
||
418 | throw new NotImplementedException(); |
||
419 | } |
||
420 | } |
||
421 | |||
422 | public class LineNumber : SPPID_ITEM |
||
423 | { |
||
424 | public enum LineNumberType |
||
425 | { |
||
426 | LineNumber = 1, |
||
427 | TrimLine = 2, |
||
428 | } |
||
429 | #region Property |
||
430 | 8056c558 | gaqhf | private double _ANGLE; |
431 | cdf18b83 | gaqhf | private string _LOCATION; |
432 | private double _LOCATION_X; |
||
433 | private double _LOCATION_Y; |
||
434 | private string _TEXT; |
||
435 | private string _CONNECTLINE; |
||
436 | private LineNumberType _LINENUMBERTYPE; |
||
437 | |||
438 | 8056c558 | gaqhf | public double ANGLE { get => _ANGLE; set => _ANGLE = value; } |
439 | cdf18b83 | gaqhf | public string LOCATION { get => _LOCATION; set => _LOCATION = value; } |
440 | public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; } |
||
441 | public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; } |
||
442 | public string TEXT { get => _TEXT; set => _TEXT = value; } |
||
443 | public string CONNECTLINE { get => _CONNECTLINE; set => _CONNECTLINE = value; } |
||
444 | public LineNumberType LINENUMBERTYPE { get => _LINENUMBERTYPE; set => _LINENUMBERTYPE = value; } |
||
445 | #endregion |
||
446 | |||
447 | public override void AfterSetting() |
||
448 | { |
||
449 | 21be5063 | gaqhf | // SPPIDMAPPINGNAME Setting |
450 | SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME); |
||
451 | // End |
||
452 | |||
453 | 8056c558 | gaqhf | // Angle Setting |
454 | if (ANGLE == 1.57) |
||
455 | ANGLE = 90 * Math.PI / 180; |
||
456 | else if (ANGLE == 3.14) |
||
457 | ANGLE = Math.PI; |
||
458 | else if (ANGLE == 4.71) |
||
459 | ANGLE = 270 * Math.PI / 180; |
||
460 | else |
||
461 | ANGLE = 0; |
||
462 | // End |
||
463 | |||
464 | // Location Setting |
||
465 | SPPIDUtill.ConvertPointBystring(_LOCATION, ref _LOCATION_X, ref _LOCATION_Y); |
||
466 | SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT); |
||
467 | // End |
||
468 | |||
469 | // SPPID Type Setting |
||
470 | SPPID_TYPE = SPPID_ITEM_TYPE.LABEL; |
||
471 | // End |
||
472 | 21be5063 | gaqhf | |
473 | // Input Drawing |
||
474 | AutoModeling.DrawingItem.LINENUMBERS.Add(this); |
||
475 | // End |
||
476 | cdf18b83 | gaqhf | } |
477 | |||
478 | 07bf38e1 | gaqhf | public override bool Modeling() |
479 | cdf18b83 | gaqhf | { |
480 | 8056c558 | gaqhf | try |
481 | { |
||
482 | 07bf38e1 | gaqhf | Line targetLine = SPPIDUtill.FindObjectByUID(CONNECTLINE) as Line; |
483 | if (targetLine != null && !string.IsNullOrEmpty(targetLine.SPPID_ITEM_OBJECT.ToString())) |
||
484 | 8056c558 | gaqhf | { |
485 | Placement _placement = new Placement(); |
||
486 | 07bf38e1 | gaqhf | Array points = new double[] { 0, LOCATION_X, LOCATION_Y }; |
487 | LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(targetLine.SPPID_ITEM_OBJECT.ToString()); |
||
488 | 8056c558 | gaqhf | if (_pipeRun != null) |
489 | { |
||
490 | foreach (LMRepresentation rep in _pipeRun.Representations) |
||
491 | { |
||
492 | if (rep.get_RepresentationType() == "Connector" && rep.get_ItemStatus() == "Active") |
||
493 | { |
||
494 | LMConnector _LmConnector = _placement.PIDDataSource.GetConnector(rep.Id); |
||
495 | LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref points, Rotation: ANGLE, LabeledItem: _LmConnector.AsLMRepresentation(), IsLeaderVisible: true); |
||
496 | _LmLabelPresist.Commit(); |
||
497 | SPPID_ITEM_OBJECT = _LmLabelPresist; |
||
498 | } |
||
499 | } |
||
500 | } |
||
501 | } |
||
502 | } |
||
503 | 07bf38e1 | gaqhf | catch (Exception ex) |
504 | 8056c558 | gaqhf | { |
505 | 07bf38e1 | gaqhf | Console.WriteLine(ex.StackTrace); |
506 | return false; |
||
507 | 8056c558 | gaqhf | } |
508 | 07bf38e1 | gaqhf | return true; |
509 | cdf18b83 | gaqhf | } |
510 | |||
511 | public override void SetAttribute() |
||
512 | { |
||
513 | 07bf38e1 | gaqhf | try |
514 | { |
||
515 | Line targetLine = SPPIDUtill.FindObjectByUID(CONNECTLINE) as Line; |
||
516 | if (targetLine != null) |
||
517 | { |
||
518 | Placement _placement = new Placement(); |
||
519 | LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(targetLine.SPPID_ITEM_OBJECT.ToString()); |
||
520 | |||
521 | foreach (ItemAttribute attr in ATTRIBUTES) |
||
522 | { |
||
523 | if (string.IsNullOrEmpty(attr.VALUE)) |
||
524 | continue; |
||
525 | |||
526 | LMAAttribute lMAAttribute = _pipeRun.Attributes[attr.Attribute]; |
||
527 | if (lMAAttribute != null) |
||
528 | _pipeRun.Attributes[attr.Attribute].set_Value(attr.VALUE); |
||
529 | } |
||
530 | _pipeRun.Commit(); |
||
531 | } |
||
532 | } |
||
533 | catch (Exception ex) |
||
534 | { |
||
535 | Console.WriteLine(ex.StackTrace); |
||
536 | } |
||
537 | cdf18b83 | gaqhf | } |
538 | } |
||
539 | |||
540 | public class Text : SPPID_ITEM |
||
541 | { |
||
542 | #region Property |
||
543 | 8056c558 | gaqhf | private double _ANGLE; |
544 | cdf18b83 | gaqhf | private string _LOCATION; |
545 | 8056c558 | gaqhf | private double _LOCATION_X; |
546 | private double _LOCATION_Y; |
||
547 | 07bf38e1 | gaqhf | private string _VALUE; |
548 | cdf18b83 | gaqhf | private string _OWNER; |
549 | |||
550 | 8056c558 | gaqhf | public double ANGLE { get => _ANGLE; set => _ANGLE = value; } |
551 | cdf18b83 | gaqhf | public string LOCATION { get => _LOCATION; set => _LOCATION = value; } |
552 | 8056c558 | gaqhf | public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; } |
553 | public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; } |
||
554 | 07bf38e1 | gaqhf | public string VALUE { get => _VALUE; set => _VALUE = value; } |
555 | cdf18b83 | gaqhf | public string OWNER { get => _OWNER; set => _OWNER = value; } |
556 | #endregion |
||
557 | public override void AfterSetting() |
||
558 | { |
||
559 | 21be5063 | gaqhf | // SPPIDMAPPINGNAME Setting |
560 | SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME); |
||
561 | // End |
||
562 | |||
563 | 8056c558 | gaqhf | // Angle Setting |
564 | if (ANGLE == 1.57) |
||
565 | ANGLE = 90 * Math.PI / 180; |
||
566 | else if (ANGLE == 3.14) |
||
567 | ANGLE = Math.PI; |
||
568 | else if (ANGLE == 4.71) |
||
569 | ANGLE = 270 * Math.PI / 180; |
||
570 | else |
||
571 | ANGLE = 0; |
||
572 | // End |
||
573 | |||
574 | // Location Setting |
||
575 | SPPIDUtill.ConvertPointBystring(_LOCATION, ref _LOCATION_X, ref _LOCATION_Y); |
||
576 | SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT); |
||
577 | // End |
||
578 | |||
579 | // SPPID Type Setting |
||
580 | SPPID_TYPE = SPPID_ITEM_TYPE.TEXT; |
||
581 | // End |
||
582 | 21be5063 | gaqhf | |
583 | // Input Drawing |
||
584 | AutoModeling.DrawingItem.TEXTS.Add(this); |
||
585 | // End |
||
586 | cdf18b83 | gaqhf | } |
587 | |||
588 | 07bf38e1 | gaqhf | public override bool Modeling() |
589 | cdf18b83 | gaqhf | { |
590 | 8056c558 | gaqhf | try |
591 | { |
||
592 | 07bf38e1 | gaqhf | if (SPPID_ITEM_OBJECT == null) |
593 | 8056c558 | gaqhf | { |
594 | 07bf38e1 | gaqhf | Placement _placement = new Placement(); |
595 | if (NAME == "TEXT" || NAME == "NOTE") |
||
596 | 8056c558 | gaqhf | { |
597 | 07bf38e1 | gaqhf | LMSymbol _LmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Rotation: ANGLE); |
598 | LMItemNote _LmItemNote = _placement.PIDDataSource.GetItemNote(_LmSymbol.ModelItemID); |
||
599 | _LmItemNote.Attributes["Note.Body"].set_Value(VALUE); |
||
600 | _LmItemNote.Commit(); |
||
601 | SPPID_ITEM_OBJECT = _LmItemNote; |
||
602 | } |
||
603 | else if (NAME == "SIZE" && !string.IsNullOrEmpty(OWNER)) |
||
604 | { |
||
605 | object _obj = SPPIDUtill.FindObjectByUID(OWNER); |
||
606 | if (_obj != null && typeof(Symbol) == _obj.GetType()) |
||
607 | { |
||
608 | Array array = new double[] { 0, LOCATION_X, LOCATION_Y }; |
||
609 | Symbol _symbol = _obj as Symbol; |
||
610 | LMSymbol _LmSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol; |
||
611 | 8056c558 | gaqhf | |
612 | 07bf38e1 | gaqhf | if (_LmSymbol != null) |
613 | { |
||
614 | string fileName = _LmSymbol.get_FileName(); |
||
615 | if (fileName.Contains("Piping")) |
||
616 | SPPIDMAPPINGNAME = @"\Piping\Labels - Piping Components\Nominal Diameter.sym"; |
||
617 | else if (fileName.Contains("Instrumentation")) |
||
618 | SPPIDMAPPINGNAME = @"\Instrumentation\Labels - General Instrument\Nominal Diameter.sym"; |
||
619 | 8056c558 | gaqhf | |
620 | 07bf38e1 | gaqhf | LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref array, Rotation: ANGLE, LabeledItem: _LmSymbol.AsLMRepresentation(), IsLeaderVisible: true); |
621 | _LmLabelPersist.Commit(); |
||
622 | 8056c558 | gaqhf | |
623 | 07bf38e1 | gaqhf | SPPID_ITEM_OBJECT = _LmLabelPersist; |
624 | } |
||
625 | } |
||
626 | 8056c558 | gaqhf | } |
627 | } |
||
628 | } |
||
629 | 07bf38e1 | gaqhf | catch (Exception ex) |
630 | 8056c558 | gaqhf | { |
631 | 07bf38e1 | gaqhf | Console.WriteLine(ex.StackTrace); |
632 | return false; |
||
633 | 8056c558 | gaqhf | } |
634 | 07bf38e1 | gaqhf | |
635 | return true; |
||
636 | cdf18b83 | gaqhf | } |
637 | |||
638 | public override void SetAttribute() |
||
639 | { |
||
640 | 07bf38e1 | gaqhf | try |
641 | { |
||
642 | Placement _placement = new Placement(); |
||
643 | if (NAME == "SIZE") |
||
644 | { |
||
645 | object _obj = SPPIDUtill.FindObjectByUID(OWNER); |
||
646 | if (_obj != null && typeof(Symbol) == _obj.GetType()) |
||
647 | { |
||
648 | Symbol _symbol = _obj as Symbol; |
||
649 | LMSymbol _LmSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol; |
||
650 | |||
651 | if (_LmSymbol != null) |
||
652 | { |
||
653 | string fileName = _LmSymbol.get_FileName(); |
||
654 | if (fileName.Contains("Piping")) |
||
655 | { |
||
656 | LMPipingComp _LmPipingComp = _placement.PIDDataSource.GetPipingComp(_LmSymbol.ModelItemID); |
||
657 | if (_LmPipingComp != null && DBNull.Value.Equals(_LmPipingComp.Attributes["NominalDiameter"].get_Value())) |
||
658 | { |
||
659 | _LmPipingComp.Attributes["NominalDiameter"].set_Value(VALUE); |
||
660 | _LmPipingComp.Commit(); |
||
661 | } |
||
662 | } |
||
663 | else if (fileName.Contains("Instrumentation")) |
||
664 | { |
||
665 | LMInstrument _LmInstrument = _placement.PIDDataSource.GetInstrument(_LmSymbol.ModelItemID); |
||
666 | if (_LmInstrument != null && DBNull.Value.Equals(_LmInstrument.Attributes["NominalDiameter"].get_Value())) |
||
667 | { |
||
668 | _LmInstrument.Attributes["NominalDiameter"].set_Value(VALUE); |
||
669 | _LmInstrument.Commit(); |
||
670 | } |
||
671 | } |
||
672 | } |
||
673 | } |
||
674 | } |
||
675 | } |
||
676 | catch (Exception ex) |
||
677 | { |
||
678 | Console.WriteLine(ex.StackTrace); |
||
679 | } |
||
680 | |||
681 | |||
682 | |||
683 | //throw new NotImplementedException(); |
||
684 | cdf18b83 | gaqhf | } |
685 | } |
||
686 | |||
687 | |||
688 | 07bf38e1 | gaqhf | public class ItemAttribute |
689 | cdf18b83 | gaqhf | { |
690 | #region Property |
||
691 | private string _UID; |
||
692 | 07bf38e1 | gaqhf | private string _Length; |
693 | private string _Expression; |
||
694 | private string _DisplayAttribute; |
||
695 | private string _AttributeType; |
||
696 | private string _Attribute; |
||
697 | private string _AttrAt; |
||
698 | |||
699 | cdf18b83 | gaqhf | private string _VALUE; |
700 | |||
701 | public string UID { get => _UID; set => _UID = value; } |
||
702 | public string VALUE { get => _VALUE; set => _VALUE = value; } |
||
703 | 07bf38e1 | gaqhf | public string Length { get => _Length; set => _Length = value; } |
704 | public string Expression { get => _Expression; set => _Expression = value; } |
||
705 | public string DisplayAttribute { get => _DisplayAttribute; set => _DisplayAttribute = value; } |
||
706 | public string AttributeType { get => _AttributeType; set => _AttributeType = value; } |
||
707 | public string Attribute { get => _Attribute; set => _Attribute = value; } |
||
708 | public string AttrAt { get => _AttrAt; set => _AttrAt = value; } |
||
709 | cdf18b83 | gaqhf | #endregion |
710 | } |
||
711 | |||
712 | public class Connector |
||
713 | { |
||
714 | #region Property |
||
715 | private string _CONNECTEDITEM; |
||
716 | private string _CONNECTPOINT; |
||
717 | private string _SCENECONNECTPOINT; |
||
718 | 07bf38e1 | gaqhf | private int _INDEX; |
719 | cdf18b83 | gaqhf | |
720 | public string CONNECTEDITEM { get => _CONNECTEDITEM; set => _CONNECTEDITEM = value; } |
||
721 | public string CONNECTPOINT { get => _CONNECTPOINT; set => _CONNECTPOINT = value; } |
||
722 | public string SCENECONNECTPOINT { get => _SCENECONNECTPOINT; set => _SCENECONNECTPOINT = value; } |
||
723 | 07bf38e1 | gaqhf | public int INDEX { get => _INDEX; set => _INDEX = value; } |
724 | cdf18b83 | gaqhf | #endregion |
725 | } |
||
726 | } |