hytos / DTI_PID / SPPIDConverter / AutoModeling.cs @ 7c3cdd0b
이력 | 보기 | 이력해설 | 다운로드 (85.9 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
using Llama; |
7 |
using Plaice; |
8 |
using Ingr.RAD2D.Interop.RAD2D; |
9 |
using Ingr.RAD2D.Internal; |
10 |
using Ingr.RAD2D.Helper; |
11 |
using Converter.BaseModel; |
12 |
using Converter.SPPID.Model; |
13 |
using Converter.SPPID.Properties; |
14 |
using Converter.SPPID.Util; |
15 |
using Converter.SPPID.DB; |
16 |
using Ingr.RAD2D.MacroControls.CmdCtrl; |
17 |
using Ingr.RAD2D; |
18 |
using System.Windows; |
19 |
using System.Threading; |
20 |
using System.Drawing; |
21 |
using Microsoft.VisualBasic; |
22 |
using Newtonsoft.Json; |
23 |
|
24 |
using DevExpress.XtraSplashScreen; |
25 |
namespace Converter.SPPID |
26 |
{ |
27 |
public class AutoModeling |
28 |
{ |
29 |
Placement _placement; |
30 |
LMADataSource dataSource; |
31 |
dynamic newDrawing; |
32 |
dynamic application; |
33 |
Ingr.RAD2D.Application radApp; |
34 |
SPPID_Document document; |
35 |
ETCSetting _ETCSetting; |
36 |
|
37 |
public string DocumentLabelText { get; set; } |
38 |
|
39 |
int CurrentCount; |
40 |
|
41 |
List <Tuple<string, Line, Line>> BranchLines = new List<Tuple<string, Line, Line>>(); |
42 |
public AutoModeling(SPPID_Document document, dynamic application, Ingr.RAD2D.Application radApp) |
43 |
{ |
44 |
this.document = document; |
45 |
this.application = application; |
46 |
this.radApp = radApp; |
47 |
this._ETCSetting = ETCSetting.GetInstance(); |
48 |
} |
49 |
|
50 |
private int ClacProgressCount() |
51 |
{ |
52 |
int EquipCount = 0; |
53 |
int SymbolCount = 0; |
54 |
int LineCount = 0; |
55 |
int NoteCount = 0; |
56 |
int TextCount = 0; |
57 |
int EndBreakCount = 0; |
58 |
int LineNumberCount = 0; |
59 |
|
60 |
EquipCount = document.Equipments.Count; |
61 |
SymbolCount = document.SYMBOLS.Count; |
62 |
SymbolCount = SymbolCount * 3; |
63 |
|
64 |
foreach (LineNumber lineNumber in document.LINENUMBERS) |
65 |
foreach (LineRun run in lineNumber.RUNS) |
66 |
foreach (var item in run.RUNITEMS) |
67 |
if (item.GetType() == typeof(Line)) |
68 |
LineCount++; |
69 |
foreach (TrimLine trimLine in document.TRIMLINES) |
70 |
foreach (LineRun run in trimLine.RUNS) |
71 |
foreach (var item in run.RUNITEMS) |
72 |
if (item.GetType() == typeof(Line)) |
73 |
LineCount++; |
74 |
|
75 |
LineCount = LineCount * 2; |
76 |
NoteCount = document.NOTES.Count; |
77 |
TextCount = document.TEXTINFOS.Count; |
78 |
EndBreakCount = document.EndBreaks.Count; |
79 |
LineNumberCount = document.LINENUMBERS.Count; |
80 |
LineNumberCount = LineNumberCount * 2; |
81 |
|
82 |
return EquipCount + SymbolCount + LineCount + NoteCount + TextCount + EndBreakCount; |
83 |
} |
84 |
|
85 |
/// <summary> |
86 |
/// 도면 단위당 실행되는 메서드 |
87 |
/// </summary> |
88 |
public void Run() |
89 |
{ |
90 |
try |
91 |
{ |
92 |
_placement = new Placement(); |
93 |
dataSource = _placement.PIDDataSource; |
94 |
|
95 |
CreateDocument(); |
96 |
|
97 |
if (DocumentCoordinateCorrection()) |
98 |
{ |
99 |
int AllCount = ClacProgressCount(); |
100 |
|
101 |
SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true); |
102 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStep, AllCount); |
103 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, DocumentLabelText); |
104 |
Thread.Sleep(1000); |
105 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetParent, (IntPtr)radApp.HWnd); |
106 |
Thread.Sleep(1000); |
107 |
|
108 |
// Equipment Modeling |
109 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Equipments Modeling"); |
110 |
foreach (Equipment equipment in document.Equipments) |
111 |
EquipmentModeling(equipment); |
112 |
|
113 |
// LineRun Symbol Modeling |
114 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Symbols Modeling"); |
115 |
foreach (LineNumber lineNumber in document.LINENUMBERS) |
116 |
foreach (LineRun run in lineNumber.RUNS) |
117 |
SymbolModelingByRun(run); |
118 |
// TrimLineRun Symbol Modeling |
119 |
foreach (TrimLine trimLine in document.TRIMLINES) |
120 |
foreach (LineRun run in trimLine.RUNS) |
121 |
SymbolModelingByRun(run); |
122 |
|
123 |
// LineRun Line Modeling |
124 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Lines Modeling"); |
125 |
foreach (LineNumber lineNumber in document.LINENUMBERS) |
126 |
foreach (LineRun run in lineNumber.RUNS) |
127 |
LineModelingByRun(run); |
128 |
// TrimLineRun Line Modeling |
129 |
foreach (TrimLine trimLine in document.TRIMLINES) |
130 |
foreach (LineRun run in trimLine.RUNS) |
131 |
LineModelingByRun(run); |
132 |
|
133 |
// Branch Line Modeling |
134 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Branch Lines Modeling"); |
135 |
foreach (var item in BranchLines) |
136 |
BranchLineModeling(item); |
137 |
|
138 |
// EndBreak Modeling |
139 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "EndBreaks Modeling"); |
140 |
foreach (var item in document.EndBreaks) |
141 |
EndBreakModeling(item); |
142 |
|
143 |
// LineNumber Modeling |
144 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "LineNumbers Modeling"); |
145 |
foreach (var item in document.LINENUMBERS) |
146 |
LineNumberModeling(item); |
147 |
|
148 |
// Note Modeling |
149 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Notes Modeling"); |
150 |
foreach (var item in document.NOTES) |
151 |
NoteModeling(item); |
152 |
|
153 |
// Text Modeling |
154 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Texts Modeling"); |
155 |
foreach (var item in document.TEXTINFOS) |
156 |
TextModeling(item); |
157 |
|
158 |
// LineRun Line Join |
159 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Join LineRuns"); |
160 |
foreach (LineNumber lineNumber in document.LINENUMBERS) |
161 |
foreach (LineRun run in lineNumber.RUNS) |
162 |
JoinRunLine(run); |
163 |
// TrimLineRun Line Join |
164 |
foreach (TrimLine trimLine in document.TRIMLINES) |
165 |
foreach (LineRun run in trimLine.RUNS) |
166 |
JoinRunLine(run); |
167 |
|
168 |
// Input LineNumber Attribute |
169 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Set Lines Attribute"); |
170 |
foreach (var item in document.LINENUMBERS) |
171 |
InputLineNumberAttribute(item); |
172 |
|
173 |
// Input Symbol Attribute |
174 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Set Symbols Attribute"); |
175 |
foreach (var item in document.SYMBOLS) |
176 |
InputSymbolAttribute(item, item.ATTRIBUTES); |
177 |
|
178 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Labels Modeling"); |
179 |
#region Label Modeling |
180 |
foreach (var item in document.SYMBOLS) |
181 |
LabelSymbolModeling(item); |
182 |
#endregion |
183 |
|
184 |
|
185 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, AllCount); |
186 |
} |
187 |
} |
188 |
catch (Exception ex) |
189 |
{ |
190 |
System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
191 |
} |
192 |
finally |
193 |
{ |
194 |
application.ActiveWindow.Fit(); |
195 |
|
196 |
if (newDrawing != null) |
197 |
{ |
198 |
radApp.ActiveDocument.SaveOnClose = false; |
199 |
radApp.ActiveDocument.Save(); |
200 |
ReleaseCOMObjects(newDrawing); |
201 |
} |
202 |
|
203 |
ReleaseCOMObjects(dataSource); |
204 |
ReleaseCOMObjects(_placement); |
205 |
|
206 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.ClearParent, null); |
207 |
SplashScreenManager.CloseForm(false); |
208 |
} |
209 |
} |
210 |
|
211 |
/// <summary> |
212 |
/// 도면 생성 메서드 |
213 |
/// </summary> |
214 |
private void CreateDocument() |
215 |
{ |
216 |
newDrawing = application.Drawings.Add(document.Unit, document.Template, document.DrawingNumber, document.DrawingName); |
217 |
application.ActiveWindow.Fit(); |
218 |
Thread.Sleep(1000); |
219 |
application.ActiveWindow.Zoom = 2000; |
220 |
Thread.Sleep(2000); |
221 |
} |
222 |
|
223 |
/// <summary> |
224 |
/// 도면 크기 구하는 메서드 |
225 |
/// </summary> |
226 |
/// <returns></returns> |
227 |
private bool DocumentCoordinateCorrection() |
228 |
{ |
229 |
double maxX = 0; |
230 |
double maxY = 0; |
231 |
foreach (object drawingObj in radApp.ActiveDocument.ActiveSheet.DrawingObjects) |
232 |
{ |
233 |
Ingr.RAD2D.SmartFrame2d smartFrame2d = drawingObj as Ingr.RAD2D.SmartFrame2d; |
234 |
if (smartFrame2d != null) |
235 |
{ |
236 |
double x1 = 0; |
237 |
double x2 = 0; |
238 |
double y1 = 0; |
239 |
double y2 = 0; |
240 |
smartFrame2d.Range(out x1, out y1, out x2, out y2); |
241 |
maxX = Math.Max(x2, maxX); |
242 |
maxY = Math.Max(y2, maxY); |
243 |
} |
244 |
} |
245 |
if (maxX != 0 && maxY != 0) |
246 |
{ |
247 |
document.SetSPPIDLocation(maxX, maxY); |
248 |
return true; |
249 |
} |
250 |
else |
251 |
return false; |
252 |
} |
253 |
|
254 |
/// <summary> |
255 |
/// 라인을 Run 단위로 모델링하는 진입 메서드 |
256 |
/// </summary> |
257 |
/// <param name="run"></param> |
258 |
private void LineModelingByRun(LineRun run) |
259 |
{ |
260 |
Line prevLine = null; |
261 |
List<Line> lines = new List<Line>(); |
262 |
foreach (var item in run.RUNITEMS) |
263 |
{ |
264 |
// Line일 경우 |
265 |
if (item.GetType() == typeof(Line)) |
266 |
{ |
267 |
Line line = item as Line; |
268 |
if (prevLine == null) |
269 |
lines.Add(line); |
270 |
else if (prevLine != null) |
271 |
{ |
272 |
if (prevLine.SPPID.MAPPINGNAME == line.SPPID.MAPPINGNAME) |
273 |
lines.Add(line); |
274 |
else |
275 |
{ |
276 |
if (lines.Count > 0) |
277 |
{ |
278 |
LineModeling(lines); |
279 |
lines.Clear(); |
280 |
} |
281 |
lines.Add(line); |
282 |
} |
283 |
} |
284 |
|
285 |
prevLine = line; |
286 |
|
287 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
288 |
} |
289 |
// Symbol 일 경우 |
290 |
else if (item.GetType() == typeof(Symbol)) |
291 |
{ |
292 |
if (lines.Count > 0) |
293 |
{ |
294 |
LineModeling(lines); |
295 |
lines.Clear(); |
296 |
} |
297 |
} |
298 |
} |
299 |
|
300 |
if (lines.Count > 0) |
301 |
LineModeling(lines); |
302 |
} |
303 |
|
304 |
/// <summary> |
305 |
/// 심볼을 Run 단위로 모델링하는 진입 메서드 |
306 |
/// </summary> |
307 |
/// <param name="run"></param> |
308 |
private void SymbolModelingByRun(LineRun run) |
309 |
{ |
310 |
// 양끝 Symbol 검사 후 Line이 나올때까지만 Symbol Modeling |
311 |
if (run.RUNITEMS.Count > 0) |
312 |
{ |
313 |
if (run.RUNITEMS[0].GetType() == typeof(Symbol)) |
314 |
SymbolModelingByRunStart(run.RUNITEMS[0] as Symbol, run); |
315 |
|
316 |
if (run.RUNITEMS[run.RUNITEMS.Count - 1].GetType() == typeof(Symbol)) |
317 |
SymbolModelingByRunEnd(run.RUNITEMS[run.RUNITEMS.Count - 1] as Symbol, run); |
318 |
} |
319 |
|
320 |
Symbol prevSymbol = null; |
321 |
Symbol targetSymbol = null; |
322 |
foreach (var item in run.RUNITEMS) |
323 |
{ |
324 |
if (item.GetType() == typeof(Symbol)) |
325 |
{ |
326 |
Symbol symbol = item as Symbol; |
327 |
SymbolModeling(symbol, targetSymbol, prevSymbol); |
328 |
prevSymbol = symbol; |
329 |
targetSymbol = symbol; |
330 |
} |
331 |
else |
332 |
{ |
333 |
targetSymbol = null; |
334 |
} |
335 |
} |
336 |
} |
337 |
|
338 |
/// <summary> |
339 |
/// Run에 있는 심볼을 모델링하는데 기준이 Run의 시작점 |
340 |
/// </summary> |
341 |
/// <param name="symbol"></param> |
342 |
/// <param name="run"></param> |
343 |
private void SymbolModelingByRunStart(Symbol symbol, LineRun run) |
344 |
{ |
345 |
foreach (var connector in symbol.CONNECTORS) |
346 |
{ |
347 |
object targetItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
348 |
if (targetItem != null && |
349 |
(targetItem.GetType() == typeof(Symbol) || targetItem.GetType() == typeof(Equipment)) && |
350 |
!IsSameLineRun(symbol, targetItem)) |
351 |
{ |
352 |
SymbolModeling(symbol, targetItem as Symbol, null); |
353 |
for (int i = 1; i < run.RUNITEMS.Count; i++) |
354 |
{ |
355 |
object item = run.RUNITEMS[i]; |
356 |
if (item.GetType() == typeof(Symbol)) |
357 |
SymbolModeling(item as Symbol, run.RUNITEMS[i - 1] as Symbol, null); |
358 |
else |
359 |
break; |
360 |
} |
361 |
break; |
362 |
} |
363 |
} |
364 |
|
365 |
|
366 |
} |
367 |
|
368 |
/// <summary> |
369 |
/// Run에 있는 심볼을 모델링하는데 기준이 Run의 끝점 |
370 |
/// </summary> |
371 |
/// <param name="symbol"></param> |
372 |
/// <param name="run"></param> |
373 |
private void SymbolModelingByRunEnd(Symbol symbol, LineRun run) |
374 |
{ |
375 |
foreach (var connector in symbol.CONNECTORS) |
376 |
{ |
377 |
object targetItem = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM); |
378 |
if (targetItem != null && |
379 |
(targetItem.GetType() == typeof(Symbol) || targetItem.GetType() == typeof(Equipment)) && |
380 |
!IsSameLineRun(symbol, targetItem)) |
381 |
{ |
382 |
SymbolModeling(symbol, targetItem as Symbol, null); |
383 |
for (int i = run.RUNITEMS.Count - 2; i >= 0; i--) |
384 |
{ |
385 |
object item = run.RUNITEMS[i]; |
386 |
if (item.GetType() == typeof(Symbol)) |
387 |
SymbolModeling(item as Symbol, run.RUNITEMS[i + 1] as Symbol, null); |
388 |
else |
389 |
break; |
390 |
} |
391 |
break; |
392 |
} |
393 |
} |
394 |
} |
395 |
|
396 |
/// <summary> |
397 |
/// 심볼을 실제로 Modeling 메서드 |
398 |
/// </summary> |
399 |
/// <param name="symbol"></param> |
400 |
/// <param name="targetSymbol"></param> |
401 |
/// <param name="prevSymbol"></param> |
402 |
private void SymbolModeling(Symbol symbol, Symbol targetSymbol, Symbol prevSymbol) |
403 |
{ |
404 |
// OWNERSYMBOL Attribute, 값을 가지고 있을 경우 |
405 |
BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(attr => attr.ATTRIBUTE == "OWNERSYMBOL"); |
406 |
if (itemAttribute != null && string.IsNullOrEmpty(itemAttribute.VALUE) && itemAttribute.VALUE != "None") |
407 |
return; |
408 |
// 이미 모델링 됐을 경우 |
409 |
else if (!string.IsNullOrEmpty(symbol.SPPID.RepresentationId)) |
410 |
return; |
411 |
|
412 |
LMSymbol _LMSymbol = null; |
413 |
|
414 |
string mappingPath = symbol.SPPID.MAPPINGNAME; |
415 |
double x = symbol.SPPID.ORIGINAL_X; |
416 |
double y = symbol.SPPID.ORIGINAL_Y; |
417 |
int mirror = 0; |
418 |
double angle = symbol.ANGLE; |
419 |
|
420 |
SPPIDUtil.ConvertGridPoint(ref x, ref y); |
421 |
|
422 |
// OPC 일경우 180도 일때 Mirror |
423 |
if (mappingPath.Contains("Piping OPC's") && angle == Math.PI) |
424 |
mirror = 1; |
425 |
|
426 |
if (targetSymbol != null && !string.IsNullOrEmpty(targetSymbol.SPPID.RepresentationId)) |
427 |
{ |
428 |
LMSymbol _TargetItem = dataSource.GetSymbol(targetSymbol.SPPID.RepresentationId); |
429 |
|
430 |
Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[_TargetItem.get_GraphicOID().ToString()]; |
431 |
double x1 = 0; |
432 |
double x2 = 0; |
433 |
double y1 = 0; |
434 |
double y2 = 0; |
435 |
symbol2d.Range(out x1, out y1, out x2, out y2); |
436 |
|
437 |
if (y2 < y) |
438 |
y = y2; |
439 |
else if (y1 > y) |
440 |
y = y1; |
441 |
|
442 |
if (x2 < x) |
443 |
x = x2; |
444 |
else if (x1 > x) |
445 |
x = x1; |
446 |
|
447 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem); |
448 |
ReleaseCOMObjects(_TargetItem); |
449 |
} |
450 |
else if (prevSymbol != null) |
451 |
{ |
452 |
LMSymbol _PrevSymbol = dataSource.GetSymbol(prevSymbol.SPPID.RepresentationId); |
453 |
SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y); |
454 |
double prevX = _PrevSymbol.get_XCoordinate(); |
455 |
double prevY = _PrevSymbol.get_YCoordinate(); |
456 |
//if (slopeType == SlopeType.HORIZONTAL) |
457 |
// y = prevY; |
458 |
//else if (slopeType == SlopeType.VERTICAL) |
459 |
// x = prevX; |
460 |
ReleaseCOMObjects(_PrevSymbol); |
461 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
462 |
} |
463 |
else |
464 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
465 |
|
466 |
|
467 |
if (_LMSymbol != null) |
468 |
{ |
469 |
_LMSymbol.Commit(); |
470 |
symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
471 |
symbol.SPPID.GraphicOID = _LMSymbol.get_GraphicOID(); |
472 |
|
473 |
foreach (var item in symbol.ChildSymbols) |
474 |
CreateChildSymbol(item, _LMSymbol); |
475 |
} |
476 |
|
477 |
ReleaseCOMObjects(_LMSymbol); |
478 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
479 |
} |
480 |
|
481 |
private void LabelSymbolModeling(Symbol symbol) |
482 |
{ |
483 |
BaseModel.Attribute itemAttribute = symbol.ATTRIBUTES.Find(x => x.ATTRIBUTE == "OWNERSYMBOL"); |
484 |
if (itemAttribute == null || string.IsNullOrEmpty(itemAttribute.VALUE)) |
485 |
return; |
486 |
|
487 |
Array points = new double[] { 0, symbol.SPPID.ORIGINAL_X, symbol.SPPID.ORIGINAL_Y }; |
488 |
|
489 |
string symbolUID = itemAttribute.VALUE; |
490 |
object targetItem = SPPIDUtil.FindObjectByUID(document, symbolUID); |
491 |
if (targetItem != null) |
492 |
{ |
493 |
// Object 아이템이 Symbol일 경우 Equipment일 경우 |
494 |
string sRep = null; |
495 |
if (targetItem.GetType() == typeof(Symbol)) |
496 |
sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
497 |
else if (targetItem.GetType() == typeof(Equipment)) |
498 |
sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
499 |
|
500 |
if (!string.IsNullOrEmpty(sRep)) |
501 |
{ |
502 |
// LEADER Line 검사 |
503 |
bool leaderLine = false; |
504 |
SymbolMapping symbolMapping = document.SymbolMappings.Find(x => x.UID == symbol.DBUID); |
505 |
if (symbolMapping != null) |
506 |
leaderLine = symbolMapping.LEADERLINE; |
507 |
|
508 |
// Target Symbol Item 가져오고 Label Modeling |
509 |
LMSymbol _TargetItem = dataSource.GetSymbol(sRep); |
510 |
LMLabelPersist _LMLabelPresist = _placement.PIDPlaceLabel(symbol.SPPID.MAPPINGNAME, ref points, Rotation: 0, LabeledItem: _TargetItem.AsLMRepresentation(), IsLeaderVisible: leaderLine); |
511 |
|
512 |
// Target Item에 Label의 Attribute Input |
513 |
InputSymbolAttribute(targetItem, symbol.ATTRIBUTES); |
514 |
|
515 |
//Leader 선 센터로 |
516 |
string OID = _LMLabelPresist.get_GraphicOID(); |
517 |
DependencyObject dependency = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID] as DependencyObject; |
518 |
if (dependency != null) |
519 |
{ |
520 |
bool result = false; |
521 |
foreach (var attributes in dependency.AttributeSets) |
522 |
{ |
523 |
foreach (var attribute in attributes) |
524 |
{ |
525 |
string name = attribute.Name; |
526 |
string value = attribute.GetValue().ToString(); |
527 |
if (name == "DrawingItemType" && value == "LabelPersist") |
528 |
{ |
529 |
foreach (DrawingObjectBase drawingObject in dependency.DrawingObjects) |
530 |
{ |
531 |
if (drawingObject.Type == Ingr.RAD2D.ObjectType.igLineString2d) |
532 |
{ |
533 |
Ingr.RAD2D.LineString2d lineString2D = drawingObject as Ingr.RAD2D.LineString2d; |
534 |
double prevX = _TargetItem.get_XCoordinate(); |
535 |
double prevY = _TargetItem.get_YCoordinate(); |
536 |
lineString2D.InsertVertex(lineString2D.VertexCount, prevX, prevY); |
537 |
lineString2D.RemoveVertex(lineString2D.VertexCount); |
538 |
result = true; |
539 |
break; |
540 |
} |
541 |
} |
542 |
} |
543 |
|
544 |
if (result) |
545 |
break; |
546 |
} |
547 |
|
548 |
if (result) |
549 |
break; |
550 |
} |
551 |
} |
552 |
|
553 |
_LMLabelPresist.Commit(); |
554 |
ReleaseCOMObjects(_TargetItem); |
555 |
ReleaseCOMObjects(_LMLabelPresist); |
556 |
} |
557 |
} |
558 |
|
559 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
560 |
} |
561 |
|
562 |
/// <summary> |
563 |
/// Equipment를 실제로 Modeling 메서드 |
564 |
/// </summary> |
565 |
/// <param name="equipment"></param> |
566 |
private void EquipmentModeling(Equipment equipment) |
567 |
{ |
568 |
if (!string.IsNullOrEmpty(equipment.SPPID.RepresentationId)) |
569 |
return; |
570 |
|
571 |
LMSymbol _LMSymbol = null; |
572 |
LMSymbol targetItem = null; |
573 |
string mappingPath = equipment.SPPID.MAPPINGNAME; |
574 |
double x = equipment.SPPID.ORIGINAL_X; |
575 |
double y = equipment.SPPID.ORIGINAL_Y; |
576 |
int mirror = 0; |
577 |
double angle = equipment.ANGLE; |
578 |
|
579 |
SPPIDUtil.ConvertGridPoint(ref x, ref y); |
580 |
|
581 |
Connector connector = equipment.CONNECTORS.Find(conn => !string.IsNullOrEmpty(conn.CONNECTEDITEM) && conn.CONNECTEDITEM != "None"); |
582 |
if (connector != null) |
583 |
{ |
584 |
Equipment connEquipment = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM) as Equipment; |
585 |
if (connEquipment != null) |
586 |
{ |
587 |
if (string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId)) |
588 |
EquipmentModeling(connEquipment); |
589 |
|
590 |
if (!string.IsNullOrEmpty(connEquipment.SPPID.RepresentationId)) |
591 |
{ |
592 |
targetItem = dataSource.GetSymbol(connEquipment.SPPID.RepresentationId); |
593 |
if (targetItem != null) |
594 |
{ |
595 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: targetItem); |
596 |
} |
597 |
else |
598 |
{ |
599 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
600 |
} |
601 |
} |
602 |
else |
603 |
{ |
604 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
605 |
} |
606 |
} |
607 |
else |
608 |
{ |
609 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
610 |
} |
611 |
} |
612 |
else |
613 |
{ |
614 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
615 |
} |
616 |
|
617 |
if (_LMSymbol != null) |
618 |
{ |
619 |
_LMSymbol.Commit(); |
620 |
equipment.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
621 |
equipment.SPPID.GraphicOID = _LMSymbol.get_GraphicOID(); |
622 |
ReleaseCOMObjects(_LMSymbol); |
623 |
} |
624 |
|
625 |
if (targetItem != null) |
626 |
{ |
627 |
ReleaseCOMObjects(targetItem); |
628 |
} |
629 |
|
630 |
ReleaseCOMObjects(_LMSymbol); |
631 |
|
632 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
633 |
} |
634 |
|
635 |
/// <summary> |
636 |
/// 심볼을 실제로 Modeling할때 ChildSymbol이 있다면 Modeling하는 메서드 |
637 |
/// </summary> |
638 |
/// <param name="childSymbol"></param> |
639 |
/// <param name="parentSymbol"></param> |
640 |
private void CreateChildSymbol(ChildSymbol childSymbol, LMSymbol parentSymbol) |
641 |
{ |
642 |
Ingr.RAD2D.Symbol2d symbol2d = radApp.ActiveDocument.ActiveSheet.DrawingObjects[parentSymbol.get_GraphicOID().ToString()]; |
643 |
double x1 = 0; |
644 |
double x2 = 0; |
645 |
double y1 = 0; |
646 |
double y2 = 0; |
647 |
symbol2d.Range(out x1, out y1, out x2, out y2); |
648 |
|
649 |
LMSymbol _LMSymbol = _placement.PIDPlaceSymbol(childSymbol.SPPID.MAPPINGNAME, (x1 + x2) / 2, (y1 + y2) / 2, TargetItem: parentSymbol); |
650 |
if (_LMSymbol != null) |
651 |
{ |
652 |
childSymbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
653 |
foreach (var item in childSymbol.ChildSymbols) |
654 |
CreateChildSymbol(item, _LMSymbol); |
655 |
} |
656 |
|
657 |
|
658 |
ReleaseCOMObjects(_LMSymbol); |
659 |
} |
660 |
|
661 |
/// <summary> |
662 |
/// item이 TargetItem과 같은 LineRun에 있는지 검사 |
663 |
/// </summary> |
664 |
/// <param name="item"></param> |
665 |
/// <param name="targetItem"></param> |
666 |
/// <returns></returns> |
667 |
private bool IsSameLineRun(object item, object targetItem) |
668 |
{ |
669 |
foreach (var lineNumber in document.LINENUMBERS) |
670 |
{ |
671 |
foreach (var run in lineNumber.RUNS) |
672 |
{ |
673 |
foreach (var runItem in run.RUNITEMS) |
674 |
{ |
675 |
if (runItem == item) |
676 |
{ |
677 |
foreach (var findItem in run.RUNITEMS) |
678 |
{ |
679 |
if (findItem == targetItem) |
680 |
{ |
681 |
return true; |
682 |
} |
683 |
} |
684 |
|
685 |
return false; |
686 |
|
687 |
} |
688 |
} |
689 |
} |
690 |
} |
691 |
|
692 |
return false; |
693 |
} |
694 |
|
695 |
/// <summary> |
696 |
/// Line을 실제로 모델링하는 메서드 |
697 |
/// </summary> |
698 |
/// <param name="lines"></param> |
699 |
private void LineModeling(List<Line> lines) |
700 |
{ |
701 |
_LMAItem _LMAItem = _placement.PIDCreateItem(lines[0].SPPID.MAPPINGNAME); |
702 |
PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
703 |
LMSymbol _LMSymbol1 = null; |
704 |
LMSymbol _LMSymbol2 = null; |
705 |
Dictionary<LMConnector, List<double[]>> connectorVertices1 = new Dictionary<LMConnector, List<double[]>>(); |
706 |
LMConnector targetConnector1 = null; |
707 |
Dictionary<LMConnector, List<double[]>> connectorVertices2 = new Dictionary<LMConnector, List<double[]>>(); |
708 |
LMConnector targetConnector2 = null; |
709 |
|
710 |
Line startBranchLine = null; |
711 |
Line endBranchLine = null; |
712 |
|
713 |
for (int i = 0; i < lines.Count; i++) |
714 |
{ |
715 |
Line line = lines[i]; |
716 |
if (i == 0 || i + 1 != lines.Count) |
717 |
{ |
718 |
// 시작점에 연결된 Symbol 찾기 |
719 |
object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[0].CONNECTEDITEM); |
720 |
if (connItem != null && connItem.GetType() == typeof(Symbol)) |
721 |
{ |
722 |
_LMSymbol1 = GetTargetSymbol(connItem as Symbol, line); |
723 |
if (_LMSymbol1 != null) |
724 |
placeRunInputs.AddSymbolTarget(_LMSymbol1, line.SPPID.START_X, line.SPPID.START_Y); |
725 |
else |
726 |
placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y); |
727 |
} |
728 |
else if (connItem != null && connItem.GetType() == typeof(Line) && !lines.Contains(connItem)) |
729 |
{ |
730 |
connectorVertices1 = GetPipeRunVertices(((Line)connItem).SPPID.ModelItemId); |
731 |
targetConnector1 = FindTargetLMConnector(connectorVertices1, line.SPPID.START_X, line.SPPID.START_Y, line.SPPID.END_X, line.SPPID.END_Y); |
732 |
|
733 |
if (targetConnector1 != null) |
734 |
placeRunInputs.AddConnectorTarget(targetConnector1, line.SPPID.START_X, line.SPPID.START_Y); |
735 |
else |
736 |
{ |
737 |
startBranchLine = connItem as Line; |
738 |
placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y); |
739 |
} |
740 |
} |
741 |
else |
742 |
placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y); |
743 |
} |
744 |
|
745 |
if (i + 1 == lines.Count) |
746 |
{ |
747 |
// 끝점에 연결된 Symbol 찾기 |
748 |
object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[1].CONNECTEDITEM); |
749 |
|
750 |
if (i != 0) |
751 |
placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y); |
752 |
|
753 |
if (connItem != null && connItem.GetType() == typeof(Symbol)) |
754 |
{ |
755 |
_LMSymbol2 = GetTargetSymbol(connItem as Symbol, line); |
756 |
if (_LMSymbol2 != null) |
757 |
placeRunInputs.AddSymbolTarget(_LMSymbol2, line.SPPID.END_X, line.SPPID.END_Y); |
758 |
else |
759 |
placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y); |
760 |
|
761 |
} |
762 |
else if (connItem != null && connItem.GetType() == typeof(Line) && !lines.Contains(connItem)) |
763 |
{ |
764 |
connectorVertices2 = GetPipeRunVertices(((Line)connItem).SPPID.ModelItemId); |
765 |
targetConnector2 = FindTargetLMConnector(connectorVertices2, line.SPPID.END_X, line.SPPID.END_Y, line.SPPID.START_X, line.SPPID.START_Y); |
766 |
|
767 |
if (targetConnector2 != null) |
768 |
placeRunInputs.AddConnectorTarget(targetConnector2, line.SPPID.END_X, line.SPPID.END_Y); |
769 |
else |
770 |
{ |
771 |
endBranchLine = connItem as Line; |
772 |
placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y); |
773 |
} |
774 |
} |
775 |
else |
776 |
{ |
777 |
placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y); |
778 |
} |
779 |
} |
780 |
} |
781 |
|
782 |
LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
783 |
|
784 |
if (_lMConnector != null) |
785 |
{ |
786 |
foreach (var line in lines) |
787 |
line.SPPID.ModelItemId = _lMConnector.ModelItemID; |
788 |
_lMConnector.Commit(); |
789 |
if (startBranchLine != null || endBranchLine != null) |
790 |
{ |
791 |
BranchLines.Add(new Tuple<string, Line, Line>(_lMConnector.ModelItemID, startBranchLine, endBranchLine)); |
792 |
} |
793 |
} |
794 |
|
795 |
|
796 |
if (_LMSymbol1 != null) |
797 |
ReleaseCOMObjects(_LMSymbol1); |
798 |
if (_LMSymbol2 != null) |
799 |
ReleaseCOMObjects(_LMSymbol2); |
800 |
if (targetConnector1 != null) |
801 |
ReleaseCOMObjects(targetConnector1); |
802 |
if (targetConnector2 != null) |
803 |
ReleaseCOMObjects(targetConnector2); |
804 |
foreach (var item in connectorVertices1) |
805 |
ReleaseCOMObjects(item.Key); |
806 |
foreach (var item in connectorVertices2) |
807 |
ReleaseCOMObjects(item.Key); |
808 |
|
809 |
ReleaseCOMObjects(_lMConnector); |
810 |
ReleaseCOMObjects(placeRunInputs); |
811 |
ReleaseCOMObjects(_LMAItem); |
812 |
} |
813 |
|
814 |
/// <summary> |
815 |
/// Symbol이 모델링된 SPPPID Symbol Object를 반환 - 연결된 Symbol이 ChildSymbol일 수도 있기때문에 메서드 개발 |
816 |
/// </summary> |
817 |
/// <param name="symbol"></param> |
818 |
/// <param name="line"></param> |
819 |
/// <returns></returns> |
820 |
private LMSymbol GetTargetSymbol(Symbol symbol, Line line) |
821 |
{ |
822 |
LMSymbol _LMSymbol = null; |
823 |
foreach (var connector in symbol.CONNECTORS) |
824 |
{ |
825 |
if (connector.CONNECTEDITEM == line.UID) |
826 |
{ |
827 |
if (connector.Index == 0) |
828 |
_LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
829 |
else |
830 |
{ |
831 |
ChildSymbol child = null; |
832 |
foreach (var childSymbol in symbol.ChildSymbols) |
833 |
{ |
834 |
if (childSymbol.Connectors.Contains(connector)) |
835 |
child = childSymbol; |
836 |
else |
837 |
child = GetChildSymbolByConnector(childSymbol, connector); |
838 |
|
839 |
if (child != null) |
840 |
break; |
841 |
} |
842 |
|
843 |
if (child != null) |
844 |
_LMSymbol = dataSource.GetSymbol(child.SPPID.RepresentationId); |
845 |
} |
846 |
|
847 |
break; |
848 |
} |
849 |
} |
850 |
|
851 |
return _LMSymbol; |
852 |
} |
853 |
|
854 |
/// <summary> |
855 |
/// Connector를 가지고 있는 ChildSymbol Object 반환 |
856 |
/// </summary> |
857 |
/// <param name="item"></param> |
858 |
/// <param name="connector"></param> |
859 |
/// <returns></returns> |
860 |
private ChildSymbol GetChildSymbolByConnector(ChildSymbol item, Connector connector) |
861 |
{ |
862 |
foreach (var childSymbol in item.ChildSymbols) |
863 |
{ |
864 |
if (childSymbol.Connectors.Contains(connector)) |
865 |
return childSymbol; |
866 |
else |
867 |
return GetChildSymbolByConnector(childSymbol, connector); |
868 |
} |
869 |
|
870 |
return null; |
871 |
} |
872 |
|
873 |
/// <summary> |
874 |
/// Branch 라인을 다시 모델링하는 진입 메서드 |
875 |
/// </summary> |
876 |
/// <param name="branch"></param> |
877 |
private void BranchLineModeling(Tuple<string, Line, Line> branch) |
878 |
{ |
879 |
List<Line> lines = SPPIDUtil.FindLinesByModelId(document, branch.Item1); |
880 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(branch.Item1); |
881 |
|
882 |
LMConnector _StartConnector = null; |
883 |
LMConnector _EndConnector = null; |
884 |
double lengthStart = double.MaxValue; |
885 |
double lengthEnd = double.MaxValue; |
886 |
List<double[]> startPoints = new List<double[]>(); |
887 |
List<double[]> endPoints = new List<double[]>(); |
888 |
|
889 |
foreach (var item in connectorVertices) |
890 |
{ |
891 |
foreach (var point in item.Value) |
892 |
{ |
893 |
// Start Point가 Branch |
894 |
if (branch.Item2 != null) |
895 |
{ |
896 |
Line targetLine = branch.Item2; |
897 |
double distance = SPPIDUtil.CalcLineToPointDistance(targetLine.SPPID.START_X, targetLine.SPPID.START_Y, targetLine.SPPID.END_X, targetLine.SPPID.END_Y, point[0], point[1]); |
898 |
if (lengthStart > distance) |
899 |
{ |
900 |
_StartConnector = item.Key; |
901 |
lengthStart = distance; |
902 |
startPoints = item.Value; |
903 |
} |
904 |
} |
905 |
// End Point가 Branch |
906 |
if (branch.Item3 != null) |
907 |
{ |
908 |
Line targetLine = branch.Item3; |
909 |
double distance = SPPIDUtil.CalcLineToPointDistance(targetLine.SPPID.START_X, targetLine.SPPID.START_Y, targetLine.SPPID.END_X, targetLine.SPPID.END_Y, point[0], point[1]); |
910 |
if (lengthEnd > distance) |
911 |
{ |
912 |
_EndConnector = item.Key; |
913 |
lengthEnd = distance; |
914 |
endPoints = item.Value; |
915 |
} |
916 |
} |
917 |
} |
918 |
} |
919 |
#region Branch가 양쪽 전부일 때 |
920 |
if (_StartConnector != null && _StartConnector == _EndConnector) |
921 |
{ |
922 |
_placement.PIDRemovePlacement(_StartConnector.AsLMRepresentation()); |
923 |
|
924 |
_LMAItem _LMAItem = _placement.PIDCreateItem(lines[0].SPPID.MAPPINGNAME); |
925 |
PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
926 |
|
927 |
Dictionary<LMConnector, List<double[]>> startConnectorVertices = GetPipeRunVertices(branch.Item2.SPPID.ModelItemId); |
928 |
LMConnector _StartTargetConnector = FindTargetLMConnector(startConnectorVertices, startPoints[0][0], startPoints[0][1], startPoints[1][0], startPoints[1][1]); |
929 |
Dictionary<LMConnector, List<double[]>> endConnectorVertices = GetPipeRunVertices(branch.Item3.SPPID.ModelItemId); |
930 |
LMConnector _EndTargetConnector = FindTargetLMConnector(endConnectorVertices, |
931 |
startPoints[startPoints.Count - 1][0], |
932 |
startPoints[startPoints.Count - 1][1], |
933 |
startPoints[startPoints.Count - 2][0], |
934 |
startPoints[startPoints.Count - 2][1]); |
935 |
|
936 |
for (int i = 0; i < startPoints.Count; i++) |
937 |
{ |
938 |
double[] point = startPoints[i]; |
939 |
if (i == 0) |
940 |
placeRunInputs.AddConnectorTarget(_StartTargetConnector, point[0], point[1]); |
941 |
else if (i == startPoints.Count - 1) |
942 |
placeRunInputs.AddConnectorTarget(_EndTargetConnector, point[0], point[1]); |
943 |
else |
944 |
placeRunInputs.AddPoint(point[0], point[1]); |
945 |
} |
946 |
|
947 |
LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
948 |
if (_LMConnector != null) |
949 |
{ |
950 |
_LMConnector.Commit(); |
951 |
foreach (var item in lines) |
952 |
item.SPPID.ModelItemId = _LMConnector.ModelItemID; |
953 |
} |
954 |
|
955 |
foreach (var item in startConnectorVertices) |
956 |
ReleaseCOMObjects(item.Key); |
957 |
foreach (var item in endConnectorVertices) |
958 |
ReleaseCOMObjects(item.Key); |
959 |
ReleaseCOMObjects(placeRunInputs); |
960 |
ReleaseCOMObjects(_LMAItem); |
961 |
ReleaseCOMObjects(_LMConnector); |
962 |
} |
963 |
#endregion |
964 |
#region 양쪽이 다른 Branch |
965 |
else |
966 |
{ |
967 |
// Branch 시작 Connector |
968 |
if (_StartConnector != null) |
969 |
BranchLineModelingByConnector(branch, _StartConnector, startPoints, true); |
970 |
|
971 |
// Branch 끝 Connector |
972 |
if (_EndConnector != null) |
973 |
BranchLineModelingByConnector(branch, _EndConnector, endPoints, false); |
974 |
} |
975 |
#endregion |
976 |
|
977 |
if (_StartConnector != null) |
978 |
ReleaseCOMObjects(_StartConnector); |
979 |
if (_EndConnector != null) |
980 |
ReleaseCOMObjects(_EndConnector); |
981 |
foreach (var item in connectorVertices) |
982 |
ReleaseCOMObjects(item.Key); |
983 |
} |
984 |
|
985 |
/// <summary> |
986 |
/// Branch 라인을 다시 실제로 모델링하는 메서드 |
987 |
/// </summary> |
988 |
/// <param name="branch"></param> |
989 |
/// <param name="_Connector"></param> |
990 |
/// <param name="points"></param> |
991 |
/// <param name="IsStart"></param> |
992 |
private void BranchLineModelingByConnector(Tuple<string, Line, Line> branch, LMConnector _Connector, List<double[]> points, bool IsStart) |
993 |
{ |
994 |
List<Line> lines = SPPIDUtil.FindLinesByModelId(document, branch.Item1); |
995 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(branch.Item1); |
996 |
LMConnector _SameRunTargetConnector = null; |
997 |
LMSymbol _SameRunTargetSymbol = null; |
998 |
Dictionary<LMConnector, List<double[]>> branchConnectorVertices = null; |
999 |
LMConnector _BranchTargetConnector = null; |
1000 |
PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
1001 |
|
1002 |
// 같은 Line Run의 Connector 찾기 |
1003 |
foreach (var item in connectorVertices) |
1004 |
{ |
1005 |
if (item.Key == _Connector) |
1006 |
continue; |
1007 |
|
1008 |
if (IsStart && |
1009 |
!DBNull.Value.Equals(item.Key.ConnectItem1SymbolID) && |
1010 |
!DBNull.Value.Equals(_Connector.ConnectItem2SymbolID)&& |
1011 |
item.Key.ConnectItem1SymbolID == _Connector.ConnectItem2SymbolID) |
1012 |
{ |
1013 |
_SameRunTargetConnector = item.Key; |
1014 |
break; |
1015 |
} |
1016 |
else if (!IsStart && |
1017 |
!DBNull.Value.Equals(item.Key.ConnectItem2SymbolID) && |
1018 |
!DBNull.Value.Equals(_Connector.ConnectItem1SymbolID) && |
1019 |
item.Key.ConnectItem2SymbolID == _Connector.ConnectItem1SymbolID) |
1020 |
{ |
1021 |
_SameRunTargetConnector = item.Key; |
1022 |
break; |
1023 |
} |
1024 |
} |
1025 |
|
1026 |
// Branch 반대편이 Symbol |
1027 |
if (_SameRunTargetConnector == null) |
1028 |
{ |
1029 |
foreach (var line in lines) |
1030 |
{ |
1031 |
foreach (var connector in line.CONNECTORS) |
1032 |
{ |
1033 |
Symbol symbol = SPPIDUtil.FindObjectByUID(document, connector.CONNECTEDITEM) as Symbol; |
1034 |
if (symbol != null) |
1035 |
{ |
1036 |
_SameRunTargetSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
1037 |
break; |
1038 |
} |
1039 |
} |
1040 |
} |
1041 |
} |
1042 |
|
1043 |
// 기존 Connector 제거 |
1044 |
_placement.PIDRemovePlacement(_Connector.AsLMRepresentation()); |
1045 |
|
1046 |
// 시작 Connector일 경우 첫 Point가 TargetConnector를 찾아야함 |
1047 |
if (IsStart) |
1048 |
{ |
1049 |
branchConnectorVertices = GetPipeRunVertices(branch.Item2.SPPID.ModelItemId); |
1050 |
_BranchTargetConnector = FindTargetLMConnector(branchConnectorVertices, points[0][0], points[0][1], points[1][0], points[1][1]); |
1051 |
} |
1052 |
// 끝 Conenctor일 경우 마지막 Point가 TargetConnector를 찾아야함 |
1053 |
else |
1054 |
{ |
1055 |
branchConnectorVertices = GetPipeRunVertices(branch.Item3.SPPID.ModelItemId); |
1056 |
_BranchTargetConnector = FindTargetLMConnector(branchConnectorVertices, |
1057 |
points[points.Count - 1][0], |
1058 |
points[points.Count - 1][1], |
1059 |
points[points.Count - 2][0], |
1060 |
points[points.Count - 2][1]); |
1061 |
} |
1062 |
|
1063 |
for (int i = 0; i < points.Count; i++) |
1064 |
{ |
1065 |
double[] point = points[i]; |
1066 |
if (i == 0) |
1067 |
{ |
1068 |
if (IsStart) |
1069 |
{ |
1070 |
placeRunInputs.AddConnectorTarget(_BranchTargetConnector, point[0], point[1]); |
1071 |
} |
1072 |
else |
1073 |
{ |
1074 |
if (_SameRunTargetConnector != null) |
1075 |
placeRunInputs.AddConnectorTarget(_SameRunTargetConnector, point[0], point[1]); |
1076 |
else if (_SameRunTargetSymbol != null) |
1077 |
placeRunInputs.AddSymbolTarget(_SameRunTargetSymbol, point[0], point[1]); |
1078 |
else |
1079 |
placeRunInputs.AddPoint(point[0], point[1]); |
1080 |
} |
1081 |
} |
1082 |
else if (i == points.Count - 1) |
1083 |
{ |
1084 |
if (IsStart) |
1085 |
{ |
1086 |
if (_SameRunTargetConnector != null) |
1087 |
placeRunInputs.AddConnectorTarget(_SameRunTargetConnector, point[0], point[1]); |
1088 |
else if (_SameRunTargetSymbol != null) |
1089 |
placeRunInputs.AddSymbolTarget(_SameRunTargetSymbol, point[0], point[1]); |
1090 |
else |
1091 |
placeRunInputs.AddPoint(point[0], point[1]); |
1092 |
} |
1093 |
else |
1094 |
{ |
1095 |
if (_BranchTargetConnector != null) |
1096 |
{ |
1097 |
placeRunInputs.AddConnectorTarget(_BranchTargetConnector, point[0], point[1]); |
1098 |
} |
1099 |
} |
1100 |
} |
1101 |
else |
1102 |
placeRunInputs.AddPoint(point[0], point[1]); |
1103 |
} |
1104 |
_LMAItem _LMAItem = _placement.PIDCreateItem(lines[0].SPPID.MAPPINGNAME); |
1105 |
LMConnector _LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
1106 |
|
1107 |
if (_LMConnector != null) |
1108 |
{ |
1109 |
if (_SameRunTargetConnector != null) |
1110 |
{ |
1111 |
JoinPipeRun(_LMConnector.ModelItemID, _SameRunTargetConnector.ModelItemID); |
1112 |
} |
1113 |
else |
1114 |
{ |
1115 |
foreach (var item in lines) |
1116 |
item.SPPID.ModelItemId = _LMConnector.ModelItemID; |
1117 |
} |
1118 |
|
1119 |
_LMConnector.Commit(); |
1120 |
ReleaseCOMObjects(_LMConnector); |
1121 |
} |
1122 |
|
1123 |
ReleaseCOMObjects(placeRunInputs); |
1124 |
ReleaseCOMObjects(_LMAItem); |
1125 |
if (_BranchTargetConnector != null) |
1126 |
ReleaseCOMObjects(_BranchTargetConnector); |
1127 |
if (_SameRunTargetConnector != null) |
1128 |
ReleaseCOMObjects(_SameRunTargetConnector); |
1129 |
if (_SameRunTargetSymbol != null) |
1130 |
ReleaseCOMObjects(_SameRunTargetSymbol); |
1131 |
foreach (var item in connectorVertices) |
1132 |
ReleaseCOMObjects(item.Key); |
1133 |
foreach (var item in branchConnectorVertices) |
1134 |
ReleaseCOMObjects(item.Key); |
1135 |
} |
1136 |
|
1137 |
/// <summary> |
1138 |
/// EndBreak 모델링 메서드 |
1139 |
/// </summary> |
1140 |
/// <param name="endBreak"></param> |
1141 |
private void EndBreakModeling(EndBreak endBreak) |
1142 |
{ |
1143 |
object ownerObj = SPPIDUtil.FindObjectByUID(document, endBreak.OWNER); |
1144 |
LMConnector targetLMConnector = null; |
1145 |
if (ownerObj !=null && ownerObj.GetType() == typeof(Line)) |
1146 |
{ |
1147 |
Line ownerLine = ownerObj as Line; |
1148 |
LMLabelPersist _LmLabelPersist = null; |
1149 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(ownerLine.SPPID.ModelItemId); |
1150 |
|
1151 |
targetLMConnector = FindTargetLMConnectorByPoint(connectorVertices, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y); |
1152 |
|
1153 |
if (targetLMConnector != null) |
1154 |
{ |
1155 |
Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
1156 |
_LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
1157 |
} |
1158 |
|
1159 |
if (_LmLabelPersist != null) |
1160 |
{ |
1161 |
_LmLabelPersist.Commit(); |
1162 |
ReleaseCOMObjects(_LmLabelPersist); |
1163 |
} |
1164 |
else |
1165 |
RetryEndBreakModeling(endBreak, targetLMConnector); |
1166 |
|
1167 |
foreach (var item in connectorVertices) |
1168 |
ReleaseCOMObjects(item.Key); |
1169 |
|
1170 |
} |
1171 |
else if (ownerObj != null && ownerObj.GetType() == typeof(Symbol)) |
1172 |
{ |
1173 |
Symbol ownerSymbol = ownerObj as Symbol; |
1174 |
LMSymbol _LMSymbol = dataSource.GetSymbol(ownerSymbol.SPPID.RepresentationId); |
1175 |
|
1176 |
targetLMConnector = null; |
1177 |
double distance = double.MaxValue; |
1178 |
|
1179 |
foreach (LMConnector connector in _LMSymbol.Avoid1Connectors) |
1180 |
{ |
1181 |
if (connector.get_ItemStatus() == "Active") |
1182 |
{ |
1183 |
dynamic OID = connector.get_GraphicOID(); |
1184 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
1185 |
Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
1186 |
int verticesCount = lineStringGeometry.VertexCount; |
1187 |
double[] vertices = null; |
1188 |
lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
1189 |
for (int i = 0; i < verticesCount; i++) |
1190 |
{ |
1191 |
double x = 0; |
1192 |
double y = 0; |
1193 |
lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
1194 |
|
1195 |
double result = SPPIDUtil.CalcPointToPointdDistance(x, y, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y); |
1196 |
if (result < distance) |
1197 |
{ |
1198 |
targetLMConnector = connector; |
1199 |
distance = result; |
1200 |
} |
1201 |
} |
1202 |
} |
1203 |
} |
1204 |
|
1205 |
foreach (LMConnector connector in _LMSymbol.Avoid2Connectors) |
1206 |
{ |
1207 |
if (connector.get_ItemStatus() == "Active") |
1208 |
{ |
1209 |
dynamic OID = connector.get_GraphicOID(); |
1210 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
1211 |
Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
1212 |
int verticesCount = lineStringGeometry.VertexCount; |
1213 |
double[] vertices = null; |
1214 |
lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
1215 |
for (int i = 0; i < verticesCount; i++) |
1216 |
{ |
1217 |
double x = 0; |
1218 |
double y = 0; |
1219 |
lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
1220 |
|
1221 |
double result = SPPIDUtil.CalcPointToPointdDistance(x, y, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y); |
1222 |
if (result < distance) |
1223 |
{ |
1224 |
targetLMConnector = connector; |
1225 |
distance = result; |
1226 |
} |
1227 |
} |
1228 |
} |
1229 |
} |
1230 |
|
1231 |
if (targetLMConnector != null) |
1232 |
{ |
1233 |
LMLabelPersist _LmLabelPersist = null; |
1234 |
Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
1235 |
_LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
1236 |
if (_LmLabelPersist != null) |
1237 |
{ |
1238 |
_LmLabelPersist.Commit(); |
1239 |
ReleaseCOMObjects(_LmLabelPersist); |
1240 |
} |
1241 |
else |
1242 |
RetryEndBreakModeling(endBreak, targetLMConnector); |
1243 |
} |
1244 |
|
1245 |
ReleaseCOMObjects(_LMSymbol); |
1246 |
} |
1247 |
|
1248 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
1249 |
} |
1250 |
|
1251 |
/// <summary> |
1252 |
/// EndBreak 모델링이 실패시 다시 시도하는 메서드 |
1253 |
/// </summary> |
1254 |
/// <param name="endBreak"></param> |
1255 |
/// <param name="targetLMConnector"></param> |
1256 |
private void RetryEndBreakModeling(EndBreak endBreak, LMConnector targetLMConnector) |
1257 |
{ |
1258 |
bool isZeroLength = Convert.ToBoolean(targetLMConnector.get_IsZeroLength()); |
1259 |
Array array = null; |
1260 |
LMLabelPersist _LMLabelPersist = null; |
1261 |
LMConnector _LMConnector = null; |
1262 |
dynamic OID = targetLMConnector.get_GraphicOID(); |
1263 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
1264 |
Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
1265 |
int verticesCount = lineStringGeometry.VertexCount; |
1266 |
PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
1267 |
_LMAItem _LMAItem = _placement.PIDCreateItem(@"\Piping\Routing\Process Lines\Primary Piping.sym"); |
1268 |
|
1269 |
if (isZeroLength) |
1270 |
{ |
1271 |
double[] vertices = null; |
1272 |
lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
1273 |
double x = 0; |
1274 |
double y = 0; |
1275 |
lineStringGeometry.GetVertex(1, ref x, ref y); |
1276 |
|
1277 |
placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem1SymbolObject, x, y); |
1278 |
placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem2SymbolObject, x, y); |
1279 |
|
1280 |
_placement.PIDRemovePlacement(targetLMConnector.AsLMRepresentation()); |
1281 |
_LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
1282 |
|
1283 |
array = new double[] { 0, x, y }; |
1284 |
_LMLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: _LMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
1285 |
|
1286 |
AutoJoinPipeRun(_LMConnector.ModelItemID); |
1287 |
} |
1288 |
else |
1289 |
{ |
1290 |
List<double[]> vertices = new List<double[]>(); |
1291 |
for (int i = 1; i <= verticesCount; i++) |
1292 |
{ |
1293 |
double x = 0; |
1294 |
double y = 0; |
1295 |
lineStringGeometry.GetVertex(i, ref x, ref y); |
1296 |
vertices.Add(new double[] { x, y }); |
1297 |
} |
1298 |
|
1299 |
for (int i = 0; i < vertices.Count; i++) |
1300 |
{ |
1301 |
double[] points = vertices[i]; |
1302 |
if (i == 0) |
1303 |
{ |
1304 |
if (targetLMConnector.ConnectItem1SymbolObject != null) |
1305 |
placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem1SymbolObject, points[0], points[1]); |
1306 |
else |
1307 |
placeRunInputs.AddPoint(points[0], points[1]); |
1308 |
} |
1309 |
else if (i == vertices.Count - 1) |
1310 |
{ |
1311 |
if (targetLMConnector.ConnectItem2SymbolObject != null) |
1312 |
placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem2SymbolObject, points[0], points[1]); |
1313 |
else |
1314 |
placeRunInputs.AddPoint(points[0], points[1]); |
1315 |
} |
1316 |
else |
1317 |
placeRunInputs.AddPoint(points[0], points[1]); |
1318 |
} |
1319 |
|
1320 |
List<Line> lines = SPPIDUtil.FindLinesByModelId(document, targetLMConnector.ModelItemID); |
1321 |
|
1322 |
_placement.PIDRemovePlacement(targetLMConnector.AsLMRepresentation()); |
1323 |
_LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
1324 |
|
1325 |
array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
1326 |
_LMLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: _LMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
1327 |
|
1328 |
AutoJoinPipeRun(_LMConnector.ModelItemID); |
1329 |
foreach (var line in lines) |
1330 |
line.SPPID.ModelItemId = _LMConnector.ModelItemID; |
1331 |
} |
1332 |
|
1333 |
|
1334 |
if (_LMLabelPersist != null) |
1335 |
{ |
1336 |
_LMLabelPersist.Commit(); |
1337 |
ReleaseCOMObjects(_LMLabelPersist); |
1338 |
} |
1339 |
else |
1340 |
{ |
1341 |
|
1342 |
} |
1343 |
|
1344 |
ReleaseCOMObjects(_LMConnector); |
1345 |
ReleaseCOMObjects(placeRunInputs); |
1346 |
ReleaseCOMObjects(_LMAItem); |
1347 |
} |
1348 |
|
1349 |
/// <summary> |
1350 |
/// FromModelItem을 ToModelItem으로 PipeRunJoin하는 메서드 |
1351 |
/// </summary> |
1352 |
/// <param name="fromModelItemId"></param> |
1353 |
/// <param name="toModelItemId"></param> |
1354 |
private void JoinPipeRun(string fromModelItemId, string toModelItemId) |
1355 |
{ |
1356 |
LMModelItem modelItem1 = dataSource.GetModelItem(toModelItemId); |
1357 |
_LMAItem item1 = modelItem1.AsLMAItem(); |
1358 |
LMModelItem modelItem2 = dataSource.GetModelItem(fromModelItemId); |
1359 |
_LMAItem item2 = modelItem2.AsLMAItem(); |
1360 |
|
1361 |
// item2가 item1으로 조인 |
1362 |
try |
1363 |
{ |
1364 |
_placement.PIDJoinRuns(ref item1, ref item2); |
1365 |
item1.Commit(); |
1366 |
item2.Commit(); |
1367 |
|
1368 |
List<Line> lines = SPPIDUtil.FindLinesByModelId(document, fromModelItemId); |
1369 |
foreach (var line in lines) |
1370 |
line.SPPID.ModelItemId = toModelItemId; |
1371 |
} |
1372 |
catch (Exception ex) |
1373 |
{ |
1374 |
System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
1375 |
} |
1376 |
finally |
1377 |
{ |
1378 |
ReleaseCOMObjects(modelItem1); |
1379 |
ReleaseCOMObjects(item1); |
1380 |
ReleaseCOMObjects(modelItem2); |
1381 |
ReleaseCOMObjects(item2); |
1382 |
} |
1383 |
} |
1384 |
|
1385 |
/// <summary> |
1386 |
/// PipeRun을 자동으로 Join하는 메서드 |
1387 |
/// </summary> |
1388 |
/// <param name="modelItemId"></param> |
1389 |
private void AutoJoinPipeRun(string modelItemId) |
1390 |
{ |
1391 |
LMModelItem modelItem = dataSource.GetModelItem(modelItemId); |
1392 |
_LMAItem item = modelItem.AsLMAItem(); |
1393 |
try |
1394 |
{ |
1395 |
string modelitemID = item.Id; |
1396 |
_placement.PIDAutoJoin(item, AutoJoinEndConstants.autoJoin_Both, ref item); |
1397 |
string afterModelItemID = item.Id; |
1398 |
|
1399 |
if (modelitemID != afterModelItemID) |
1400 |
{ |
1401 |
List<Line> lines = SPPIDUtil.FindLinesByModelId(document, modelitemID); |
1402 |
foreach (var line in lines) |
1403 |
line.SPPID.ModelItemId = afterModelItemID; |
1404 |
} |
1405 |
item.Commit(); |
1406 |
} |
1407 |
catch (Exception ex) |
1408 |
{ |
1409 |
System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
1410 |
} |
1411 |
finally |
1412 |
{ |
1413 |
ReleaseCOMObjects(modelItem); |
1414 |
ReleaseCOMObjects(item); |
1415 |
} |
1416 |
} |
1417 |
|
1418 |
/// <summary> |
1419 |
/// LineRun에 있는 Line들을 Join하는 진입 메서드 |
1420 |
/// </summary> |
1421 |
/// <param name="run"></param> |
1422 |
private void JoinRunLine(LineRun run) |
1423 |
{ |
1424 |
string modelItemId = string.Empty; |
1425 |
foreach (var item in run.RUNITEMS) |
1426 |
{ |
1427 |
if (item.GetType() == typeof(Line)) |
1428 |
{ |
1429 |
Line line = item as Line; |
1430 |
AutoJoinPipeRun(line.SPPID.ModelItemId); |
1431 |
modelItemId = line.SPPID.ModelItemId; |
1432 |
|
1433 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
1434 |
} |
1435 |
} |
1436 |
} |
1437 |
|
1438 |
/// <summary> |
1439 |
/// PipeRun의 좌표를 가져오는 메서드 |
1440 |
/// </summary> |
1441 |
/// <param name="modelId"></param> |
1442 |
/// <returns></returns> |
1443 |
private Dictionary<LMConnector, List<double[]>> GetPipeRunVertices(string modelId) |
1444 |
{ |
1445 |
Dictionary<LMConnector, List<double[]>> connectorVertices = new Dictionary<LMConnector, List<double[]>>(); |
1446 |
LMModelItem modelItem = dataSource.GetModelItem(modelId); |
1447 |
|
1448 |
if (modelItem != null) |
1449 |
{ |
1450 |
foreach (LMRepresentation rep in modelItem.Representations) |
1451 |
{ |
1452 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
1453 |
{ |
1454 |
LMConnector _LMConnector = dataSource.GetConnector(rep.Id); |
1455 |
connectorVertices.Add(_LMConnector, new List<double[]>()); |
1456 |
dynamic OID = rep.get_GraphicOID(); |
1457 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
1458 |
Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
1459 |
int verticesCount = lineStringGeometry.VertexCount; |
1460 |
double[] vertices = null; |
1461 |
lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
1462 |
for (int i = 0; i < verticesCount; i++) |
1463 |
{ |
1464 |
double x = 0; |
1465 |
double y = 0; |
1466 |
lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
1467 |
connectorVertices[_LMConnector].Add(new double[] { Math.Round(x, 10), Math.Round(y, 10) }); |
1468 |
} |
1469 |
} |
1470 |
} |
1471 |
|
1472 |
ReleaseCOMObjects(modelItem); |
1473 |
} |
1474 |
|
1475 |
return connectorVertices; |
1476 |
} |
1477 |
|
1478 |
/// <summary> |
1479 |
/// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 두점으로 라인의 교차점을 기준으로 구함 |
1480 |
/// </summary> |
1481 |
/// <param name="connectorVertices"></param> |
1482 |
/// <param name="connX"></param> |
1483 |
/// <param name="connY"></param> |
1484 |
/// <param name="x2"></param> |
1485 |
/// <param name="y2"></param> |
1486 |
/// <returns></returns> |
1487 |
private LMConnector FindTargetLMConnector(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY, double x2, double y2) |
1488 |
{ |
1489 |
double length = double.MaxValue; |
1490 |
LMConnector targetConnector = null; |
1491 |
foreach (var item in connectorVertices) |
1492 |
{ |
1493 |
List<double[]> points = item.Value; |
1494 |
for (int i = 0; i < points.Count - 1; i++) |
1495 |
{ |
1496 |
double[] point1 = points[i]; |
1497 |
double[] point2 = points[i + 1]; |
1498 |
|
1499 |
double maxLineX = Math.Max(point1[0], point2[0]); |
1500 |
double minLineX = Math.Min(point1[0], point2[0]); |
1501 |
double maxLineY = Math.Max(point1[1], point2[1]); |
1502 |
double minLineY = Math.Min(point1[1], point2[1]); |
1503 |
|
1504 |
SlopeType slope = SPPIDUtil.CalcSlope(minLineX, minLineY, maxLineX, maxLineY); |
1505 |
|
1506 |
// 두직선의 교차점 |
1507 |
double[] crossingPoint = SPPIDUtil.CalcLineCrossingPoint(connX, connY, x2, y2, point1[0], point1[1], point2[0], point2[1]); |
1508 |
if (crossingPoint != null) |
1509 |
{ |
1510 |
double distance = SPPIDUtil.CalcPointToPointdDistance(connX, connY, crossingPoint[0], crossingPoint[1]); |
1511 |
if (length >= distance) |
1512 |
{ |
1513 |
if (slope == SlopeType.Slope && |
1514 |
minLineX <= crossingPoint[0] && maxLineX >= crossingPoint[0] && |
1515 |
minLineY <= crossingPoint[1] && maxLineY >= crossingPoint[1]) |
1516 |
{ |
1517 |
targetConnector = item.Key; |
1518 |
length = distance; |
1519 |
} |
1520 |
else if (slope == SlopeType.HORIZONTAL && |
1521 |
minLineX <= crossingPoint[0] && maxLineX >= crossingPoint[0]) |
1522 |
{ |
1523 |
targetConnector = item.Key; |
1524 |
length = distance; |
1525 |
} |
1526 |
else if (slope == SlopeType.VERTICAL && |
1527 |
minLineY <= crossingPoint[1] && maxLineY >= crossingPoint[1]) |
1528 |
{ |
1529 |
targetConnector = item.Key; |
1530 |
length = distance; |
1531 |
} |
1532 |
} |
1533 |
} |
1534 |
} |
1535 |
|
1536 |
|
1537 |
} |
1538 |
|
1539 |
if (targetConnector == null) |
1540 |
{ |
1541 |
foreach (var item in connectorVertices) |
1542 |
{ |
1543 |
List<double[]> points = item.Value; |
1544 |
foreach (var point in points) |
1545 |
{ |
1546 |
double distance = SPPIDUtil.CalcPointToPointdDistance(connX, connY, point[0], point[1]); |
1547 |
if (length >= distance) |
1548 |
{ |
1549 |
targetConnector = item.Key; |
1550 |
length = distance; |
1551 |
} |
1552 |
} |
1553 |
} |
1554 |
|
1555 |
} |
1556 |
|
1557 |
return targetConnector; |
1558 |
} |
1559 |
|
1560 |
/// <summary> |
1561 |
/// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 한점으로 제일 가까운 기준으로 구함(단순) |
1562 |
/// </summary> |
1563 |
/// <param name="connectorVertices"></param> |
1564 |
/// <param name="connX"></param> |
1565 |
/// <param name="connY"></param> |
1566 |
/// <returns></returns> |
1567 |
private LMConnector FindTargetLMConnectorByPoint(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY) |
1568 |
{ |
1569 |
double length = double.MaxValue; |
1570 |
LMConnector targetConnector = null; |
1571 |
foreach (var item in connectorVertices) |
1572 |
{ |
1573 |
List<double[]> points = item.Value; |
1574 |
|
1575 |
foreach (double[] point in points) |
1576 |
{ |
1577 |
double distance = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], connX, connY); |
1578 |
if (length >= distance) |
1579 |
{ |
1580 |
targetConnector = item.Key; |
1581 |
length = distance; |
1582 |
} |
1583 |
} |
1584 |
} |
1585 |
|
1586 |
return targetConnector; |
1587 |
} |
1588 |
|
1589 |
/// <summary> |
1590 |
/// 좌표로 PipeRun의 Connector중에 어느 Connector에 가까운지/붙을지 가져오는 메서드 - 조건에 안맞아서 못찾을시 제일 가까운 점으로 가져오는 방식 |
1591 |
/// </summary> |
1592 |
/// <param name="connectorVertices"></param> |
1593 |
/// <param name="connX"></param> |
1594 |
/// <param name="connY"></param> |
1595 |
/// <returns></returns> |
1596 |
private LMConnector FindTargetLMConnectorForLabel(Dictionary<LMConnector, List<double[]>> connectorVertices, double connX, double connY) |
1597 |
{ |
1598 |
double length = double.MaxValue; |
1599 |
LMConnector targetConnector = null; |
1600 |
foreach (var item in connectorVertices) |
1601 |
{ |
1602 |
List<double[]> points = item.Value; |
1603 |
for (int i = 0; i < points.Count - 1; i++) |
1604 |
{ |
1605 |
double[] point1 = points[i]; |
1606 |
double[] point2 = points[i + 1]; |
1607 |
double x1 = Math.Min(point1[0], point2[0]); |
1608 |
double y1 = Math.Min(point1[1], point2[1]); |
1609 |
double x2 = Math.Max(point1[0], point2[0]); |
1610 |
double y2 = Math.Max(point1[1], point2[1]); |
1611 |
|
1612 |
if ((x1 <= connX && x2 >= connX) || |
1613 |
(y1 <= connY && y2 >= connY)) |
1614 |
{ |
1615 |
double distance = SPPIDUtil.CalcPointToPointdDistance(point1[0], point1[1], connX, connY); |
1616 |
if (length >= distance) |
1617 |
{ |
1618 |
targetConnector = item.Key; |
1619 |
length = distance; |
1620 |
} |
1621 |
|
1622 |
distance = SPPIDUtil.CalcPointToPointdDistance(point2[0], point2[1], connX, connY); |
1623 |
if (length >= distance) |
1624 |
{ |
1625 |
targetConnector = item.Key; |
1626 |
length = distance; |
1627 |
} |
1628 |
} |
1629 |
} |
1630 |
} |
1631 |
|
1632 |
// 못찾았을때. |
1633 |
length = double.MaxValue; |
1634 |
if (targetConnector == null) |
1635 |
{ |
1636 |
foreach (var item in connectorVertices) |
1637 |
{ |
1638 |
List<double[]> points = item.Value; |
1639 |
|
1640 |
foreach (double[] point in points) |
1641 |
{ |
1642 |
double distance = SPPIDUtil.CalcPointToPointdDistance(point[0], point[1], connX, connY); |
1643 |
if (length >= distance) |
1644 |
{ |
1645 |
targetConnector = item.Key; |
1646 |
length = distance; |
1647 |
} |
1648 |
} |
1649 |
} |
1650 |
} |
1651 |
|
1652 |
return targetConnector; |
1653 |
} |
1654 |
|
1655 |
/// <summary> |
1656 |
/// Line Number Symbol을 실제로 Modeling하는 메서드 |
1657 |
/// </summary> |
1658 |
/// <param name="lineNumber"></param> |
1659 |
private void LineNumberModeling(LineNumber lineNumber) |
1660 |
{ |
1661 |
Line line = SPPIDUtil.FindObjectByUID(document, lineNumber.CONNLINE) as Line; |
1662 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(line.SPPID.ModelItemId); |
1663 |
LMConnector connectedLMConnector = FindTargetLMConnectorForLabel(connectorVertices, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y); |
1664 |
if (connectedLMConnector != null) |
1665 |
{ |
1666 |
double x = 0; |
1667 |
double y = 0; |
1668 |
CalcLabelLocation(ref x, ref y, lineNumber.SPPID.ORIGINAL_X, lineNumber.SPPID.ORIGINAL_Y, lineNumber.SPPIDLabelLocation, _ETCSetting.LineNumberLocation); |
1669 |
|
1670 |
Array points = new double[] { 0, x, y }; |
1671 |
LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(lineNumber.SPPID.MAPPINGNAME, ref points, Rotation: lineNumber.ANGLE, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: false); |
1672 |
|
1673 |
foreach (var item in connectorVertices) |
1674 |
ReleaseCOMObjects(item.Key); |
1675 |
if (_LmLabelPresist != null) |
1676 |
{ |
1677 |
_LmLabelPresist.Commit(); |
1678 |
lineNumber.SPPID.RepresentationId = _LmLabelPresist.AsLMRepresentation().Id; |
1679 |
ReleaseCOMObjects(_LmLabelPresist); |
1680 |
} |
1681 |
else |
1682 |
{ |
1683 |
|
1684 |
} |
1685 |
} |
1686 |
|
1687 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
1688 |
} |
1689 |
|
1690 |
/// <summary> |
1691 |
/// Line Number 기준으로 모든 Item에 Line Number의 Attribute Input |
1692 |
/// </summary> |
1693 |
/// <param name="lineNumber"></param> |
1694 |
private void InputLineNumberAttribute(LineNumber lineNumber) |
1695 |
{ |
1696 |
foreach (LineRun run in lineNumber.RUNS) |
1697 |
{ |
1698 |
foreach (var item in run.RUNITEMS) |
1699 |
{ |
1700 |
if (item.GetType() == typeof(Symbol)) |
1701 |
{ |
1702 |
Symbol symbol = item as Symbol; |
1703 |
LMSymbol _LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
1704 |
LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
1705 |
|
1706 |
if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
1707 |
{ |
1708 |
foreach (var attribute in lineNumber.ATTRIBUTES) |
1709 |
{ |
1710 |
LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID); |
1711 |
if (mapping != null) |
1712 |
{ |
1713 |
LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME]; |
1714 |
if (_LMAAttribute != null) |
1715 |
{ |
1716 |
if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
1717 |
_LMAAttribute.set_Value(attribute.VALUE); |
1718 |
else if (_LMAAttribute.get_Value() != attribute.VALUE) |
1719 |
_LMAAttribute.set_Value(attribute.VALUE); |
1720 |
} |
1721 |
} |
1722 |
} |
1723 |
_LMModelItem.Commit(); |
1724 |
} |
1725 |
if (_LMModelItem != null) |
1726 |
ReleaseCOMObjects(_LMModelItem); |
1727 |
if (_LMSymbol != null) |
1728 |
ReleaseCOMObjects(_LMSymbol); |
1729 |
} |
1730 |
else if (item.GetType() == typeof(Line)) |
1731 |
{ |
1732 |
Line line = item as Line; |
1733 |
if (line != null) |
1734 |
{ |
1735 |
LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
1736 |
if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
1737 |
{ |
1738 |
foreach (var attribute in lineNumber.ATTRIBUTES) |
1739 |
{ |
1740 |
LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID); |
1741 |
if (mapping != null) |
1742 |
{ |
1743 |
LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME]; |
1744 |
if (_LMAAttribute != null) |
1745 |
{ |
1746 |
if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
1747 |
_LMAAttribute.set_Value(attribute.VALUE); |
1748 |
else if (_LMAAttribute.get_Value() != attribute.VALUE) |
1749 |
_LMAAttribute.set_Value(attribute.VALUE); |
1750 |
|
1751 |
} |
1752 |
} |
1753 |
} |
1754 |
_LMModelItem.Commit(); |
1755 |
} |
1756 |
if (_LMModelItem != null) |
1757 |
ReleaseCOMObjects(_LMModelItem); |
1758 |
} |
1759 |
} |
1760 |
} |
1761 |
} |
1762 |
|
1763 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
1764 |
} |
1765 |
|
1766 |
/// <summary> |
1767 |
/// Symbol Attribute 입력 메서드 |
1768 |
/// </summary> |
1769 |
/// <param name="item"></param> |
1770 |
private void InputSymbolAttribute(object targetItem, List<BaseModel.Attribute> targetAttributes) |
1771 |
{ |
1772 |
try |
1773 |
{ |
1774 |
// Object 아이템이 Symbol일 경우 Equipment일 경우 |
1775 |
string sRep = null; |
1776 |
if (targetItem.GetType() == typeof(Symbol)) |
1777 |
sRep = ((Symbol)targetItem).SPPID.RepresentationId; |
1778 |
else if (targetItem.GetType() == typeof(Equipment)) |
1779 |
sRep = ((Equipment)targetItem).SPPID.RepresentationId; |
1780 |
|
1781 |
if (!string.IsNullOrEmpty(sRep)) |
1782 |
{ |
1783 |
LMSymbol _LMSymbol = dataSource.GetSymbol(sRep); |
1784 |
LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
1785 |
LMAAttributes _Attributes = _LMModelItem.Attributes; |
1786 |
|
1787 |
foreach (var item in targetAttributes) |
1788 |
{ |
1789 |
AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == item.UID); |
1790 |
if (mapping != null && !string.IsNullOrEmpty(item.VALUE) && item.VALUE != "None") |
1791 |
{ |
1792 |
LMAAttribute _Attribute = _Attributes[mapping.SPPIDATTRIBUTENAME]; |
1793 |
if (_Attribute != null) |
1794 |
_Attribute.set_Value(item.VALUE); |
1795 |
} |
1796 |
} |
1797 |
_LMModelItem.Commit(); |
1798 |
|
1799 |
ReleaseCOMObjects(_Attributes); |
1800 |
ReleaseCOMObjects(_LMModelItem); |
1801 |
ReleaseCOMObjects(_LMSymbol); |
1802 |
} |
1803 |
} |
1804 |
catch (Exception ex) |
1805 |
{ |
1806 |
System.Windows.Forms.MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace); |
1807 |
} |
1808 |
|
1809 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
1810 |
} |
1811 |
|
1812 |
/// <summary> |
1813 |
/// Text Modeling - Association일 경우는 Text대신 해당 맵핑된 Symbol로 모델링 |
1814 |
/// </summary> |
1815 |
/// <param name="text"></param> |
1816 |
private void TextModeling(Text text) |
1817 |
{ |
1818 |
LMSymbol _LMSymbol = null; |
1819 |
try |
1820 |
{ |
1821 |
//if (text.ASSOCIATION && !string.IsNullOrEmpty(text.OWNER) && text.OWNER != "None") |
1822 |
if (text.ASSOCIATION) |
1823 |
{ |
1824 |
object owner = SPPIDUtil.FindObjectByUID(document, text.OWNER); |
1825 |
if (owner.GetType() == typeof(Symbol)) |
1826 |
{ |
1827 |
Symbol symbol = owner as Symbol; |
1828 |
_LMSymbol = dataSource.GetSymbol(symbol.SPPID.RepresentationId); |
1829 |
if (_LMSymbol != null) |
1830 |
{ |
1831 |
Association association = symbol.ASSOCIATIONS.Find(x => x.VALUE == text.UID); |
1832 |
List<BaseModel.Attribute> attributes = symbol.ATTRIBUTES.FindAll(x => x.ATTRIBUTETYPE == association.TYPE); |
1833 |
AttributeMapping mapping = null; |
1834 |
foreach (var attribute in attributes) |
1835 |
{ |
1836 |
if (string.IsNullOrEmpty(attribute.VALUE) || attribute.VALUE == "None") |
1837 |
continue; |
1838 |
|
1839 |
mapping = document.AttributeMappings.Find(x => x.UID == attribute.UID && !string.IsNullOrEmpty(x.SPPIDSYMBOLNAME)); |
1840 |
if (mapping != null) |
1841 |
break; |
1842 |
} |
1843 |
|
1844 |
if (mapping != null) |
1845 |
{ |
1846 |
double x = 0; |
1847 |
double y = 0; |
1848 |
|
1849 |
CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, mapping.Location); |
1850 |
Array array = new double[] { 0, x, y }; |
1851 |
|
1852 |
LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mapping.SPPIDSYMBOLNAME, ref array, Rotation: text.ANGLE, LabeledItem: _LMSymbol.AsLMRepresentation(), IsLeaderVisible: mapping.LeaderLine); |
1853 |
if (_LMLabelPersist!=null) |
1854 |
{ |
1855 |
_LMLabelPersist.Commit(); |
1856 |
ReleaseCOMObjects(_LMLabelPersist); |
1857 |
} |
1858 |
} |
1859 |
} |
1860 |
} |
1861 |
else if (owner.GetType() == typeof(Line)) |
1862 |
{ |
1863 |
|
1864 |
} |
1865 |
} |
1866 |
else |
1867 |
{ |
1868 |
LMItemNote _LMItemNote = null; |
1869 |
LMAAttribute _LMAAttribute = null; |
1870 |
|
1871 |
double x = 0; |
1872 |
double y = 0; |
1873 |
|
1874 |
CalcLabelLocation(ref x, ref y, text.SPPID.ORIGINAL_X, text.SPPID.ORIGINAL_Y, text.SPPIDLabelLocation, _ETCSetting.TextLocation); |
1875 |
|
1876 |
_LMSymbol = _placement.PIDPlaceSymbol(text.SPPID.MAPPINGNAME, x, y); |
1877 |
_LMSymbol.Commit(); |
1878 |
_LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
1879 |
_LMItemNote.Commit(); |
1880 |
_LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
1881 |
_LMAAttribute.set_Value(text.VALUE); |
1882 |
_LMItemNote.Commit(); |
1883 |
|
1884 |
if (_LMAAttribute != null) |
1885 |
ReleaseCOMObjects(_LMAAttribute); |
1886 |
if (_LMItemNote != null) |
1887 |
ReleaseCOMObjects(_LMItemNote); |
1888 |
} |
1889 |
} |
1890 |
catch (Exception ex) |
1891 |
{ |
1892 |
|
1893 |
} |
1894 |
finally |
1895 |
{ |
1896 |
if (_LMSymbol != null) |
1897 |
ReleaseCOMObjects(_LMSymbol); |
1898 |
} |
1899 |
|
1900 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
1901 |
} |
1902 |
|
1903 |
/// <summary> |
1904 |
/// Note Modeling |
1905 |
/// </summary> |
1906 |
/// <param name="note"></param> |
1907 |
private void NoteModeling(Note note) |
1908 |
{ |
1909 |
LMSymbol _LMSymbol = null; |
1910 |
LMItemNote _LMItemNote = null; |
1911 |
LMAAttribute _LMAAttribute = null; |
1912 |
|
1913 |
try |
1914 |
{ |
1915 |
double x = 0; |
1916 |
double y = 0; |
1917 |
|
1918 |
CalcLabelLocation(ref x, ref y, note.SPPID.ORIGINAL_X, note.SPPID.ORIGINAL_Y, note.SPPIDLabelLocation, _ETCSetting.NoteLocation); |
1919 |
|
1920 |
_LMSymbol = _placement.PIDPlaceSymbol(note.SPPID.MAPPINGNAME, x, y); |
1921 |
_LMSymbol.Commit(); |
1922 |
_LMItemNote = _placement.PIDDataSource.GetItemNote(_LMSymbol.ModelItemID); |
1923 |
_LMItemNote.Commit(); |
1924 |
_LMAAttribute = _LMItemNote.Attributes["Note.Body"]; |
1925 |
_LMAAttribute.set_Value(note.VALUE); |
1926 |
_LMItemNote.Commit(); |
1927 |
} |
1928 |
catch (Exception ex) |
1929 |
{ |
1930 |
|
1931 |
} |
1932 |
finally |
1933 |
{ |
1934 |
if (_LMAAttribute != null) |
1935 |
ReleaseCOMObjects(_LMAAttribute); |
1936 |
if (_LMItemNote != null) |
1937 |
ReleaseCOMObjects(_LMItemNote); |
1938 |
if (_LMSymbol != null) |
1939 |
ReleaseCOMObjects(_LMSymbol); |
1940 |
} |
1941 |
|
1942 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetProgress, ++CurrentCount); |
1943 |
} |
1944 |
|
1945 |
/// <summary> |
1946 |
/// Label의 좌표를 구하는 메서드(ID2 기준의 좌표 -> SPPID 좌표) |
1947 |
/// </summary> |
1948 |
/// <param name="x"></param> |
1949 |
/// <param name="y"></param> |
1950 |
/// <param name="originX"></param> |
1951 |
/// <param name="originY"></param> |
1952 |
/// <param name="SPPIDLabelLocation"></param> |
1953 |
/// <param name="location"></param> |
1954 |
private void CalcLabelLocation(ref double x, ref double y, double originX, double originY, SPPIDLabelLocationInfo SPPIDLabelLocation, Location location) |
1955 |
{ |
1956 |
if (location == Location.None) |
1957 |
{ |
1958 |
x = originX; |
1959 |
y = originY; |
1960 |
} |
1961 |
else |
1962 |
{ |
1963 |
if (location.HasFlag(Location.Center)) |
1964 |
{ |
1965 |
x = (SPPIDLabelLocation.X1 + SPPIDLabelLocation.X2) / 2; |
1966 |
y = (SPPIDLabelLocation.Y1 + SPPIDLabelLocation.Y2) / 2; |
1967 |
} |
1968 |
|
1969 |
if (location.HasFlag(Location.Left)) |
1970 |
x = SPPIDLabelLocation.X1; |
1971 |
else if (location.HasFlag(Location.Right)) |
1972 |
x = SPPIDLabelLocation.X2; |
1973 |
|
1974 |
if (location.HasFlag(Location.Down)) |
1975 |
y = SPPIDLabelLocation.Y1; |
1976 |
else if (location.HasFlag(Location.Up)) |
1977 |
y = SPPIDLabelLocation.Y2; |
1978 |
} |
1979 |
} |
1980 |
|
1981 |
/// <summary> |
1982 |
/// ComObject를 Release |
1983 |
/// </summary> |
1984 |
/// <param name="objVars"></param> |
1985 |
public void ReleaseCOMObjects(params object[] objVars) |
1986 |
{ |
1987 |
int intNewRefCount = 0; |
1988 |
foreach (object obj in objVars) |
1989 |
{ |
1990 |
if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj)) |
1991 |
intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj); |
1992 |
} |
1993 |
} |
1994 |
} |
1995 |
} |