개정판 2a4872ec
dev issue #000 : EndBreakModeling 실패시 RetryEndBreakModeling 추가
Change-Id: Id46812d745d1844842312623e6b42a105d8dcb7f
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
976 | 976 |
private void EndBreakModeling(EndBreak endBreak) |
977 | 977 |
{ |
978 | 978 |
object ownerObj = SPPIDUtil.FindObjectByUID(document, endBreak.OWNER); |
979 |
LMConnector targetLMConnector = null; |
|
979 | 980 |
if (ownerObj !=null && ownerObj.GetType() == typeof(Line)) |
980 | 981 |
{ |
981 | 982 |
Line ownerLine = ownerObj as Line; |
982 | 983 |
LMLabelPersist _LmLabelPersist = null; |
983 | 984 |
Dictionary<LMConnector, List<double[]>> connectorVertices = GetPipeRunVertices(ownerLine.SPPID.ModelItemId); |
984 | 985 |
|
985 |
LMConnector connectedLMConnector = FindTargetLMConnectorByPoint(connectorVertices, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y);
|
|
986 |
targetLMConnector = FindTargetLMConnectorByPoint(connectorVertices, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y);
|
|
986 | 987 |
|
987 |
if (connectedLMConnector != null)
|
|
988 |
if (targetLMConnector != null)
|
|
988 | 989 |
{ |
989 | 990 |
Array array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
990 |
_LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: connectedLMConnector.AsLMRepresentation(), IsLeaderVisible: true);
|
|
991 |
_LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: targetLMConnector.AsLMRepresentation(), IsLeaderVisible: true);
|
|
991 | 992 |
} |
992 | 993 |
|
993 | 994 |
if (_LmLabelPersist != null) |
... | ... | |
997 | 998 |
} |
998 | 999 |
else |
999 | 1000 |
{ |
1000 |
|
|
1001 |
RetryEndBreakModeling(endBreak, targetLMConnector); |
|
1001 | 1002 |
} |
1002 | 1003 |
|
1003 | 1004 |
foreach (var item in connectorVertices) |
1004 | 1005 |
ReleaseCOMObjects(item.Key); |
1006 |
|
|
1005 | 1007 |
} |
1006 | 1008 |
else if (ownerObj != null && ownerObj.GetType() == typeof(Symbol)) |
1007 | 1009 |
{ |
1008 | 1010 |
Symbol ownerSymbol = ownerObj as Symbol; |
1009 | 1011 |
LMSymbol _LMSymbol = dataSource.GetSymbol(ownerSymbol.SPPID.RepresentationId); |
1010 | 1012 |
|
1011 |
LMConnector targetLMConnector = null;
|
|
1013 |
targetLMConnector = null; |
|
1012 | 1014 |
double distance = double.MaxValue; |
1013 | 1015 |
|
1014 | 1016 |
foreach (LMConnector connector in _LMSymbol.Avoid1Connectors) |
... | ... | |
1075 | 1077 |
} |
1076 | 1078 |
else |
1077 | 1079 |
{ |
1078 |
bool isZeroLength = Convert.ToBoolean(targetLMConnector.get_IsZeroLength()); |
|
1079 |
if (isZeroLength) |
|
1080 |
{ |
|
1081 |
dynamic OID = targetLMConnector.get_GraphicOID(); |
|
1082 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
|
1083 |
Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
|
1084 |
int verticesCount = lineStringGeometry.VertexCount; |
|
1085 |
double[] vertices = null; |
|
1086 |
lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
|
1087 |
List<double[]> list = new List<double[]>(); |
|
1088 |
for (int i = 0; i < verticesCount; i++) |
|
1089 |
{ |
|
1090 |
double x = 0; |
|
1091 |
double y = 0; |
|
1092 |
lineStringGeometry.GetVertex(i + 1, ref x, ref y); |
|
1093 |
list.Add(new double[] { x, y }); |
|
1094 |
} |
|
1080 |
RetryEndBreakModeling(endBreak, targetLMConnector); |
|
1081 |
} |
|
1082 |
} |
|
1083 |
|
|
1084 |
ReleaseCOMObjects(_LMSymbol); |
|
1085 |
} |
|
1086 |
} |
|
1095 | 1087 |
|
1096 |
PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
|
1097 |
placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem1SymbolObject, list[0][0], list[0][1]); |
|
1098 |
placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem2SymbolObject, list[0][0], list[0][1]); |
|
1099 |
_LMAItem _LMAItem = _placement.PIDCreateItem(@"\Piping\Routing\Process Lines\Primary Piping.sym"); |
|
1088 |
private void RetryEndBreakModeling(EndBreak endBreak, LMConnector targetLMConnector) |
|
1089 |
{ |
|
1090 |
bool isZeroLength = Convert.ToBoolean(targetLMConnector.get_IsZeroLength()); |
|
1091 |
Array array = null; |
|
1092 |
LMLabelPersist _LMLabelPersist = null; |
|
1093 |
LMConnector _LMConnector = null; |
|
1094 |
dynamic OID = targetLMConnector.get_GraphicOID(); |
|
1095 |
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID]; |
|
1096 |
Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d; |
|
1097 |
int verticesCount = lineStringGeometry.VertexCount; |
|
1098 |
PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
|
1099 |
_LMAItem _LMAItem = _placement.PIDCreateItem(@"\Piping\Routing\Process Lines\Primary Piping.sym"); |
|
1100 | 1100 |
|
1101 |
_placement.PIDRemovePlacement(targetLMConnector.AsLMRepresentation()); |
|
1102 |
LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
|
1101 |
if (isZeroLength) |
|
1102 |
{ |
|
1103 |
double[] vertices = null; |
|
1104 |
lineStringGeometry.GetVertices(ref verticesCount, ref vertices); |
|
1105 |
double x = 0; |
|
1106 |
double y = 0; |
|
1107 |
lineStringGeometry.GetVertex(1, ref x, ref y); |
|
1103 | 1108 |
|
1104 |
array = new double[] { 0, list[0][0], list[0][1] }; |
|
1105 |
_LmLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: _lMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
|
1106 |
if (_LmLabelPersist != null) |
|
1107 |
{ |
|
1108 |
_LmLabelPersist.Commit(); |
|
1109 |
} |
|
1110 |
else |
|
1111 |
{ |
|
1109 |
placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem1SymbolObject, x, y); |
|
1110 |
placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem2SymbolObject, x, y); |
|
1112 | 1111 |
|
1113 |
} |
|
1114 |
} |
|
1112 |
_placement.PIDRemovePlacement(targetLMConnector.AsLMRepresentation()); |
|
1113 |
_LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
|
1114 |
|
|
1115 |
array = new double[] { 0, x, y }; |
|
1116 |
_LMLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: _LMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
|
1117 |
} |
|
1118 |
else |
|
1119 |
{ |
|
1120 |
List<double[]> vertices = new List<double[]>(); |
|
1121 |
for (int i = 1; i <= verticesCount; i++) |
|
1122 |
{ |
|
1123 |
double x = 0; |
|
1124 |
double y = 0; |
|
1125 |
lineStringGeometry.GetVertex(i, ref x, ref y); |
|
1126 |
vertices.Add(new double[] { x, y }); |
|
1127 |
} |
|
1128 |
|
|
1129 |
for (int i = 0; i < vertices.Count; i++) |
|
1130 |
{ |
|
1131 |
double[] points = vertices[i]; |
|
1132 |
if (i == 0) |
|
1133 |
{ |
|
1134 |
if (targetLMConnector.ConnectItem1SymbolObject != null) |
|
1135 |
placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem1SymbolObject, points[0], points[1]); |
|
1136 |
else |
|
1137 |
placeRunInputs.AddPoint(points[0], points[1]); |
|
1138 |
} |
|
1139 |
else if (i == vertices.Count - 1) |
|
1140 |
{ |
|
1141 |
if (targetLMConnector.ConnectItem2SymbolObject != null) |
|
1142 |
placeRunInputs.AddSymbolTarget(targetLMConnector.ConnectItem2SymbolObject, points[0], points[1]); |
|
1143 |
else |
|
1144 |
placeRunInputs.AddPoint(points[0], points[1]); |
|
1115 | 1145 |
} |
1146 |
else |
|
1147 |
placeRunInputs.AddPoint(points[0], points[1]); |
|
1116 | 1148 |
} |
1149 |
|
|
1150 |
List<Line> lines = SPPIDUtil.FindLinesByModelId(document, targetLMConnector.ModelItemID); |
|
1117 | 1151 |
|
1118 |
ReleaseCOMObjects(_LMSymbol); |
|
1152 |
_placement.PIDRemovePlacement(targetLMConnector.AsLMRepresentation()); |
|
1153 |
_LMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
|
1154 |
|
|
1155 |
foreach (var line in lines) |
|
1156 |
line.SPPID.ModelItemId = _LMConnector.ModelItemID; |
|
1157 |
|
|
1158 |
array = new double[] { 0, endBreak.SPPID.ORIGINAL_X, endBreak.SPPID.ORIGINAL_Y }; |
|
1159 |
_LMLabelPersist = _placement.PIDPlaceLabel(endBreak.SPPID.MAPPINGNAME, ref array, Rotation: 0, LabeledItem: _LMConnector.AsLMRepresentation(), IsLeaderVisible: true); |
|
1160 |
} |
|
1161 |
|
|
1162 |
|
|
1163 |
if (_LMLabelPersist != null) |
|
1164 |
{ |
|
1165 |
_LMLabelPersist.Commit(); |
|
1166 |
ReleaseCOMObjects(_LMLabelPersist); |
|
1119 | 1167 |
} |
1168 |
else |
|
1169 |
{ |
|
1170 |
|
|
1171 |
} |
|
1172 |
|
|
1173 |
ReleaseCOMObjects(_LMConnector); |
|
1174 |
ReleaseCOMObjects(placeRunInputs); |
|
1175 |
ReleaseCOMObjects(_LMAItem); |
|
1120 | 1176 |
} |
1121 | 1177 |
|
1122 | 1178 |
private void JoinPipeRun(string fromModelItemId, string toModelItemId) |
내보내기 Unified diff