개정판 07bf38e1
dev issue #728: Convert vb to C#
DTI_PID/SPPIDAutoModeling/AutoModeling.cs | ||
---|---|---|
4 | 4 |
using System.Text; |
5 | 5 |
using System.Threading.Tasks; |
6 | 6 |
using System.Xml.Linq; |
7 |
using Llama; |
|
8 |
using Plaice; |
|
7 | 9 |
|
8 | 10 |
namespace SPPIDAutoModeling |
9 | 11 |
{ |
... | ... | |
33 | 35 |
SetText(xml.Element("TEXTINFOS")); |
34 | 36 |
SetTrimLine(xml.Element("TRIMLINENOS")); |
35 | 37 |
SetNote(xml.Element("NOTES")); |
38 |
|
|
39 |
SetGrouping(); |
|
36 | 40 |
} |
37 |
catch (Exception) |
|
41 |
catch (Exception ex)
|
|
38 | 42 |
{ |
39 |
|
|
43 |
Console.WriteLine(ex.StackTrace); |
|
40 | 44 |
} |
41 | 45 |
} |
42 | 46 |
|
47 |
|
|
48 |
#region SPPID Item |
|
43 | 49 |
private void SetSymbol(XElement node) |
44 | 50 |
{ |
45 | 51 |
foreach (XElement item in node.Elements("SYMBOL")) |
46 | 52 |
{ |
47 |
Symbol symbol = new Symbol() |
|
53 |
try |
|
54 |
{ |
|
55 |
Symbol symbol = new Symbol() |
|
56 |
{ |
|
57 |
UID = item.Element("UID").Value, |
|
58 |
NAME = item.Element("NAME").Value, |
|
59 |
TYPE = item.Element("TYPE").Value, |
|
60 |
ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
|
61 |
CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
|
62 |
LOCATION = item.Element("LOCATION").Value, |
|
63 |
SIZE = item.Element("SIZE").Value, |
|
64 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
|
65 |
PARENT = item.Element("PARENT").Value, |
|
66 |
CHILD = item.Element("CHILD").Value, |
|
67 |
HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
|
68 |
AREA = item.Element("AREA").Value |
|
69 |
}; |
|
70 |
SetConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS); |
|
71 |
SetAssociations(item.Element("ASSOCIATIONS"), symbol.ASSOCIATIONS); |
|
72 |
SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES); |
|
73 |
|
|
74 |
symbol.AfterSetting(); |
|
75 |
} |
|
76 |
catch (Exception ex) |
|
48 | 77 |
{ |
49 |
UID = item.Element("UID").Value, |
|
50 |
NAME = item.Element("NAME").Value, |
|
51 |
TYPE = item.Element("TYPE").Value, |
|
52 |
ORIGINALPOINT = item.Element("ORIGINALPOINT").Value, |
|
53 |
CONNECTIONPOINT = item.Element("CONNECTIONPOINT").Value, |
|
54 |
LOCATION = item.Element("LOCATION").Value, |
|
55 |
SIZE = item.Element("SIZE").Value, |
|
56 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
|
57 |
PARENT = item.Element("PARENT").Value, |
|
58 |
CHILD = item.Element("CHILD").Value, |
|
59 |
HASINSTRUMENTLABEL = item.Element("HASINSTRUMENTLABEL").Value, |
|
60 |
AREA = item.Element("AREA").Value |
|
61 |
}; |
|
62 |
SetConnectors(item.Element("CONNECTORS"), symbol.CONNECTORS); |
|
63 |
SetAttributes(item.Element("SYMBOLATTRIBUTES"), symbol.ATTRIBUTES); |
|
64 |
symbol.AfterSetting(); |
|
78 |
Console.WriteLine(ex.StackTrace); |
|
79 |
} |
|
65 | 80 |
} |
66 | 81 |
} |
67 | 82 |
|
68 | 83 |
private void SetLine(XElement node) |
69 | 84 |
{ |
85 |
try |
|
86 |
{ |
|
87 |
foreach (XElement item in node.Elements("LINE")) |
|
88 |
{ |
|
89 |
try |
|
90 |
{ |
|
91 |
Line line = new Line() |
|
92 |
{ |
|
93 |
UID = item.Element("UID").Value, |
|
94 |
STARTPOINT = item.Element("STARTPOINT").Value, |
|
95 |
ENDPOINT = item.Element("ENDPOINT").Value, |
|
96 |
TYPE = item.Element("TYPE").Value, |
|
97 |
AREA = item.Element("AREA").Value |
|
98 |
}; |
|
99 |
SetConnectors(item.Element("CONNECTORS"), line.CONNECTORS); |
|
70 | 100 |
|
101 |
line.AfterSetting(); |
|
102 |
} |
|
103 |
catch (Exception ex) |
|
104 |
{ |
|
105 |
Console.WriteLine(ex.StackTrace); |
|
106 |
} |
|
107 |
} |
|
108 |
} |
|
109 |
catch (Exception ex) |
|
110 |
{ |
|
111 |
Console.WriteLine(ex.StackTrace); |
|
112 |
} |
|
71 | 113 |
} |
72 | 114 |
|
73 | 115 |
private void SetLineNumber(XElement node) |
74 | 116 |
{ |
117 |
try |
|
118 |
{ |
|
119 |
foreach (XElement item in node.Elements("LINE_NO")) |
|
120 |
{ |
|
121 |
try |
|
122 |
{ |
|
123 |
LineNumber lineNumber = new LineNumber() |
|
124 |
{ |
|
125 |
UID = item.Element("UID").Value, |
|
126 |
TEXT = item.Element("TEXT").Value, |
|
127 |
LOCATION = item.Element("LOCATION").Value, |
|
128 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
|
129 |
AREA = item.Element("AREA").Value, |
|
130 |
LINENUMBERTYPE = LineNumber.LineNumberType.LineNumber, |
|
131 |
NAME = "LineNumber", |
|
132 |
}; |
|
75 | 133 |
|
134 |
if (item.Element("CONNLINE") != null) |
|
135 |
lineNumber.CONNECTLINE = item.Element("CONNLINE").Value; |
|
136 |
SetAttributes(item, lineNumber.ATTRIBUTES); |
|
137 |
lineNumber.AfterSetting(); |
|
138 |
} |
|
139 |
catch (Exception ex) |
|
140 |
{ |
|
141 |
Console.WriteLine(ex.StackTrace); |
|
142 |
} |
|
143 |
} |
|
144 |
} |
|
145 |
catch (Exception ex) |
|
146 |
{ |
|
147 |
Console.WriteLine(ex.StackTrace); |
|
148 |
} |
|
76 | 149 |
} |
77 | 150 |
|
78 | 151 |
private void SetTrimLine(XElement node) |
79 | 152 |
{ |
153 |
try |
|
154 |
{ |
|
155 |
foreach (XElement item in node.Elements("LINE_NO")) |
|
156 |
{ |
|
157 |
try |
|
158 |
{ |
|
159 |
LineNumber lineNumber = new LineNumber() |
|
160 |
{ |
|
161 |
UID = item.Element("UID").Value, |
|
162 |
TEXT = item.Element("TEXT").Value, |
|
163 |
LOCATION = item.Element("LOCATION").Value, |
|
164 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
|
165 |
AREA = item.Element("AREA").Value, |
|
166 |
LINENUMBERTYPE = LineNumber.LineNumberType.TrimLine, |
|
167 |
NAME = "LineNumber", |
|
168 |
}; |
|
80 | 169 |
|
170 |
if (item.Element("CONNLINE") != null) |
|
171 |
lineNumber.CONNECTLINE = item.Element("CONNLINE").Value; |
|
172 |
SetAttributes(item, lineNumber.ATTRIBUTES); |
|
173 |
lineNumber.AfterSetting(); |
|
174 |
} |
|
175 |
catch (Exception ex) |
|
176 |
{ |
|
177 |
Console.WriteLine(ex.StackTrace); |
|
178 |
} |
|
179 |
} |
|
180 |
} |
|
181 |
catch (Exception ex) |
|
182 |
{ |
|
183 |
Console.WriteLine(ex.StackTrace); |
|
184 |
} |
|
81 | 185 |
} |
82 | 186 |
|
83 | 187 |
private void SetText(XElement node) |
84 | 188 |
{ |
85 |
|
|
189 |
foreach (XElement item in node.Elements("ATTRIBUTE")) |
|
190 |
{ |
|
191 |
try |
|
192 |
{ |
|
193 |
Text text = new Text() |
|
194 |
{ |
|
195 |
UID = item.Element("UID").Value, |
|
196 |
NAME = item.Element("NAME").Value, |
|
197 |
LOCATION = item.Element("LOCATION").Value, |
|
198 |
VALUE = item.Element("VALUE").Value, |
|
199 |
ANGLE = Convert.ToDouble(item.Element("ANGLE").Value), |
|
200 |
AREA = item.Element("AREA").Value, |
|
201 |
}; |
|
202 |
text.AfterSetting(); |
|
203 |
} |
|
204 |
catch (Exception ex) |
|
205 |
{ |
|
206 |
Console.WriteLine(ex.StackTrace); |
|
207 |
} |
|
208 |
} |
|
86 | 209 |
} |
87 | 210 |
|
88 | 211 |
private void SetNote(XElement node) |
89 | 212 |
{ |
90 | 213 |
|
91 | 214 |
} |
215 |
#endregion |
|
216 |
|
|
92 | 217 |
|
218 |
#region Connector, Association, Attribute |
|
93 | 219 |
private void SetConnectors(XElement node, List<Connector> connectors) |
94 | 220 |
{ |
95 | 221 |
foreach (XElement item in node.Elements("CONNECTOR")) |
96 | 222 |
{ |
97 |
connectors.Add(new Connector()
|
|
223 |
try
|
|
98 | 224 |
{ |
99 |
CONNECTEDITEM = item.Element("CONNECTEDITEM").Value, |
|
100 |
CONNECTPOINT = item.Element("CONNECTPOINT").Value, |
|
101 |
SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value |
|
102 |
}); |
|
225 |
connectors.Add(new Connector() |
|
226 |
{ |
|
227 |
CONNECTEDITEM = item.Element("CONNECTEDITEM").Value, |
|
228 |
CONNECTPOINT = item.Element("CONNECTPOINT").Value, |
|
229 |
SCENECONNECTPOINT = item.Element("SCENECONNECTPOINT").Value, |
|
230 |
}); |
|
231 |
} |
|
232 |
catch (Exception ex) |
|
233 |
{ |
|
234 |
Console.WriteLine(ex.StackTrace); |
|
235 |
} |
|
103 | 236 |
} |
104 | 237 |
} |
105 | 238 |
|
106 |
private void SetAttributes(XElement node, List<Attribute> attributes)
|
|
239 |
private void SetAssociations(XElement node, List<Association> associations)
|
|
107 | 240 |
{ |
108 |
|
|
241 |
foreach (XElement item in node.Elements("ASSOCIATION")) |
|
242 |
{ |
|
243 |
try |
|
244 |
{ |
|
245 |
associations.Add(new Association() |
|
246 |
{ |
|
247 |
TYPE = item.Attribute("TYPE").Value, |
|
248 |
TYPE_VALUE = item.Value, |
|
249 |
}); |
|
250 |
} |
|
251 |
catch (Exception ex) |
|
252 |
{ |
|
253 |
Console.WriteLine(ex.StackTrace); |
|
254 |
} |
|
255 |
} |
|
109 | 256 |
} |
110 | 257 |
|
258 |
private void SetAttributes(XElement node, List<ItemAttribute> attributes) |
|
259 |
{ |
|
260 |
try |
|
261 |
{ |
|
262 |
foreach (XElement item in node.Elements("ATTRIBUTE")) |
|
263 |
{ |
|
264 |
ItemAttribute attribute = new ItemAttribute() |
|
265 |
{ |
|
266 |
UID = item.Attribute("UID").Value, |
|
267 |
Length = item.Attribute("Length").Value, |
|
268 |
Expression = item.Attribute("Expression").Value, |
|
269 |
DisplayAttribute = item.Attribute("DisplayAttribute").Value, |
|
270 |
AttributeType = item.Attribute("AttributeType").Value, |
|
271 |
Attribute = item.Attribute("Attribute").Value, |
|
272 |
AttrAt = item.Attribute("AttrAt").Value, |
|
273 |
VALUE = item.Value, |
|
274 |
}; |
|
275 |
attributes.Add(attribute); |
|
276 |
} |
|
277 |
} |
|
278 |
catch (Exception ex) |
|
279 |
{ |
|
280 |
Console.WriteLine(ex.StackTrace); |
|
281 |
} |
|
282 |
} |
|
283 |
#endregion |
|
111 | 284 |
#endregion |
112 | 285 |
|
113 |
|
|
286 |
#region Grouping Source |
|
287 |
private void SetGrouping() |
|
288 |
{ |
|
289 |
try |
|
290 |
{ |
|
291 |
// Line 기준으로 묶음 |
|
292 |
foreach (Line item in DrawingItem.LINES) |
|
293 |
if (!item.GROUPING) |
|
294 |
SetGroupingByItem(item); |
|
295 |
// End |
|
296 |
|
|
297 |
// Symbol 기준으로 묶음 |
|
298 |
foreach (Symbol item in DrawingItem.SYMBOLS) |
|
299 |
if (!item.GROUPING) |
|
300 |
SetGroupingByItem(item); |
|
301 |
// End |
|
302 |
} |
|
303 |
catch (Exception ex) |
|
304 |
{ |
|
305 |
Console.WriteLine(ex.StackTrace); |
|
306 |
} |
|
307 |
} |
|
308 |
|
|
309 |
private void SetGroupingByItem(SPPID_ITEM item) |
|
310 |
{ |
|
311 |
try |
|
312 |
{ |
|
313 |
Group group = new Group(); |
|
314 |
group.Items.Add(item); |
|
315 |
bool forward = true; |
|
316 |
SetGroupingByConnectedItem(item, group.Items, ref forward); |
|
317 |
|
|
318 |
DrawingItem.GROUPS.Add(group); |
|
319 |
|
|
320 |
foreach (SPPID_ITEM testItem in group.Items) |
|
321 |
{ |
|
322 |
if (testItem != null) |
|
323 |
{ |
|
324 |
Console.WriteLine(testItem.UID); |
|
325 |
} |
|
326 |
} |
|
327 |
} |
|
328 |
catch (Exception ex) |
|
329 |
{ |
|
330 |
Console.WriteLine(ex.StackTrace); |
|
331 |
} |
|
332 |
} |
|
333 |
|
|
334 |
private void SetGroupingByConnectedItem(SPPID_ITEM item, List<object> list, ref bool IsForward) |
|
335 |
{ |
|
336 |
try |
|
337 |
{ |
|
338 |
item.GROUPING = true; |
|
339 |
if (typeof(Line) == item.GetType()) |
|
340 |
{ |
|
341 |
Line line = item as Line; |
|
342 |
SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, line.CONNECTORS); |
|
343 |
} |
|
344 |
else if (typeof(Symbol) == item.GetType()) |
|
345 |
{ |
|
346 |
Symbol symbol = item as Symbol; |
|
347 |
// Symbol의 경우 BaseSymbol Connector가 2개 이하때 진행 / 나머지는 Grouping 종료 |
|
348 |
int baseSymbolCount = 0; |
|
349 |
foreach (Connector symbolConnector in symbol.CONNECTORS) |
|
350 |
if (symbolConnector.INDEX == 0) |
|
351 |
baseSymbolCount++; |
|
352 |
|
|
353 |
if (baseSymbolCount <= 2) |
|
354 |
SetGroupingByConnectedItem_ConnectorsLogic(item, list, ref IsForward, symbol.CONNECTORS); |
|
355 |
} |
|
356 |
IsForward = false; |
|
357 |
} |
|
358 |
catch (Exception ex) |
|
359 |
{ |
|
360 |
Console.WriteLine(ex.StackTrace); |
|
361 |
} |
|
362 |
} |
|
363 |
|
|
364 |
private void SetGroupingByConnectedItem_ConnectorsLogic(SPPID_ITEM item, List<object> list, ref bool IsForward, List<Connector> connectors) |
|
365 |
{ |
|
366 |
foreach (Connector connector in connectors) |
|
367 |
{ |
|
368 |
// 부가 심볼일 경우 continue |
|
369 |
if (connector.INDEX > 0) |
|
370 |
continue; |
|
371 |
|
|
372 |
SPPID_ITEM connItem = SPPIDUtill.FindObjectByUID(connector.CONNECTEDITEM) as SPPID_ITEM; |
|
373 |
if (connItem != null) |
|
374 |
{ |
|
375 |
bool result = false; |
|
376 |
if (typeof(Line) == connItem.GetType()) |
|
377 |
{ |
|
378 |
Line connLine = connItem as Line; |
|
379 |
// 연결되는 Item이 전부 Line일 경우 Branch, Line Type을 확인 |
|
380 |
if (item.GetType() == connLine.GetType() && |
|
381 |
(SPPIDUtill.IsBranchLine(item.UID, connLine) || item.SPPIDMAPPINGNAME != connLine.SPPIDMAPPINGNAME)) |
|
382 |
continue; |
|
383 |
|
|
384 |
result = true; |
|
385 |
} |
|
386 |
else if (typeof(Symbol) == connItem.GetType()) |
|
387 |
{ |
|
388 |
Symbol connSymbol = connItem as Symbol; |
|
389 |
// 연결되는 Symbol의 Connector가 부가 심볼일 경우는 result = false |
|
390 |
foreach (Connector symbolConnector in connSymbol.CONNECTORS) |
|
391 |
{ |
|
392 |
if (symbolConnector.CONNECTEDITEM == item.UID) |
|
393 |
{ |
|
394 |
if (symbolConnector.INDEX == 0) |
|
395 |
result = true; |
|
396 |
else |
|
397 |
result = false; |
|
398 |
break; |
|
399 |
} |
|
400 |
} |
|
401 |
} |
|
402 |
|
|
403 |
if (!connItem.GROUPING && result) |
|
404 |
{ |
|
405 |
if (IsForward) |
|
406 |
list.Add(connItem); |
|
407 |
else |
|
408 |
list.Insert(0, connItem); |
|
409 |
SetGroupingByConnectedItem(connItem, list, ref IsForward); |
|
410 |
} |
|
411 |
} |
|
412 |
} |
|
413 |
} |
|
414 |
#endregion |
|
114 | 415 |
|
115 | 416 |
public void Run() |
116 | 417 |
{ |
117 |
foreach (Symbol item in DrawingItem.SYMBOLS) |
|
418 |
// Group Symbol 실패시 Group Remove |
|
419 |
foreach (Group group in DrawingItem.GROUPS) |
|
420 |
{ |
|
421 |
if (!SymbolModeling(group)) |
|
422 |
{ |
|
423 |
group.Enable = false; |
|
424 |
} |
|
425 |
} |
|
426 |
|
|
427 |
// Line Group은 Group 없을 때까지 Loop |
|
428 |
while (DrawingItem.GROUPS.Count > 0) |
|
429 |
{ |
|
430 |
bool loopAction = false; |
|
431 |
foreach (Group group in DrawingItem.GROUPS) |
|
432 |
{ |
|
433 |
if (!group.Enable) |
|
434 |
continue; |
|
435 |
|
|
436 |
if (IsPossibleDrawGroupLine(group)) |
|
437 |
{ |
|
438 |
loopAction = true; |
|
439 |
LineModeling(group); |
|
440 |
DrawingItem.GROUPS.Remove(group); |
|
441 |
break; |
|
442 |
} |
|
443 |
} |
|
444 |
|
|
445 |
if (!loopAction) |
|
446 |
break; |
|
447 |
} |
|
448 |
|
|
449 |
foreach (Text text in DrawingItem.TEXTS) |
|
450 |
{ |
|
451 |
text.Modeling(); |
|
452 |
} |
|
453 |
} |
|
454 |
|
|
455 |
private bool IsPossibleDrawGroupLine(Group group) |
|
456 |
{ |
|
457 |
foreach (SPPID_ITEM item in group.Items) |
|
458 |
{ |
|
459 |
if (item.GetType() == typeof(Symbol)) |
|
460 |
{ |
|
461 |
Symbol symbol = item as Symbol; |
|
462 |
foreach (Connector connector in symbol.CONNECTORS) |
|
463 |
{ |
|
464 |
SPPID_ITEM objItem = SPPIDUtill.FindObjectByUID(connector.CONNECTEDITEM) as SPPID_ITEM; |
|
465 |
if (objItem != null && !group.Items.Contains(objItem) && objItem.SPPID_ITEM_OBJECT == null) |
|
466 |
return false; |
|
467 |
} |
|
468 |
} |
|
469 |
else if (item.GetType() == typeof(Line)) |
|
470 |
{ |
|
471 |
Line line = item as Line; |
|
472 |
foreach (Connector connector in line.CONNECTORS) |
|
473 |
{ |
|
474 |
SPPID_ITEM objItem = SPPIDUtill.FindObjectByUID(connector.CONNECTEDITEM) as SPPID_ITEM; |
|
475 |
if (objItem != null && !group.Items.Contains(objItem) && objItem.SPPID_ITEM_OBJECT == null) |
|
476 |
return false; |
|
477 |
} |
|
478 |
} |
|
479 |
} |
|
480 |
|
|
481 |
return true; |
|
482 |
} |
|
483 |
|
|
484 |
#region |
|
485 |
|
|
486 |
private bool SymbolModeling(Group group) |
|
487 |
{ |
|
488 |
try |
|
489 |
{ |
|
490 |
List<object> Items = group.Items; |
|
491 |
Symbol prevSymbol = null; |
|
492 |
int prevIndex = 0; |
|
493 |
|
|
494 |
for (int itemIndex = 0; itemIndex < Items.Count(); itemIndex++) |
|
495 |
{ |
|
496 |
Line.SlopeType prevSlope = Line.SlopeType.NONE; |
|
497 |
Symbol symbol = Items[itemIndex] as Symbol; |
|
498 |
if (symbol != null) |
|
499 |
{ |
|
500 |
// Group중에 최근에 Modeling된 Symbol |
|
501 |
if (prevSymbol != null) |
|
502 |
{ |
|
503 |
LMSymbol prevLMSymbol = prevSymbol.SPPID_ITEM_OBJECT as LMSymbol; |
|
504 |
for (int prevLineIndex = prevIndex + 1; prevLineIndex < itemIndex; prevLineIndex++) |
|
505 |
{ |
|
506 |
Line prevLine = Items[prevLineIndex] as Line; |
|
507 |
if (prevLine != null) |
|
508 |
{ |
|
509 |
if (prevSlope == Line.SlopeType.NONE) |
|
510 |
{ |
|
511 |
prevSlope = prevLine.SLOPTYPE; |
|
512 |
} |
|
513 |
else if (prevSlope != prevLine.SLOPTYPE) |
|
514 |
{ |
|
515 |
prevSlope = Line.SlopeType.NONE; |
|
516 |
break; |
|
517 |
} |
|
518 |
} |
|
519 |
} |
|
520 |
|
|
521 |
if (prevSlope == Line.SlopeType.HORIZONTAL) |
|
522 |
symbol.LOCATION_Y = prevLMSymbol.get_YCoordinate(); |
|
523 |
else if (prevSlope == Line.SlopeType.VERTICAL) |
|
524 |
symbol.LOCATION_X = prevLMSymbol.get_XCoordinate(); |
|
525 |
} |
|
526 |
|
|
527 |
symbol.Modeling(); |
|
528 |
if (symbol.SPPID_ITEM_OBJECT != null) |
|
529 |
{ |
|
530 |
prevSymbol = symbol; |
|
531 |
prevIndex = itemIndex; |
|
532 |
} |
|
533 |
} |
|
534 |
} |
|
535 |
} |
|
536 |
catch (Exception ex) |
|
537 |
{ |
|
538 |
Console.WriteLine(ex.StackTrace); |
|
539 |
return false; |
|
540 |
} |
|
541 |
|
|
542 |
return true; |
|
543 |
} |
|
544 |
|
|
545 |
private bool LineModeling(Group group) |
|
546 |
{ |
|
547 |
try |
|
548 |
{ |
|
549 |
List<object> Items = group.Items; |
|
550 |
List<Line> lineList = new List<Line>(); |
|
551 |
foreach (SPPID_ITEM item in Items) |
|
552 |
{ |
|
553 |
Line line = item as Line; |
|
554 |
if (line != null) |
|
555 |
lineList.Add(line); |
|
556 |
else if (lineList.Count > 0) |
|
557 |
{ |
|
558 |
LineModelingByList(lineList, group); |
|
559 |
} |
|
560 |
} |
|
561 |
|
|
562 |
if (lineList.Count > 0) |
|
563 |
LineModelingByList(lineList, group); |
|
564 |
} |
|
565 |
catch (Exception ex) |
|
566 |
{ |
|
567 |
Console.WriteLine(ex.StackTrace); |
|
568 |
return false; |
|
569 |
} |
|
570 |
|
|
571 |
return true; |
|
572 |
} |
|
573 |
|
|
574 |
private void LineModelingByList(List<Line> lines, Group group) |
|
575 |
{ |
|
576 |
List<PointInfo> pointInfos = GetLinePointInfos(lines, group); |
|
577 |
LMConnector lMConnector = DrawLines(pointInfos, lines[0].SPPIDMAPPINGNAME); |
|
578 |
|
|
579 |
if (lMConnector != null) |
|
580 |
{ |
|
581 |
string modelId = lMConnector.ModelItemID; |
|
582 |
DrawingItem.PipeRunPoint.Add(lMConnector.ModelItemID, pointInfos); |
|
583 |
foreach (Line line in lines) |
|
584 |
{ |
|
585 |
line.SPPID_ITEM_OBJECT = modelId; |
|
586 |
IfContainLineNumber(line.UID); |
|
587 |
} |
|
588 |
} |
|
589 |
|
|
590 |
lines.Clear(); |
|
591 |
} |
|
592 |
|
|
593 |
private void IfContainLineNumber(string lineUID) |
|
594 |
{ |
|
595 |
foreach (LineNumber lineNumber in DrawingItem.LINENUMBERS) |
|
596 |
{ |
|
597 |
if (lineNumber.CONNECTLINE == lineUID) |
|
598 |
{ |
|
599 |
lineNumber.Modeling(); |
|
600 |
lineNumber.SetAttribute(); |
|
601 |
break; |
|
602 |
} |
|
603 |
} |
|
604 |
} |
|
605 |
|
|
606 |
private LMConnector DrawLines(List<PointInfo> pointInfos, string SPPID_MAPPINGNAME) |
|
607 |
{ |
|
608 |
Placement _placement = new Placement(); |
|
609 |
_LMAItem _LMAItem = _placement.PIDCreateItem(SPPID_MAPPINGNAME); |
|
610 |
LMConnector lMConnector = null; |
|
611 |
PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
|
612 |
|
|
613 |
PointInfo branchPoint = null; |
|
614 |
int branchIndex = 0; |
|
615 |
List<string> branch_SP_ID_List = null; |
|
616 |
|
|
617 |
for (int pointIndex = 0; pointIndex < pointInfos.Count; pointIndex++) |
|
618 |
{ |
|
619 |
PointInfo pointInfo = pointInfos[pointIndex]; |
|
620 |
if (pointIndex == 0 || pointIndex == pointInfos.Count - 1) |
|
621 |
{ |
|
622 |
if (pointInfo.ConnectedItemObject == null) |
|
623 |
{ |
|
624 |
placeRunInputs.AddPoint(pointInfo.X, pointInfo.Y); |
|
625 |
} |
|
626 |
else |
|
627 |
{ |
|
628 |
if (typeof(Symbol) == pointInfo.ConnectedItemObject.GetType()) |
|
629 |
{ |
|
630 |
Symbol symbol = pointInfo.ConnectedItemObject as Symbol; |
|
631 |
LMSymbol tartgetLMSymbol = symbol.SPPID_ITEM_OBJECT as LMSymbol; |
|
632 |
placeRunInputs.AddSymbolTarget(tartgetLMSymbol, pointInfo.X, pointInfo.Y); |
|
633 |
} |
|
634 |
else if (typeof(Line) == pointInfo.ConnectedItemObject.GetType()) |
|
635 |
{ |
|
636 |
Line line = pointInfo.ConnectedItemObject as Line; |
|
637 |
Tuple<LMConnector, int> targetLMConnector = GetTargetLMConnector(pointInfo); |
|
638 |
if (targetLMConnector.Item1 != null) |
|
639 |
{ |
|
640 |
placeRunInputs.AddConnectorTarget(targetLMConnector.Item1, pointInfo.X, pointInfo.Y); |
|
641 |
branchPoint = new PointInfo(pointInfo.X, pointInfo.Y); |
|
642 |
branchPoint.Type = PointInfo.PointType.Branch; |
|
643 |
branchPoint.ConnectedItem = pointInfo.ConnectedItem; |
|
644 |
branchPoint.ConnectedItemObject = pointInfo.ConnectedItemObject; |
|
645 |
branchIndex = targetLMConnector.Item2; |
|
646 |
|
|
647 |
branch_SP_ID_List = new List<string>(); |
|
648 |
LMPipeRun lMPipeRun = _placement.PIDDataSource.GetPipeRun(line.SPPID_ITEM_OBJECT.ToString()); |
|
649 |
foreach (LMRepresentation rep in lMPipeRun.Representations) |
|
650 |
if (rep.Attributes["RepresentationType"].get_Value() == "Branch" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
651 |
branch_SP_ID_List.Add(rep.Id); |
|
652 |
} |
|
653 |
else |
|
654 |
{ |
|
655 |
placeRunInputs.AddPoint(pointInfo.X, pointInfo.Y); |
|
656 |
} |
|
657 |
} |
|
658 |
} |
|
659 |
} |
|
660 |
else |
|
661 |
{ |
|
662 |
placeRunInputs.AddPoint(pointInfo.X, pointInfo.Y); |
|
663 |
} |
|
664 |
} |
|
665 |
|
|
666 |
lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
|
667 |
lMConnector.Commit(); |
|
668 |
|
|
669 |
// Branch Point Setting |
|
670 |
if (branchPoint != null) |
|
671 |
{ |
|
672 |
Line branchedLine = branchPoint.ConnectedItemObject as Line; |
|
673 |
LMPipeRun lMPipeRun = _placement.PIDDataSource.GetPipeRun(branchedLine.SPPID_ITEM_OBJECT.ToString()); |
|
674 |
foreach (LMRepresentation rep in lMPipeRun.Representations) |
|
675 |
if (rep.Attributes["RepresentationType"].get_Value() == "Branch" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
676 |
{ |
|
677 |
if (!branch_SP_ID_List.Contains(rep.Id)) |
|
678 |
{ |
|
679 |
branchPoint.SP_ID = rep.Id; |
|
680 |
DrawingItem.PipeRunPoint[branchedLine.SPPID_ITEM_OBJECT.ToString()].Insert(branchIndex, branchPoint); |
|
681 |
break; |
|
682 |
} |
|
683 |
} |
|
684 |
} |
|
685 |
// End |
|
686 |
|
|
687 |
return lMConnector; |
|
688 |
} |
|
689 |
|
|
690 |
private List<PointInfo> GetLinePointInfos(List<Line> lineList, Group group) |
|
691 |
{ |
|
692 |
// Line들의 points를 구함 |
|
693 |
List<PointInfo> pointInfos = new List<PointInfo>(); |
|
694 |
if (lineList.Count == 1) |
|
695 |
{ |
|
696 |
pointInfos.Add(new PointInfo(lineList[0].START_X, lineList[0].START_Y) { ConnectedItem = lineList[0].CONNECTORS[0].CONNECTEDITEM }); |
|
697 |
pointInfos.Add(new PointInfo(lineList[0].END_X, lineList[0].END_Y) { ConnectedItem = lineList[0].CONNECTORS[1].CONNECTEDITEM }); |
|
698 |
} |
|
699 |
else |
|
700 |
{ |
|
701 |
for (int i = 0; i < lineList.Count; i++) |
|
702 |
if (lineList.Count > i + 1) |
|
703 |
GetLinePoints(lineList[i], lineList[i + 1], pointInfos); |
|
704 |
} |
|
705 |
|
|
706 |
// 맨앞 뒤의 ConnectedItem 구함 |
|
707 |
for (int i = 0; i < pointInfos.Count; i++) |
|
708 |
{ |
|
709 |
PointInfo info = pointInfos[i]; |
|
710 |
if (i == 0 || pointInfos.Count - 1 == i) |
|
711 |
{ |
|
712 |
info.ConnectedItemObject = SPPIDUtill.FindObjectByUID(info.ConnectedItem) as SPPID_ITEM; |
|
713 |
|
|
714 |
if (info.ConnectedItemObject == null) |
|
715 |
{ |
|
716 |
info.Type = PointInfo.PointType.Run; |
|
717 |
} |
|
718 |
else |
|
719 |
{ |
|
720 |
info.Type = PointInfo.PointType.Branch; |
|
721 |
} |
|
722 |
} |
|
723 |
else |
|
724 |
{ |
|
725 |
info.ConnectedItem = string.Empty; |
|
726 |
info.Type = PointInfo.PointType.Run; |
|
727 |
} |
|
728 |
|
|
729 |
} |
|
730 |
|
|
731 |
// 라인 보정 |
|
732 |
CalibratePointInfos(pointInfos, lineList); |
|
733 |
|
|
734 |
return pointInfos; |
|
735 |
} |
|
736 |
|
|
737 |
private void GetLinePoints(Line line, Line nextLine, List<PointInfo> pointInfos) |
|
738 |
{ |
|
739 |
if (nextLine != null) |
|
740 |
{ |
|
741 |
if (pointInfos.Count > 0) |
|
742 |
pointInfos.RemoveRange(pointInfos.Count - 2, 2); |
|
743 |
|
|
744 |
if (line.CONNECTORS[0].CONNECTEDITEM == nextLine.UID) |
|
745 |
{ |
|
746 |
pointInfos.Add(new PointInfo(line.END_X, line.END_Y) { ConnectedItem = line.CONNECTORS[1].CONNECTEDITEM }); |
|
747 |
pointInfos.Add(new PointInfo(line.START_X, line.START_Y) { ConnectedItem = line.CONNECTORS[0].CONNECTEDITEM }); |
|
748 |
|
|
749 |
if (nextLine.CONNECTORS[0].CONNECTEDITEM == line.UID) |
|
750 |
pointInfos.Add(new PointInfo(nextLine.END_X, nextLine.END_Y) { ConnectedItem = nextLine.CONNECTORS[1].CONNECTEDITEM }); |
|
751 |
else if (nextLine.CONNECTORS[1].CONNECTEDITEM == line.UID) |
|
752 |
pointInfos.Add(new PointInfo(nextLine.START_X, nextLine.START_Y) { ConnectedItem = nextLine.CONNECTORS[0].CONNECTEDITEM }); |
|
753 |
|
|
754 |
} |
|
755 |
else if (line.CONNECTORS[1].CONNECTEDITEM == nextLine.UID) |
|
756 |
{ |
|
757 |
pointInfos.Add(new PointInfo(line.START_X, line.START_Y) { ConnectedItem = line.CONNECTORS[0].CONNECTEDITEM }); |
|
758 |
pointInfos.Add(new PointInfo(line.END_X, line.END_Y) { ConnectedItem = line.CONNECTORS[1].CONNECTEDITEM }); |
|
759 |
|
|
760 |
if (nextLine.CONNECTORS[0].CONNECTEDITEM == line.UID) |
|
761 |
pointInfos.Add(new PointInfo(nextLine.END_X, nextLine.END_Y) { ConnectedItem = nextLine.CONNECTORS[1].CONNECTEDITEM }); |
|
762 |
else if (nextLine.CONNECTORS[1].CONNECTEDITEM == line.UID) |
|
763 |
pointInfos.Add(new PointInfo(nextLine.START_X, nextLine.START_Y) { ConnectedItem = nextLine.CONNECTORS[0].CONNECTEDITEM }); |
|
764 |
} |
|
765 |
} |
|
766 |
} |
|
767 |
|
|
768 |
private void CalibratePointInfos(List<PointInfo> pointInfos, List<Line> lines) |
|
769 |
{ |
|
770 |
// 맨 앞이 Symbol일 경우 |
|
771 |
if (pointInfos[0].ConnectedItemObject != null && typeof(Symbol) == pointInfos[0].ConnectedItemObject.GetType()) |
|
772 |
{ |
|
773 |
PointInfo startPoint = pointInfos[0]; |
|
774 |
PointInfo nextPoint = pointInfos[1]; |
|
775 |
|
|
776 |
Symbol symbol = startPoint.ConnectedItemObject as Symbol; |
|
777 |
LMSymbol _LMSymbol = symbol.SPPID_ITEM_OBJECT as LMSymbol; |
|
778 |
double symbolX = _LMSymbol.get_XCoordinate(); |
|
779 |
double symbolY = _LMSymbol.get_YCoordinate(); |
|
780 |
|
|
781 |
if (lines[0].SLOPTYPE == Line.SlopeType.HORIZONTAL) |
|
782 |
{ |
|
783 |
startPoint.Y = symbolY; |
|
784 |
nextPoint.Y = symbolY; |
|
785 |
} |
|
786 |
else if (lines[0].SLOPTYPE == Line.SlopeType.VERTICAL) |
|
787 |
{ |
|
788 |
startPoint.X = symbolX; |
|
789 |
nextPoint.X = symbolX; |
|
790 |
} |
|
791 |
} |
|
792 |
// 맨 뒤가 Symbol일 경우 |
|
793 |
else if (pointInfos[pointInfos.Count - 1].ConnectedItemObject != null && typeof(Symbol) == pointInfos[pointInfos.Count - 1].ConnectedItemObject.GetType()) |
|
794 |
{ |
|
795 |
PointInfo startPoint = pointInfos[pointInfos.Count - 1]; |
|
796 |
PointInfo nextPoint = pointInfos[pointInfos.Count - 2]; |
|
797 |
|
|
798 |
Symbol symbol = startPoint.ConnectedItemObject as Symbol; |
|
799 |
LMSymbol _LMSymbol = symbol.SPPID_ITEM_OBJECT as LMSymbol; |
|
800 |
double symbolX = _LMSymbol.get_XCoordinate(); |
|
801 |
double symbolY = _LMSymbol.get_YCoordinate(); |
|
802 |
|
|
803 |
if (lines[lines.Count - 1].SLOPTYPE == Line.SlopeType.HORIZONTAL) |
|
804 |
{ |
|
805 |
startPoint.Y = symbolY; |
|
806 |
nextPoint.Y = symbolY; |
|
807 |
} |
|
808 |
else if (lines[lines.Count - 1].SLOPTYPE == Line.SlopeType.VERTICAL) |
|
809 |
{ |
|
810 |
startPoint.X = symbolX; |
|
811 |
nextPoint.X = symbolX; |
|
812 |
} |
|
813 |
} |
|
814 |
} |
|
815 |
|
|
816 |
private Tuple<LMConnector, int> GetTargetLMConnector(PointInfo pointInfo) |
|
817 |
{ |
|
818 |
LMConnector lMConnector = null; |
|
819 |
Line line = pointInfo.ConnectedItemObject as Line; |
|
820 |
string modelId = line.SPPID_ITEM_OBJECT.ToString(); |
|
821 |
List<PointInfo> pointInfos = DrawingItem.PipeRunPoint[modelId]; |
|
822 |
double distance = double.MaxValue; |
|
823 |
int insertIndex = 0; |
|
824 |
|
|
825 |
PointInfo point1 = new PointInfo(0, 0); |
|
826 |
PointInfo point2 = new PointInfo(0, 0); |
|
827 |
|
|
828 |
for (int i = 0; i < pointInfos.Count - 1; i++) |
|
829 |
{ |
|
830 |
PointInfo tempPoint1 = pointInfos[i]; |
|
831 |
PointInfo tempPoint2 = pointInfos[i + 1]; |
|
832 |
|
|
833 |
double tempDistance = double.MaxValue; |
|
834 |
|
|
835 |
Line.SlopeType slopeType = SPPIDUtill.CalcSlop(tempPoint1, tempPoint2); |
|
836 |
if (slopeType == Line.SlopeType.HORIZONTAL) |
|
837 |
{ |
|
838 |
double min = Math.Min(tempPoint1.X, tempPoint2.X); |
|
839 |
double max = Math.Max(tempPoint1.X, tempPoint2.X); |
|
840 |
|
|
841 |
if (min <= pointInfo.X && max >= pointInfo.X) |
|
842 |
tempDistance = SPPIDUtill.CalcLineToPointDistance(tempPoint1, tempPoint2, pointInfo); |
|
843 |
} |
|
844 |
else if (slopeType == Line.SlopeType.VERTICAL) |
|
845 |
{ |
|
846 |
double min = Math.Min(tempPoint1.Y, tempPoint2.Y); |
|
847 |
double max = Math.Max(tempPoint1.Y, tempPoint2.Y); |
|
848 |
|
|
849 |
if (min <= pointInfo.Y && max >= pointInfo.Y) |
|
850 |
tempDistance = SPPIDUtill.CalcLineToPointDistance(tempPoint1, tempPoint2, pointInfo); |
|
851 |
} |
|
852 |
else |
|
853 |
{ |
|
854 |
tempDistance = SPPIDUtill.CalcLineToPointDistance(tempPoint1, tempPoint2, pointInfo); |
|
855 |
} |
|
856 |
|
|
857 |
if (tempDistance < distance) |
|
858 |
{ |
|
859 |
insertIndex = i + 1; |
|
860 |
distance = tempDistance; |
|
861 |
point1 = tempPoint1; |
|
862 |
point2 = tempPoint2; |
|
863 |
} |
|
864 |
} |
|
865 |
|
|
866 |
if (point1.Type == PointInfo.PointType.Run) |
|
867 |
lMConnector = GetLMConnectorByPoint(modelId, point1); |
|
868 |
else if (point2.Type == PointInfo.PointType.Run) |
|
869 |
lMConnector = GetLMConnectorByPoint(modelId, point2); |
|
870 |
else |
|
871 |
lMConnector = GetLMConnectorBySP_ID(modelId, point1.SP_ID, point2.SP_ID); |
|
872 |
|
|
873 |
return new Tuple<LMConnector, int>(lMConnector, insertIndex); |
|
874 |
} |
|
875 |
|
|
876 |
private LMConnector GetLMConnectorByPoint(string modelId, PointInfo pointInfo) |
|
877 |
{ |
|
878 |
LMConnector lMConnector = null; |
|
879 |
Placement _placement = new Placement(); |
|
880 |
|
|
881 |
double distance = double.MaxValue; |
|
882 |
LMPipeRun lMPipeRun = _placement.PIDDataSource.GetPipeRun(modelId); |
|
883 |
foreach (LMRepresentation rep in lMPipeRun.Representations) |
|
884 |
{ |
|
885 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
886 |
{ |
|
887 |
LMConnector _tempLMConnector = _placement.PIDDataSource.GetConnector(rep.Id); |
|
888 |
foreach (LMConnectorVertex vertex in _tempLMConnector.ConnectorVertices) |
|
889 |
{ |
|
890 |
double tempDistance = SPPIDUtill.CalcPointToPointdDistance(pointInfo, new PointInfo(vertex.get_XCoordinate(), vertex.get_YCoordinate())); |
|
891 |
|
|
892 |
if (tempDistance < distance) |
|
893 |
{ |
|
894 |
distance = tempDistance; |
|
895 |
lMConnector = _tempLMConnector; |
|
896 |
} |
|
897 |
} |
|
898 |
|
|
899 |
} |
|
900 |
} |
|
901 |
return lMConnector; |
|
902 |
} |
|
903 |
|
|
904 |
private LMConnector GetLMConnectorBySP_ID(string modelId, string SP_ID1, string SP_ID2) |
|
905 |
{ |
|
906 |
Placement _placement = new Placement(); |
|
907 |
|
|
908 |
double distance = double.MaxValue; |
|
909 |
LMPipeRun lMPipeRun = _placement.PIDDataSource.GetPipeRun(modelId); |
|
910 |
foreach (LMRepresentation rep in lMPipeRun.Representations) |
|
118 | 911 |
{ |
119 |
item.Modeling(); |
|
912 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
913 |
{ |
|
914 |
LMConnector _tempLMConnector = _placement.PIDDataSource.GetConnector(rep.Id); |
|
915 |
|
|
916 |
bool find1 = false; |
|
917 |
bool find2 = false; |
|
918 |
|
|
919 |
if (_tempLMConnector.ConnectItem1SymbolID != null) |
|
920 |
{ |
|
921 |
string connId = _tempLMConnector.ConnectItem1SymbolID; |
|
922 |
if (connId == SP_ID1 || connId == SP_ID2) |
|
923 |
find1 = true; |
|
924 |
} |
|
925 |
|
|
926 |
if (_tempLMConnector.ConnectItem2SymbolID != null) |
|
927 |
{ |
|
928 |
string connId = _tempLMConnector.ConnectItem2SymbolID; |
|
929 |
if (connId == SP_ID1 || connId == SP_ID2) |
|
930 |
find2 = true; |
|
931 |
} |
|
932 |
|
|
933 |
|
|
934 |
if (find1 && find2) |
|
935 |
{ |
|
936 |
return _tempLMConnector; |
|
937 |
} |
|
938 |
} |
|
120 | 939 |
} |
940 |
return null; |
|
121 | 941 |
} |
942 |
|
|
943 |
#endregion |
|
944 |
|
|
122 | 945 |
} |
123 | 946 |
} |
DTI_PID/SPPIDAutoModeling/ItemObject.cs | ||
---|---|---|
1 | 1 |
using System; |
2 | 2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel; |
|
3 | 4 |
using System.Linq; |
5 |
using System.Runtime.InteropServices; |
|
4 | 6 |
using System.Text; |
5 | 7 |
using System.Threading.Tasks; |
6 | 8 |
using Llama; |
... | ... | |
34 | 36 |
|
35 | 37 |
public class Group |
36 | 38 |
{ |
37 |
private List<Symbol> _SYMBOLS = new List<Symbol>();
|
|
38 |
private List<Line> _LINES = new List<Line>();
|
|
39 |
private List<object> _Items = new List<object>();
|
|
40 |
private bool _Enable = true;
|
|
39 | 41 |
|
40 |
public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; } |
|
41 |
public List<Line> LINES { get => _LINES; set => _LINES = value; } |
|
42 |
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; } |
|
42 | 53 |
} |
43 | 54 |
|
44 | 55 |
|
... | ... | |
53 | 64 |
private List<Line> _LINES = new List<Line>(); |
54 | 65 |
private List<LineNumber> _LINENUMBERS = new List<LineNumber>(); |
55 | 66 |
private List<Text> _TEXTS = new List<Text>(); |
56 |
private Dictionary<string, List<PointdInfo>> _PipeRunPoint = new Dictionary<string, List<PointdInfo>>();
|
|
57 |
private List<Group> _GROUP = new List<Group>(); |
|
67 |
private Dictionary<string, List<PointInfo>> _PipeRunPoint = new Dictionary<string, List<PointInfo>>();
|
|
68 |
private List<Group> _GROUPS = new List<Group>();
|
|
58 | 69 |
|
59 | 70 |
private double _WIDTH; |
60 | 71 |
private double _HEIGHT; |
... | ... | |
70 | 81 |
} |
71 | 82 |
} |
72 | 83 |
public string UNIT { get => _UNIT; set => _UNIT = value; } |
73 |
public Dictionary<string, List<PointdInfo>> PipeRunPoint { get => _PipeRunPoint; set => _PipeRunPoint = value; }
|
|
84 |
public Dictionary<string, List<PointInfo>> PipeRunPoint { get => _PipeRunPoint; set => _PipeRunPoint = value; } |
|
74 | 85 |
public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; } |
75 | 86 |
public List<Line> LINES { get => _LINES; set => _LINES = value; } |
76 | 87 |
public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; } |
77 | 88 |
public List<Text> TEXTS { get => _TEXTS; set => _TEXTS = value; } |
78 | 89 |
public double WIDTH { get => _WIDTH; set => _WIDTH = value; } |
79 | 90 |
public double HEIGHT { get => _HEIGHT; set => _HEIGHT = value; } |
80 |
public List<Group> GROUP { get => _GROUP; set => _GROUP = value; }
|
|
91 |
public List<Group> GROUPS { get => _GROUPS; set => _GROUPS = value; }
|
|
81 | 92 |
#endregion |
82 | 93 |
} |
83 |
public class PointdInfo |
|
94 |
|
|
95 |
public class PointInfo |
|
84 | 96 |
{ |
97 |
public PointInfo(double x, double y) |
|
98 |
{ |
|
99 |
this.x = x; |
|
100 |
this.y = y; |
|
101 |
} |
|
102 |
|
|
85 | 103 |
public enum PointType |
86 | 104 |
{ |
87 | 105 |
None = 0, |
... | ... | |
89 | 107 |
Branch = 2, |
90 | 108 |
} |
91 | 109 |
#region Property |
92 |
private Pointd _Pointd; |
|
110 |
private double x; |
|
111 |
private double y; |
|
93 | 112 |
private PointType _Type; |
113 |
private string _ConnectedItem; |
|
94 | 114 |
private string _SP_ID; |
115 |
private SPPID_ITEM _ConnectedItemObject; |
|
95 | 116 |
|
96 |
public Pointd Pointd { get => _Pointd; set => _Pointd = value; } |
|
117 |
public double X { get { return x; } set { x = value; } } |
|
118 |
public double Y { get { return y; } set { y = value; } } |
|
97 | 119 |
public PointType Type { get => _Type; set => _Type = value; } |
120 |
public string ConnectedItem { get => _ConnectedItem; set => _ConnectedItem = value; } |
|
121 |
public SPPID_ITEM ConnectedItemObject { get => _ConnectedItemObject; set => _ConnectedItemObject = value; } |
|
98 | 122 |
public string SP_ID { get => _SP_ID; set => _SP_ID = value; } |
99 | 123 |
#endregion |
100 | 124 |
} |
101 |
public struct Pointd |
|
102 |
{ |
|
103 |
public Pointd(double x, double y) |
|
104 |
{ |
|
105 |
X = x; |
|
106 |
Y = y; |
|
107 |
} |
|
108 |
public double X; |
|
109 |
public double Y; |
|
110 |
} |
|
111 | 125 |
|
112 | 126 |
|
113 | 127 |
public abstract class SPPID_ITEM |
... | ... | |
118 | 132 |
private string _NAME; |
119 | 133 |
private SPPID_ITEM_TYPE _SPPID_TYPE ; |
120 | 134 |
private string _SPPIDMAPPINGNAME; |
121 |
private bool _GROUPING = true;
|
|
135 |
private bool _GROUPING; |
|
122 | 136 |
private string _AREA; |
123 |
private List<Attribute> _ATTRIBUTES = new List<Attribute>();
|
|
137 |
private List<ItemAttribute> _ATTRIBUTES = new List<ItemAttribute>();
|
|
124 | 138 |
private object _SPPID_ITEM_OBJECT; |
125 | 139 |
|
126 | 140 |
public string UID { get => _UID; set => _UID = value; } |
... | ... | |
131 | 145 |
public string AREA { get => _AREA; set => _AREA = value; } |
132 | 146 |
public object SPPID_ITEM_OBJECT { get => _SPPID_ITEM_OBJECT; set => _SPPID_ITEM_OBJECT = value; } |
133 | 147 |
public SPPID_ITEM_TYPE SPPID_TYPE { get => _SPPID_TYPE; set => _SPPID_TYPE = value; } |
134 |
public List<Attribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; } |
|
148 |
public List<ItemAttribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; }
|
|
135 | 149 |
#endregion |
136 | 150 |
|
137 |
public abstract void Modeling();
|
|
151 |
public abstract bool Modeling();
|
|
138 | 152 |
public abstract void AfterSetting(); |
139 | 153 |
public abstract void SetAttribute(); |
140 | 154 |
} |
... | ... | |
143 | 157 |
{ |
144 | 158 |
#region Property |
145 | 159 |
private string _ORIGINALPOINT; |
160 |
private List<Association> _ASSOCIATIONS = new List<Association>(); |
|
146 | 161 |
private List<Connector> _CONNECTORS = new List<Connector>(); |
147 | 162 |
private string _CONNECTIONPOINT; |
148 | 163 |
private string _LOCATION; |
... | ... | |
173 | 188 |
public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; } |
174 | 189 |
public string CONNECTIONPOINT { get => _CONNECTIONPOINT; set => _CONNECTIONPOINT = value; } |
175 | 190 |
public List<SymbolChild> CHILD_LIST { get => _CHILD_LIST; set => _CHILD_LIST = value; } |
191 |
public List<Association> ASSOCIATIONS { get => _ASSOCIATIONS; set => _ASSOCIATIONS = value; } |
|
176 | 192 |
#endregion |
177 | 193 |
public override void AfterSetting() |
178 | 194 |
{ |
179 | 195 |
// SPPIDMAPPINGNAME Setting |
180 |
SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME);
|
|
196 |
SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(PARENT);
|
|
181 | 197 |
// End |
182 | 198 |
|
183 | 199 |
// Angle Setting |
... | ... | |
203 | 219 |
// Child Setting |
204 | 220 |
if (!string.IsNullOrEmpty(CHILD) && CHILD != "None") |
205 | 221 |
{ |
206 |
string[] childArray = CHILD.Split(new char[] { ',' });
|
|
207 |
for (int i = 0; i < childArray.Length; i++)
|
|
222 |
string[] array = CHILD.Split(new char[] { ',' });
|
|
223 |
for (int i = 0; i < array.Length; i++)
|
|
208 | 224 |
{ |
209 | 225 |
SymbolChild child = new SymbolChild() |
210 | 226 |
{ |
211 |
Arrow = childArray[0],
|
|
212 |
Name = childArray[1],
|
|
213 |
Index = i |
|
227 |
Arrow = array[0],
|
|
228 |
Name = array[1],
|
|
229 |
Index = i + 1,
|
|
214 | 230 |
}; |
215 | 231 |
child.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(child.Name); |
216 | 232 |
CHILD_LIST.Add(child); |
... | ... | |
218 | 234 |
} |
219 | 235 |
// End |
220 | 236 |
|
237 |
// 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 |
|
|
221 | 249 |
// Input Drawing |
222 | 250 |
AutoModeling.DrawingItem.SYMBOLS.Add(this); |
223 | 251 |
// End |
224 | 252 |
} |
225 | 253 |
|
226 |
public override void Modeling()
|
|
254 |
public override bool Modeling()
|
|
227 | 255 |
{ |
228 | 256 |
try |
229 | 257 |
{ |
... | ... | |
280 | 308 |
_childLmSymbol.Commit(); |
281 | 309 |
symoblChild.SPPID_ITEM_OBJECT = _childLmSymbol; |
282 | 310 |
} |
283 |
catch (Exception) |
|
311 |
catch (Exception ex)
|
|
284 | 312 |
{ |
313 |
Console.WriteLine(ex.StackTrace); |
|
314 |
} |
|
315 |
} |
|
316 |
// End |
|
285 | 317 |
|
318 |
// 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 |
} |
|
286 | 334 |
} |
287 | 335 |
} |
336 |
catch (Exception ex) |
|
337 |
{ |
|
338 |
Console.WriteLine(ex.StackTrace); |
|
339 |
} |
|
288 | 340 |
// End |
289 | 341 |
} |
290 | 342 |
} |
291 |
catch (Exception) |
|
343 |
catch (Exception ex)
|
|
292 | 344 |
{ |
293 |
|
|
345 |
Console.WriteLine(ex.StackTrace); |
|
346 |
return false; |
|
294 | 347 |
} |
348 |
return true; |
|
295 | 349 |
} |
296 | 350 |
|
297 | 351 |
public override void SetAttribute() |
... | ... | |
302 | 356 |
|
303 | 357 |
public class Line : SPPID_ITEM |
304 | 358 |
{ |
305 |
public enum SlopType |
|
359 |
public enum SlopeType
|
|
306 | 360 |
{ |
307 | 361 |
NONE = 0, |
308 | 362 |
VERTICAL = 1, |
... | ... | |
313 | 367 |
private string _STARTPOINT; |
314 | 368 |
private string _ENDPOINT; |
315 | 369 |
private List<Connector> _CONNECTORS = new List<Connector>(); |
316 |
private string _LMCONNECTOR_MODELID; |
|
317 |
private SlopType _SLOPTYPE; |
|
370 |
private SlopeType _SLOPTYPE; |
|
318 | 371 |
private double _START_X; |
319 | 372 |
private double _START_Y; |
320 | 373 |
private double _END_X; |
... | ... | |
322 | 375 |
|
323 | 376 |
public string STARTPOINT { get => _STARTPOINT; set => _STARTPOINT = value; } |
324 | 377 |
public string ENDPOINT { get => _ENDPOINT; set => _ENDPOINT = value; } |
325 |
public string LMCONNECTOR_MODELID { get => _LMCONNECTOR_MODELID; set => _LMCONNECTOR_MODELID = value; } |
|
326 | 378 |
public double START_X { get => _START_X; set => _START_X = value; } |
327 | 379 |
public double START_Y { get => _START_Y; set => _START_Y = value; } |
328 | 380 |
public double END_X { get => _END_X; set => _END_X = value; } |
329 | 381 |
public double END_Y { get => _END_Y; set => _END_Y = value; } |
330 | 382 |
public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; } |
331 |
public SlopType SLOPTYPE { get => _SLOPTYPE; set => _SLOPTYPE = value; } |
|
383 |
public SlopeType SLOPTYPE { get => _SLOPTYPE; set => _SLOPTYPE = value; }
|
|
332 | 384 |
#endregion |
333 | 385 |
public override void AfterSetting() |
334 | 386 |
{ |
335 | 387 |
// SPPIDMAPPINGNAME Setting |
336 |
SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME);
|
|
388 |
SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(TYPE);
|
|
337 | 389 |
// End |
338 | 390 |
|
339 | 391 |
// Point Setting |
... | ... | |
344 | 396 |
// End |
345 | 397 |
|
346 | 398 |
// Slop Setting |
347 |
_SLOPTYPE = SPPIDUtill.CalcSlop(new Pointd(_START_X, _START_Y), new Pointd(_END_X, _END_Y));
|
|
399 |
SLOPTYPE = SPPIDUtill.CalcSlop(new PointInfo(_START_X, _START_Y), new PointInfo(_END_X, _END_Y));
|
|
348 | 400 |
// End |
349 | 401 |
|
350 | 402 |
// SPPID Type Setting |
... | ... | |
356 | 408 |
// End |
357 | 409 |
} |
358 | 410 |
|
359 |
public override void Modeling()
|
|
411 |
public override bool Modeling()
|
|
360 | 412 |
{ |
361 | 413 |
throw new MissingMethodException(); |
362 | 414 |
} |
... | ... | |
381 | 433 |
private double _LOCATION_Y; |
382 | 434 |
private string _TEXT; |
383 | 435 |
private string _CONNECTLINE; |
384 |
private Line _TARGETLINE; |
|
385 | 436 |
private LineNumberType _LINENUMBERTYPE; |
386 | 437 |
|
387 | 438 |
public double ANGLE { get => _ANGLE; set => _ANGLE = value; } |
... | ... | |
390 | 441 |
public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; } |
391 | 442 |
public string TEXT { get => _TEXT; set => _TEXT = value; } |
392 | 443 |
public string CONNECTLINE { get => _CONNECTLINE; set => _CONNECTLINE = value; } |
393 |
public Line TARGETLINE { get => _TARGETLINE; set => _TARGETLINE = value; } |
|
394 | 444 |
public LineNumberType LINENUMBERTYPE { get => _LINENUMBERTYPE; set => _LINENUMBERTYPE = value; } |
395 | 445 |
#endregion |
396 | 446 |
|
... | ... | |
425 | 475 |
// End |
426 | 476 |
} |
427 | 477 |
|
428 |
public override void Modeling()
|
|
478 |
public override bool Modeling()
|
|
429 | 479 |
{ |
430 | 480 |
try |
431 | 481 |
{ |
432 |
if (TARGETLINE != null && !string.IsNullOrEmpty(TARGETLINE.LMCONNECTOR_MODELID)) |
|
482 |
Line targetLine = SPPIDUtill.FindObjectByUID(CONNECTLINE) as Line; |
|
483 |
if (targetLine != null && !string.IsNullOrEmpty(targetLine.SPPID_ITEM_OBJECT.ToString())) |
|
433 | 484 |
{ |
434 | 485 |
Placement _placement = new Placement(); |
435 |
Array points = new double[] { LOCATION_X, LOCATION_Y }; |
|
436 |
LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(TARGETLINE.LMCONNECTOR_MODELID);
|
|
486 |
Array points = new double[] { 0, LOCATION_X, LOCATION_Y };
|
|
487 |
LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(targetLine.SPPID_ITEM_OBJECT.ToString());
|
|
437 | 488 |
if (_pipeRun != null) |
438 | 489 |
{ |
439 | 490 |
foreach (LMRepresentation rep in _pipeRun.Representations) |
... | ... | |
449 | 500 |
} |
450 | 501 |
} |
451 | 502 |
} |
452 |
catch (Exception) |
|
503 |
catch (Exception ex)
|
|
453 | 504 |
{ |
454 |
|
|
505 |
Console.WriteLine(ex.StackTrace); |
|
506 |
return false; |
|
455 | 507 |
} |
508 |
return true; |
|
456 | 509 |
} |
457 | 510 |
|
458 | 511 |
public override void SetAttribute() |
459 | 512 |
{ |
460 |
throw new NotImplementedException(); |
|
513 |
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 |
} |
|
461 | 537 |
} |
462 | 538 |
} |
463 | 539 |
|
... | ... | |
468 | 544 |
private string _LOCATION; |
469 | 545 |
private double _LOCATION_X; |
470 | 546 |
private double _LOCATION_Y; |
471 |
private string _TEXT;
|
|
547 |
private string _VALUE;
|
|
472 | 548 |
private string _OWNER; |
473 | 549 |
|
474 | 550 |
public double ANGLE { get => _ANGLE; set => _ANGLE = value; } |
475 | 551 |
public string LOCATION { get => _LOCATION; set => _LOCATION = value; } |
476 | 552 |
public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; } |
477 | 553 |
public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; } |
478 |
public string TEXT { get => _TEXT; set => _TEXT = value; }
|
|
554 |
public string VALUE { get => _VALUE; set => _VALUE = value; }
|
|
479 | 555 |
public string OWNER { get => _OWNER; set => _OWNER = value; } |
480 | 556 |
#endregion |
481 | 557 |
public override void AfterSetting() |
... | ... | |
509 | 585 |
// End |
510 | 586 |
} |
511 | 587 |
|
512 |
public override void Modeling()
|
|
588 |
public override bool Modeling()
|
|
513 | 589 |
{ |
514 | 590 |
try |
515 | 591 |
{ |
516 |
Placement _placement = new Placement(); |
|
517 |
if (NAME == "TEXT" || NAME == "NOTE") |
|
592 |
if (SPPID_ITEM_OBJECT == null) |
|
518 | 593 |
{ |
519 |
LMSymbol _LmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Rotation: ANGLE); |
|
520 |
LMItemNote _LmItemNote = _placement.PIDDataSource.GetItemNote(_LmSymbol.ModelItemID); |
|
521 |
_LmItemNote.Attributes["Note.Body"].set_Value(TEXT); |
|
522 |
_LmItemNote.Commit(); |
|
523 |
SPPID_ITEM_OBJECT = _LmItemNote; |
|
524 |
} |
|
525 |
else if (NAME == "SIZE" && !string.IsNullOrEmpty(OWNER)) |
|
526 |
{ |
|
527 |
object _obj = SPPIDUtill.FindObjectByUID(OWNER); |
|
528 |
|
|
529 |
Array array = new double[] { LOCATION_X, LOCATION_Y }; |
|
530 |
|
|
531 |
if (typeof(Symbol) == _obj.GetType()) |
|
594 |
Placement _placement = new Placement(); |
|
595 |
if (NAME == "TEXT" || NAME == "NOTE") |
|
532 | 596 |
{ |
533 |
Symbol _symbol = _obj as Symbol; |
|
534 |
LMSymbol _LmSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol; |
|
597 |
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; |
|
535 | 611 |
|
536 |
string fileName = _LmSymbol.get_FileName(); |
|
537 |
if (fileName.Contains("Piping")) |
|
538 |
SPPIDMAPPINGNAME = @"\Piping\Labels - Piping Components\Nominal Diameter.sym"; |
|
539 |
else if (fileName.Contains("Instrumentation")) |
|
540 |
SPPIDMAPPINGNAME = @"\Instrumentation\Labels - General Instrument\Nominal Diameter.sym"; |
|
612 |
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"; |
|
541 | 619 |
|
542 |
LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref array, Rotation: ANGLE, LabeledItem: _LmSymbol.AsLMRepresentation(), IsLeaderVisible: true); |
|
543 |
_LmLabelPersist.Commit(); |
|
620 |
LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref array, Rotation: ANGLE, LabeledItem: _LmSymbol.AsLMRepresentation(), IsLeaderVisible: true);
|
|
621 |
_LmLabelPersist.Commit();
|
|
544 | 622 |
|
545 |
SPPID_ITEM_OBJECT = _LmLabelPersist; |
|
623 |
SPPID_ITEM_OBJECT = _LmLabelPersist; |
|
624 |
} |
|
625 |
} |
|
546 | 626 |
} |
547 | 627 |
} |
548 | 628 |
} |
549 |
catch (Exception) |
|
629 |
catch (Exception ex)
|
|
550 | 630 |
{ |
551 |
|
|
631 |
Console.WriteLine(ex.StackTrace); |
|
632 |
return false; |
|
552 | 633 |
} |
634 |
|
|
635 |
return true; |
|
553 | 636 |
} |
554 | 637 |
|
555 | 638 |
public override void SetAttribute() |
556 | 639 |
{ |
557 |
throw new NotImplementedException(); |
|
640 |
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(); |
|
558 | 684 |
} |
내보내기 Unified diff