개정판 ca6e0f51
dev issue #000 : 안정화
Change-Id: I0841f03ded95d09a89f5a939aa0a23ec1e78a5bc
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
87 | 87 |
Log.Write("Start Modeling"); |
88 | 88 |
SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true); |
89 | 89 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetParent, (IntPtr)radApp.HWnd); |
90 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStepCount, 15);
|
|
90 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStepCount, 16);
|
|
91 | 91 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, DocumentLabelText); |
92 | 92 |
|
93 | 93 |
// Equipment Modeling |
... | ... | |
106 | 106 |
RunSpecBreakModeling(); |
107 | 107 |
// Join SameConnector |
108 | 108 |
RunJoinRunForSameConnector(); |
109 |
// Join Run |
|
110 |
RunJoinRun(); |
|
109 | 111 |
// Check FlowDirection |
110 | 112 |
RunFlowDirection(); |
111 | 113 |
// Note Modeling |
... | ... | |
123 | 125 |
|
124 | 126 |
// Result Logging |
125 | 127 |
document.CheckModelingResult(); |
126 |
|
|
127 |
|
|
128 |
|
|
128 | 129 |
//// LineRun Line Join |
129 | 130 |
//SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Join LineRuns"); |
130 | 131 |
//foreach (LineNumber lineNumber in document.LINENUMBERS) |
... | ... | |
155 | 156 |
// Log.Write(ex.Message); |
156 | 157 |
// Log.Write(ex.StackTrace); |
157 | 158 |
// } |
159 |
|
|
160 |
|
|
161 |
|
|
162 |
|
|
163 |
|
|
158 | 164 |
} |
159 | 165 |
} |
160 | 166 |
catch (Exception ex) |
... | ... | |
409 | 415 |
private void RunJoinRunForSameConnector() |
410 | 416 |
{ |
411 | 417 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.LINES.Count); |
412 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "PipeRun Join"); |
|
418 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "PipeRun Join - 1");
|
|
413 | 419 |
foreach (var line in document.LINES) |
414 | 420 |
{ |
415 | 421 |
if (!SPPIDUtil.IsSegmentLine(document, line)) |
... | ... | |
418 | 424 |
{ |
419 | 425 |
if (connector.ConnectedObject != null && |
420 | 426 |
connector.ConnectedObject.GetType() == typeof(Line) && |
421 |
!SPPIDUtil.IsBranchLine(line, connector.ConnectedObject as Line))
|
|
427 |
!SPPIDUtil.IsBranchLine(line, connector.ConnectedObject as Line)) |
|
422 | 428 |
{ |
423 | 429 |
Line connLine = connector.ConnectedObject as Line; |
424 | 430 |
if (line.SPPID.ModelItemId != connLine.SPPID.ModelItemId && !string.IsNullOrEmpty(line.SPPID.ModelItemId) && !string.IsNullOrEmpty(connLine.SPPID.ModelItemId)) |
425 |
JoinPipeRun(connLine.SPPID.ModelItemId, line.SPPID.ModelItemId); |
|
431 |
JoinPipeRunForSameConnector(connLine.SPPID.ModelItemId, line.SPPID.ModelItemId);
|
|
426 | 432 |
} |
427 | 433 |
} |
428 | 434 |
} |
429 | 435 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
430 | 436 |
} |
431 | 437 |
} |
438 |
private void RunJoinRun() |
|
439 |
{ |
|
440 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.LINES.Count); |
|
441 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "PipeRun Join - 2"); |
|
442 |
foreach (var line in document.LINES) |
|
443 |
{ |
|
444 |
JoinRun(line); |
|
445 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
|
446 |
} |
|
447 |
} |
|
432 | 448 |
private void RunFlowDirection() |
433 | 449 |
{ |
434 | 450 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, |
... | ... | |
1524 | 1540 |
|
1525 | 1541 |
List<Line> group = new List<Line>(); |
1526 | 1542 |
GetConnectedLineGroup(line, group); |
1543 |
//SortGroupLine(group); |
|
1527 | 1544 |
LineCoordinateCorrection(group); |
1528 | 1545 |
|
1529 | 1546 |
foreach (var groupLine in group) |
... | ... | |
1590 | 1607 |
else if (groupLine.SlopeType == SlopeType.VERTICAL) |
1591 | 1608 |
placeRunInputs.AddPoint(-0.1, y); |
1592 | 1609 |
else |
1593 |
placeRunInputs.AddPoint(x, -0.1); |
|
1610 |
{ |
|
1611 |
if (SPPIDUtil.CalcAngle(groupLine.SPPID.START_X, groupLine.SPPID.START_Y, groupLine.SPPID.END_X, groupLine.SPPID.END_Y) < 45) |
|
1612 |
placeRunInputs.AddPoint(-0.1, y); |
|
1613 |
else |
|
1614 |
placeRunInputs.AddPoint(x, -0.1); |
|
1615 |
} |
|
1594 | 1616 |
} |
1595 | 1617 |
|
1596 | 1618 |
placeRunInputs.AddPoint(x, y); |
... | ... | |
1602 | 1624 |
else if (groupLine.SlopeType == SlopeType.VERTICAL) |
1603 | 1625 |
placeRunInputs.AddPoint(-0.1, y); |
1604 | 1626 |
else |
1605 |
placeRunInputs.AddPoint(x, -0.1); |
|
1627 |
{ |
|
1628 |
if (SPPIDUtil.CalcAngle(groupLine.SPPID.START_X, groupLine.SPPID.START_Y, groupLine.SPPID.END_X, groupLine.SPPID.END_Y) < 45) |
|
1629 |
placeRunInputs.AddPoint(-0.1, y); |
|
1630 |
else |
|
1631 |
placeRunInputs.AddPoint(x, -0.1); |
|
1632 |
} |
|
1633 |
|
|
1606 | 1634 |
} |
1607 | 1635 |
} |
1608 | 1636 |
} |
... | ... | |
1702 | 1730 |
} |
1703 | 1731 |
} |
1704 | 1732 |
|
1733 |
private void SortGroupLine(List<Line> group) |
|
1734 |
{ |
|
1735 |
List<Line> result = new List<Line>(); |
|
1736 |
result.Add(group[0]); |
|
1737 |
|
|
1738 |
group.Clear(); |
|
1739 |
result.AddRange(result); |
|
1740 |
} |
|
1741 |
|
|
1705 | 1742 |
private void LineCoordinateCorrection(List<Line> group) |
1706 | 1743 |
{ |
1707 | 1744 |
// 순서대로 전 Item 기준 정렬 |
... | ... | |
2463 | 2500 |
/// </summary> |
2464 | 2501 |
/// <param name="modelItemID1"></param> |
2465 | 2502 |
/// <param name="modelItemID2"></param> |
2466 |
private void JoinPipeRun(string modelItemID1, string modelItemID2) |
|
2503 |
private void JoinPipeRunForSameConnector(string modelItemID1, string modelItemID2)
|
|
2467 | 2504 |
{ |
2468 |
LMModelItem modelItem1 = dataSource.GetModelItem(modelItemID1); |
|
2469 |
_LMAItem item1 = modelItem1.AsLMAItem(); |
|
2470 |
LMModelItem modelItem2 = dataSource.GetModelItem(modelItemID2); |
|
2471 |
_LMAItem item2 = modelItem2.AsLMAItem(); |
|
2472 |
|
|
2473 |
// item2가 item1으로 조인 |
|
2474 |
_placement.PIDJoinRuns(ref item1, ref item2); |
|
2475 |
item1.Commit(); |
|
2476 |
item2.Commit(); |
|
2477 |
|
|
2478 |
string beforeID = string.Empty; |
|
2479 |
string afterID = string.Empty; |
|
2480 |
|
|
2481 |
if (modelItem1.get_ItemStatus() == "Active" && modelItem2.get_ItemStatus() != "Active") |
|
2482 |
{ |
|
2483 |
beforeID = modelItem2.Id; |
|
2484 |
afterID = modelItem1.Id; |
|
2485 |
} |
|
2486 |
else if (modelItem1.get_ItemStatus() != "Active" && modelItem2.get_ItemStatus() == "Active") |
|
2487 |
{ |
|
2488 |
beforeID = modelItem1.Id; |
|
2489 |
afterID = modelItem2.Id; |
|
2490 |
} |
|
2491 |
else |
|
2505 |
try |
|
2492 | 2506 |
{ |
2493 |
throw new Exception("확인 필요한 케이스"); |
|
2494 |
} |
|
2507 |
LMModelItem modelItem1 = dataSource.GetModelItem(modelItemID1); |
|
2508 |
_LMAItem item1 = modelItem1.AsLMAItem(); |
|
2509 |
LMModelItem modelItem2 = dataSource.GetModelItem(modelItemID2); |
|
2510 |
_LMAItem item2 = modelItem2.AsLMAItem(); |
|
2495 | 2511 |
|
2496 |
List<Line> lines = SPPIDUtil.FindLinesByModelId(document, beforeID); |
|
2497 |
foreach (var line in lines) |
|
2498 |
line.SPPID.ModelItemId = afterID; |
|
2512 |
// item2가 item1으로 조인 |
|
2513 |
_placement.PIDJoinRuns(ref item1, ref item2); |
|
2514 |
item1.Commit(); |
|
2515 |
item2.Commit(); |
|
2499 | 2516 |
|
2500 |
ReleaseCOMObjects(modelItem1); |
|
2501 |
ReleaseCOMObjects(item1); |
|
2502 |
ReleaseCOMObjects(modelItem2); |
|
2503 |
ReleaseCOMObjects(item2); |
|
2504 |
} |
|
2517 |
string beforeID = string.Empty; |
|
2518 |
string afterID = string.Empty; |
|
2505 | 2519 |
|
2506 |
/// <summary> |
|
2507 |
/// PipeRun을 자동으로 Join하는 메서드 |
|
2508 |
/// </summary> |
|
2509 |
/// <param name="modelItemId"></param> |
|
2510 |
private void AutoJoinPipeRun(string modelItemId) |
|
2511 |
{ |
|
2512 |
LMModelItem modelItem = dataSource.GetModelItem(modelItemId); |
|
2513 |
_LMAItem item = modelItem.AsLMAItem(); |
|
2514 |
if (modelItem.get_ItemStatus() == "Active") |
|
2515 |
{ |
|
2516 |
string modelitemID = item.Id; |
|
2517 |
_placement.PIDAutoJoin(item, AutoJoinEndConstants.autoJoin_Both, ref item); |
|
2518 |
string afterModelItemID = item.Id; |
|
2520 |
if (modelItem1.get_ItemStatus() == "Active" && modelItem2.get_ItemStatus() != "Active") |
|
2521 |
{ |
|
2522 |
beforeID = modelItem2.Id; |
|
2523 |
afterID = modelItem1.Id; |
|
2524 |
} |
|
2525 |
else if (modelItem1.get_ItemStatus() != "Active" && modelItem2.get_ItemStatus() == "Active") |
|
2526 |
{ |
|
2527 |
beforeID = modelItem1.Id; |
|
2528 |
afterID = modelItem2.Id; |
|
2529 |
} |
|
2530 |
else |
|
2531 |
{ |
|
2532 |
Log.Write("확인 필요한 케이스"); |
|
2533 |
} |
|
2519 | 2534 |
|
2520 |
if (modelitemID != afterModelItemID)
|
|
2535 |
if (!string.IsNullOrEmpty(beforeID) && !string.IsNullOrEmpty(afterID))
|
|
2521 | 2536 |
{ |
2522 |
List<Line> lines = SPPIDUtil.FindLinesByModelId(document, modelitemID);
|
|
2537 |
List<Line> lines = SPPIDUtil.FindLinesByModelId(document, beforeID);
|
|
2523 | 2538 |
foreach (var line in lines) |
2524 |
line.SPPID.ModelItemId = afterModelItemID;
|
|
2539 |
line.SPPID.ModelItemId = afterID; |
|
2525 | 2540 |
} |
2526 |
item.Commit(); |
|
2527 |
} |
|
2528 | 2541 |
|
2529 |
ReleaseCOMObjects(modelItem); |
|
2530 |
ReleaseCOMObjects(item); |
|
2531 |
} |
|
2532 |
|
|
2533 |
/// <summary> |
|
2534 |
/// LineRun에 있는 Line들을 Join하는 진입 메서드 |
|
2535 |
/// </summary> |
|
2536 |
/// <param name="run"></param> |
|
2537 |
private void JoinRunLine(LineRun run) |
|
2538 |
{ |
|
2539 |
string modelItemId = string.Empty; |
|
2540 |
foreach (var item in run.RUNITEMS) |
|
2542 |
ReleaseCOMObjects(modelItem1); |
|
2543 |
ReleaseCOMObjects(item1); |
|
2544 |
ReleaseCOMObjects(modelItem2); |
|
2545 |
ReleaseCOMObjects(item2); |
|
2546 |
} |
|
2547 |
catch (Exception ex) |
|
2541 | 2548 |
{ |
2542 |
if (item.GetType() == typeof(Line)) |
|
2543 |
{ |
|
2544 |
Line line = item as Line; |
|
2545 |
AutoJoinPipeRun(line.SPPID.ModelItemId); |
|
2546 |
modelItemId = line.SPPID.ModelItemId; |
|
2547 |
} |
|
2549 |
Log.Write("Join Error"); |
|
2550 |
Log.Write(ex.Message); |
|
2548 | 2551 |
} |
2549 | 2552 |
} |
2550 | 2553 |
|
... | ... | |
2986 | 2989 |
} |
2987 | 2990 |
} |
2988 | 2991 |
} |
2992 |
|
|
2989 | 2993 |
/// <summary> |
2990 | 2994 |
/// Flow Mark Modeling |
2991 | 2995 |
/// </summary> |
... | ... | |
3107 | 3111 |
LMSymbol _LMSymbol = dataSource.GetSymbol(sRep); |
3108 | 3112 |
LMModelItem _LMModelItem = _LMSymbol.ModelItemObject; |
3109 | 3113 |
LMAAttributes _Attributes = _LMModelItem.Attributes; |
3110 |
|
|
3114 |
|
|
3111 | 3115 |
foreach (var item in targetAttributes) |
3112 | 3116 |
{ |
3113 | 3117 |
AttributeMapping mapping = document.AttributeMappings.Find(x => x.UID == item.UID); |
... | ... | |
3499 | 3503 |
ReleaseCOMObjects(_LMSymbol); |
3500 | 3504 |
} |
3501 | 3505 |
|
3506 |
private void JoinRun(Line line) |
|
3507 |
{ |
|
3508 |
if (!string.IsNullOrEmpty(line.SPPID.ModelItemId)) |
|
3509 |
{ |
|
3510 |
//LMModelItem modelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
|
3511 |
//foreach (LMRepresentation rep in modelItem.Representations) |
|
3512 |
//{ |
|
3513 |
// if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
3514 |
// { |
|
3515 |
// LMConnector connector = dataSource.GetConnector(rep.Id); |
|
3516 |
// if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch") |
|
3517 |
// { |
|
3518 |
|
|
3519 |
// } |
|
3520 |
// if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch") |
|
3521 |
// { |
|
3522 |
|
|
3523 |
// } |
|
3524 |
// } |
|
3525 |
//} |
|
3526 |
|
|
3527 |
|
|
3528 |
////JoinPipeRun() |
|
3529 |
} |
|
3530 |
} |
|
3531 |
|
|
3502 | 3532 |
/// <summary> |
3503 | 3533 |
/// Label의 좌표를 구하는 메서드(ID2 기준의 좌표 -> SPPID 좌표) |
3504 | 3534 |
/// </summary> |
... | ... | |
3613 | 3643 |
} |
3614 | 3644 |
else |
3615 | 3645 |
{ |
3616 |
// 아이템 연결 갯수(심볼, Line이면서 Not Branch)
|
|
3617 |
int connItemRetval = CompareConnItem(a, b);
|
|
3618 |
if (connItemRetval != 0)
|
|
3646 |
// ConnectedItem이 없는것
|
|
3647 |
int noneConnRetval = CompareNoneConn(a, b);
|
|
3648 |
if (noneConnRetval != 0)
|
|
3619 | 3649 |
{ |
3620 |
return connItemRetval;
|
|
3650 |
return noneConnRetval;
|
|
3621 | 3651 |
} |
3622 | 3652 |
else |
3623 | 3653 |
{ |
3624 |
// ConnectedItem이 없는것
|
|
3625 |
int noneConnRetval = CompareNoneConn(a, b);
|
|
3626 |
if (noneConnRetval != 0)
|
|
3654 |
// 아이템 연결 갯수(심볼, Line이면서 Not Branch)
|
|
3655 |
int connItemRetval = CompareConnItem(a, b);
|
|
3656 |
if (connItemRetval != 0)
|
|
3627 | 3657 |
{ |
3628 |
return noneConnRetval;
|
|
3658 |
return connItemRetval;
|
|
3629 | 3659 |
} |
3630 | 3660 |
else |
3631 | 3661 |
{ |
DTI_PID/SPPIDConverter/ConverterDocking.cs | ||
---|---|---|
35 | 35 |
application = Interaction.GetObject("", "PIDAutomation.Application"); |
36 | 36 |
WrapperApplication wApp = new WrapperApplication(application.Application); |
37 | 37 |
radApp = wApp.RADApplication; |
38 |
|
|
38 |
|
|
39 | 39 |
try |
40 | 40 |
{ |
41 | 41 |
textEditDrawingX.EditValue = Settings.Default.DrawingX; |
... | ... | |
188 | 188 |
} |
189 | 189 |
|
190 | 190 |
#region TEST |
191 |
Placement _placement = new Placement(); |
|
192 |
LMADataSource dataSource; |
|
191 | 193 |
bool first = true; |
192 | 194 |
LMDrawing currentDrawing; |
193 | 195 |
private void simpleButton1_Click(object sender, EventArgs e) |
194 | 196 |
{ |
195 |
Placement _placement = new Placement(); |
|
196 |
LMADataSource dataSource = _placement.PIDDataSource;//placement.PIDDataSource; |
|
197 |
dataSource = _placement.PIDDataSource; |
|
198 |
|
|
199 |
string projectNumber = dataSource.ProjectNumber; |
|
200 |
LMActiveProject activeProject = dataSource.GetActiveProject(); |
|
201 |
LMAEnumAttLists enumAttLists = dataSource.CodeLists; |
|
197 | 202 |
|
198 |
LMModelItem modelitem = dataSource.GetModelItem("F462457D634C401B9D9FB425A2AC88EA"); |
|
199 |
foreach (LMRepresentation item in modelitem.Representations) |
|
203 |
AutoJoinPipeRun(); |
|
204 |
} |
|
205 |
private void AutoJoinPipeRun() |
|
206 |
{ |
|
207 |
string modelItemId = null; |
|
208 |
List<double[]> vertices = new List<double[]>(); |
|
209 |
dynamic OID = radApp.ActiveSelectSet[0].Key(); |
|
210 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
|
211 |
foreach (var attributes in drawingObject.AttributeSets) |
|
200 | 212 |
{ |
201 |
LMSymbol symbol = dataSource.GetSymbol(item.Id); |
|
202 |
foreach (LMRelationship relationship in symbol.Relation1Relationships) |
|
213 |
foreach (var attribute in attributes) |
|
203 | 214 |
{ |
204 |
if (relationship.Item1RepresentationObject != null && relationship.Item1RepresentationObject.Id != symbol.Id) |
|
205 |
{ |
|
215 |
if (attribute.Name == "ModelID") |
|
216 |
modelItemId = attribute.GetValue().ToString(); |
|
217 |
} |
|
218 |
} |
|
219 |
radApp.ActiveSelectSet.RemoveAll(); |
|
206 | 220 |
|
207 |
} |
|
208 |
else if (relationship.Item2RepresentationObject != null && relationship.Item2RepresentationObject.Id != symbol.Id) |
|
209 |
{ |
|
210 | 221 |
|
222 |
LMModelItem modelItem = dataSource.GetModelItem(modelItemId); |
|
223 |
|
|
224 |
List<string> endModelItemIDs = new List<string>(); |
|
225 |
|
|
226 |
if (modelItem != null) |
|
227 |
{ |
|
228 |
List<string> otherModelIds = new List<string>(); |
|
229 |
foreach (LMRepresentation rep in modelItem.Representations) |
|
230 |
{ |
|
231 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
232 |
{ |
|
233 |
LMConnector connector = dataSource.GetConnector(rep.Id); |
|
234 |
if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch") |
|
235 |
{ |
|
236 |
LMSymbol symbol = connector.ConnectItem1SymbolObject; |
|
237 |
otherModelIds.AddRange(FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id)); |
|
238 |
} |
|
239 |
if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch") |
|
240 |
{ |
|
241 |
LMSymbol symbol = connector.ConnectItem2SymbolObject; |
|
242 |
otherModelIds.AddRange(FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id)); |
|
243 |
} |
|
211 | 244 |
} |
212 | 245 |
} |
213 |
foreach (LMRelationship relationship in symbol.Relation2Relationships) |
|
246 |
|
|
247 |
} |
|
248 |
} |
|
249 |
private void JoinRun(string mainModelId, string modelId) |
|
250 |
{ |
|
251 |
LMModelItem modelItem = dataSource.GetModelItem(mainModelId); |
|
252 |
if (modelItem != null) |
|
253 |
{ |
|
254 |
foreach (LMRepresentation rep in modelItem.Representations) |
|
214 | 255 |
{ |
215 |
if (relationship.Item1RepresentationObject != null && relationship.Item1RepresentationObject.Id != symbol.Id)
|
|
256 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active")
|
|
216 | 257 |
{ |
258 |
LMConnector connector = dataSource.GetConnector(rep.Id); |
|
259 |
if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch") |
|
260 |
{ |
|
261 |
LMSymbol symbol = connector.ConnectItem1SymbolObject; |
|
217 | 262 |
|
263 |
} |
|
264 |
if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch") |
|
265 |
{ |
|
266 |
LMSymbol symbol = connector.ConnectItem2SymbolObject; |
|
267 |
string typeName = symbol.ModelItemObject.get_ItemTypeName().ToString(); |
|
268 |
if (typeName == "Instrument") |
|
269 |
{ |
|
270 |
LMInstrument instrument = dataSource.GetInstrument(symbol.ModelItemID); |
|
271 |
} |
|
272 |
else if (typeName == "PipingComp") |
|
273 |
{ |
|
274 |
LMPipingComp pipingComp = dataSource.GetPipingComp(symbol.ModelItemID); |
|
275 |
} |
|
276 |
} |
|
218 | 277 |
} |
219 |
else if (relationship.Item2RepresentationObject != null && relationship.Item2RepresentationObject.Id != symbol.Id) |
|
220 |
{ |
|
278 |
} |
|
279 |
} |
|
280 |
} |
|
221 | 281 |
|
282 |
private void GetModelItemForJoin(string modelItemId, List<string> otherModelIds) |
|
283 |
{ |
|
284 |
LMModelItem modelItem = dataSource.GetModelItem(modelItemId); |
|
285 |
List<string> endModelItemIDs = new List<string>(); |
|
286 |
if (modelItem != null) |
|
287 |
{ |
|
288 |
foreach (LMRepresentation rep in modelItem.Representations) |
|
289 |
{ |
|
290 |
if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
291 |
{ |
|
292 |
LMConnector connector = dataSource.GetConnector(rep.Id); |
|
293 |
if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch") |
|
294 |
{ |
|
295 |
LMSymbol symbol = connector.ConnectItem1SymbolObject; |
|
296 |
otherModelIds.AddRange(FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id)); |
|
297 |
} |
|
298 |
if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch") |
|
299 |
{ |
|
300 |
LMSymbol symbol = connector.ConnectItem2SymbolObject; |
|
301 |
otherModelIds.AddRange(FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id)); |
|
302 |
} |
|
222 | 303 |
} |
223 | 304 |
} |
305 |
|
|
306 |
} |
|
307 |
} |
|
308 |
|
|
309 |
private List<string> FindOtherModelItemBySymbolWhereTypePipeRun(LMSymbol symbol, string modelId) |
|
310 |
{ |
|
311 |
List<string> modelItemIDs = new List<string>(); |
|
312 |
foreach (LMConnector connector in symbol.Connect1Connectors) |
|
313 |
{ |
|
314 |
LMModelItem modelItem = connector.ModelItemObject; |
|
315 |
if (modelItem.get_ItemStatus() == "Active" && modelItem.get_ItemTypeName().ToString() == "PipeRun" && modelItem.Id != modelId) |
|
316 |
modelItemIDs.Add(modelItem.Id); |
|
317 |
ReleaseCOMObjects(modelItem); |
|
318 |
} |
|
319 |
|
|
320 |
foreach (LMConnector connector in symbol.Connect2Connectors) |
|
321 |
{ |
|
322 |
LMModelItem modelItem = connector.ModelItemObject; |
|
323 |
if (modelItem.get_ItemStatus() == "Active" && modelItem.get_ItemTypeName().ToString() == "PipeRun" && modelItem.Id != modelId) |
|
324 |
modelItemIDs.Add(modelItem.Id); |
|
325 |
ReleaseCOMObjects(modelItem); |
|
224 | 326 |
} |
225 | 327 |
|
328 |
return modelItemIDs; |
|
329 |
} |
|
330 |
|
|
331 |
private void FindOtherModelItemBySymbolWhereTypePipeRunLoop() |
|
332 |
{ |
|
333 |
|
|
334 |
} |
|
335 |
|
|
336 |
private void JoinRunOnlyPipeRun() |
|
337 |
{ |
|
338 |
|
|
339 |
} |
|
226 | 340 |
|
227 |
//LMConnector connector = GetLMConnectorOnlyOne("E12B6DC30C224B51911F2AFFEFB8ED14"); |
|
228 |
//if (connector != null) |
|
229 |
//{ |
|
230 |
// string mappingPath = @"\Piping\Labels - Piping Segments\Flow Direction.sym"; |
|
231 |
// List<double[]> vertices = GetConnectorVertices(); |
|
232 |
// vertices = vertices.FindAll(x => x[0] > 0 && x[1] > 0); |
|
233 |
// double[] point = vertices[vertices.Count - 1]; |
|
234 |
// double[] temp = vertices[vertices.Count - 2]; |
|
235 |
// double angle = SPPIDUtil.CalcAngle(point[0], point[1], temp[0], temp[1]); |
|
236 |
// Array array = new double[] { 0, point[0], point[1] }; |
|
237 |
// LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mappingPath, ref array, LabeledItem: connector.AsLMRepresentation()); |
|
238 |
// if (_LMLabelPersist != null) |
|
239 |
// ReleaseCOMObjects(_LMLabelPersist); |
|
240 |
//} |
|
241 |
|
|
242 |
//LMConnector GetLMConnectorOnlyOne(string modelItemID) |
|
243 |
//{ |
|
244 |
// LMConnector result = null; |
|
245 |
// List<LMConnector> connectors = new List<LMConnector>(); |
|
246 |
// LMModelItem modelItem = dataSource.GetModelItem(modelItemID); |
|
247 |
|
|
248 |
// if (modelItem != null) |
|
249 |
// { |
|
250 |
// foreach (LMRepresentation rep in modelItem.Representations) |
|
251 |
// { |
|
252 |
// if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active") |
|
253 |
// connectors.Add(dataSource.GetConnector(rep.Id)); |
|
254 |
// } |
|
255 |
|
|
256 |
// ReleaseCOMObjects(modelItem); |
|
257 |
// } |
|
258 |
|
|
259 |
// if (connectors.Count == 1) |
|
260 |
// result = connectors[0]; |
|
261 |
// else |
|
262 |
// foreach (var item in connectors) |
|
263 |
// ReleaseCOMObjects(item); |
|
264 |
|
|
265 |
// return result; |
|
266 |
//} |
|
267 |
|
|
268 |
//List<double[]> GetConnectorVertices() |
|
269 |
//{ |
|
270 |
// List<double[]> vertices = new List<double[]>(); |
|
271 |
// dynamic OID = radApp.ActiveSelectSet[0].Key(); |
|
272 |
// DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
|
273 |
// Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
|
274 |
// int verticesCount = lineStringGeometry.VertexCount; |
|
275 |
// double[] value = null; |
|
276 |
// lineStringGeometry.GetVertices(ref verticesCount, ref value); |
|
277 |
// for (int i = 0; i < verticesCount; i++) |
|
278 |
// { |
|
279 |
// double x = 0; |
|
280 |
// double y = 0; |
|
281 |
// lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
|
282 |
// vertices.Add(new double[] { x, y }); |
|
283 |
// } |
|
284 |
// return vertices; |
|
285 |
//} |
|
341 |
private void GetConnectPointsCount(LMSymbol symbol,ref int pipeRunCount, ref int signalCount) |
|
342 |
{ |
|
343 |
string typeName = symbol.ModelItemObject.get_ItemTypeName().ToString(); |
|
344 |
if (typeName == "Instrument") |
|
345 |
{ |
|
346 |
LMInstrument item = dataSource.GetInstrument(symbol.ModelItemID); |
|
347 |
pipeRunCount = item.PipingPoints.Count; |
|
348 |
signalCount = item.SignalPoints.Count; |
|
349 |
ReleaseCOMObjects(item); |
|
350 |
} |
|
351 |
else if (typeName == "PipingComp") |
|
352 |
{ |
|
353 |
LMPipingComp item = dataSource.GetPipingComp(symbol.ModelItemID); |
|
354 |
pipeRunCount = item.PipingPoints.Count; |
|
355 |
signalCount = item.SignalPoints.Count; |
|
356 |
ReleaseCOMObjects(item); |
|
357 |
} |
|
286 | 358 |
} |
359 |
|
|
360 |
|
|
361 |
|
|
287 | 362 |
private void TESTLine() |
288 | 363 |
{ |
289 | 364 |
Placement _placement = new Placement(); |
내보내기 Unified diff