개정판 147c80c4
dev issue #507 : line join시 ZeroLength로 인한 Type변경 버그 수정
Change-Id: I0db10d8f7d69790ea724a576e3dbbe69d67c8de2
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
1059 | 1059 |
if (connector != null) |
1060 | 1060 |
GetTargetSymbolConnectorPoint(connector, targetSymbol, ref x, ref y); |
1061 | 1061 |
|
1062 |
LMConnector temp = LineModelingForSymbolZeroLength(symbol, _TargetItem, x, y); |
|
1062 | 1063 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem); |
1064 |
if (temp != null) |
|
1065 |
_placement.PIDRemovePlacement(temp.AsLMRepresentation()); |
|
1066 |
ReleaseCOMObjects(temp); |
|
1067 |
temp = null; |
|
1063 | 1068 |
|
1064 | 1069 |
if (_LMSymbol != null && _TargetItem != null) |
1065 | 1070 |
symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id; |
... | ... | |
1122 | 1127 |
ReleaseCOMObjects(_LMSymbol); |
1123 | 1128 |
} |
1124 | 1129 |
} |
1130 |
/// <summary> |
|
1131 |
/// targetX와 targetY 기준 제일 먼 PipingPoint에 TempLine Modeling |
|
1132 |
/// Signal Point는 고려하지 않음 |
|
1133 |
/// </summary> |
|
1134 |
/// <param name="symbol"></param> |
|
1135 |
/// <param name="_TargetItem"></param> |
|
1136 |
/// <param name="targetX"></param> |
|
1137 |
/// <param name="targetY"></param> |
|
1138 |
/// <returns></returns> |
|
1139 |
private LMConnector LineModelingForSymbolZeroLength(Symbol symbol, LMSymbol _TargetItem, double targetX, double targetY) |
|
1140 |
{ |
|
1141 |
LMConnector tempConnector = null; |
|
1142 |
|
|
1143 |
List<Symbol> group = new List<Symbol>(); |
|
1144 |
SPPIDUtil.FindConnectedSymbolGroup(document, symbol, group); |
|
1145 |
if (group.FindAll(loopX => !string.IsNullOrEmpty(loopX.SPPID.RepresentationId)).Count == 1) |
|
1146 |
{ |
|
1147 |
List<Connector> connectors = new List<Connector>(); |
|
1148 |
foreach (var item in group) |
|
1149 |
connectors.AddRange(item.CONNECTORS.FindAll(loopX => loopX.ConnectedObject != null && loopX.ConnectedObject.GetType() == typeof(Line))); |
|
1150 |
/// Primary or Secondary Type Line만 고려 |
|
1151 |
Connector _connector = connectors.Find(loopX => loopX.ConnectedObject != null && loopX.ConnectedObject.GetType() == typeof(Line) && |
|
1152 |
(((Line)loopX.ConnectedObject).TYPE == "Primary" || ((Line)loopX.ConnectedObject).TYPE == "Secondary")); |
|
1153 |
if (_connector != null) |
|
1154 |
{ |
|
1155 |
string sppidLine = ((Line)_connector.ConnectedObject).SPPID.MAPPINGNAME; |
|
1156 |
List<double[]> pointInfos = getPipingPoints(_TargetItem); |
|
1157 |
/// PipingPoint가 2개 이상만 |
|
1158 |
if (pointInfos.Count >= 2) |
|
1159 |
{ |
|
1160 |
double lineX = 0; |
|
1161 |
double lineY = 0; |
|
1162 |
double length = 0; |
|
1163 |
foreach (var item in pointInfos) |
|
1164 |
{ |
|
1165 |
double tempX = item[1]; |
|
1166 |
double tempY = item[2]; |
|
1167 |
|
|
1168 |
double calcDistance = SPPIDUtil.CalcPointToPointdDistance(targetX, targetY, tempX, tempY); |
|
1169 |
if (calcDistance > length) |
|
1170 |
{ |
|
1171 |
lineX = tempX; |
|
1172 |
lineY = tempY; |
|
1173 |
} |
|
1174 |
} |
|
1175 |
|
|
1176 |
_LMAItem _LMAItem = _placement.PIDCreateItem(sppidLine); |
|
1177 |
PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
|
1178 |
placeRunInputs.AddSymbolTarget(_TargetItem, lineX, lineY); |
|
1179 |
placeRunInputs.AddPoint(-1, -1); |
|
1180 |
tempConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
|
1181 |
if (tempConnector != null) |
|
1182 |
tempConnector.Commit(); |
|
1183 |
ReleaseCOMObjects(_LMAItem); |
|
1184 |
_LMAItem = null; |
|
1185 |
ReleaseCOMObjects(placeRunInputs); |
|
1186 |
placeRunInputs = null; |
|
1187 |
} |
|
1188 |
} |
|
1189 |
} |
|
1190 |
|
|
1191 |
return tempConnector; |
|
1192 |
} |
|
1193 |
/// <summary> |
|
1194 |
/// Symbol의 PipingPoints를 구함 |
|
1195 |
/// SignalPoint는 고려하지 않음 |
|
1196 |
/// </summary> |
|
1197 |
/// <param name="symbol"></param> |
|
1198 |
/// <returns></returns> |
|
1199 |
private List<double[]> getPipingPoints(LMSymbol symbol) |
|
1200 |
{ |
|
1201 |
LMModelItem modelItem = symbol.ModelItemObject; |
|
1202 |
LMPipingPoints pipingPoints = null; |
|
1203 |
if (modelItem.get_ItemTypeName() == "PipingComp") |
|
1204 |
{ |
|
1205 |
LMPipingComp pipingComp = dataSource.GetPipingComp(modelItem.Id); |
|
1206 |
pipingPoints = pipingComp.PipingPoints; |
|
1207 |
ReleaseCOMObjects(pipingComp); |
|
1208 |
pipingComp = null; |
|
1209 |
} |
|
1210 |
else if (modelItem.get_ItemTypeName() == "Instrument") |
|
1211 |
{ |
|
1212 |
LMInstrument instrument = dataSource.GetInstrument(modelItem.Id); |
|
1213 |
pipingPoints = instrument.PipingPoints; |
|
1214 |
ReleaseCOMObjects(instrument); |
|
1215 |
instrument = null; |
|
1216 |
} |
|
1217 |
else |
|
1218 |
Log.Write("다른 Type"); |
|
1219 |
|
|
1220 |
List<double[]> info = new List<double[]>(); |
|
1221 |
if (pipingPoints != null) |
|
1222 |
{ |
|
1223 |
foreach (LMPipingPoint pipingPoint in pipingPoints) |
|
1224 |
{ |
|
1225 |
foreach (LMAAttribute attribute in pipingPoint.Attributes) |
|
1226 |
{ |
|
1227 |
if (attribute.Name == "PipingPointNumber") |
|
1228 |
{ |
|
1229 |
int index = Convert.ToInt32(attribute.get_Value()); |
|
1230 |
if (info.Find(loopX => loopX[0] == index) == null) |
|
1231 |
{ |
|
1232 |
double x = 0; |
|
1233 |
double y = 0; |
|
1234 |
if (_placement.PIDConnectPointLocation(symbol, index, ref x, ref y)) |
|
1235 |
info.Add(new double[] { index, x, y }); |
|
1236 |
} |
|
1237 |
} |
|
1238 |
} |
|
1239 |
} |
|
1240 |
} |
|
1241 |
ReleaseCOMObjects(modelItem); |
|
1242 |
modelItem = null; |
|
1243 |
ReleaseCOMObjects(pipingPoints); |
|
1244 |
pipingPoints = null; |
|
1245 |
|
|
1246 |
return info; |
|
1247 |
} |
|
1125 | 1248 |
|
1126 | 1249 |
private void RemoveSymbol(Symbol symbol) |
1127 | 1250 |
{ |
내보내기 Unified diff