개정판 45af3335
Insert Auxiliary Graphic
Change-Id: Ied5b02bfede0dcb89919d8a355ed936d4f2ca2f5
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
22 | 22 |
using Microsoft.VisualBasic; |
23 | 23 |
using Newtonsoft.Json; |
24 | 24 |
using DevExpress.XtraSplashScreen; |
25 |
using System.IO; |
|
26 |
|
|
25 | 27 |
namespace Converter.SPPID |
26 | 28 |
{ |
27 | 29 |
[Flags] |
... | ... | |
101 | 103 |
Log.Write("Start Modeling"); |
102 | 104 |
SplashScreenManager.ShowForm(typeof(SPPIDSplashScreen), true, true); |
103 | 105 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetParent, (IntPtr)radApp.HWnd); |
104 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStepCount, 25);
|
|
106 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllStepCount, 26);
|
|
105 | 107 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetDocumentName, DocumentLabelText); |
106 | 108 |
|
107 | 109 |
// VendorPackage Modeling |
... | ... | |
174 | 176 |
RunETC(); |
175 | 177 |
// input bulk attribute |
176 | 178 |
RunBulkAttribute(); |
179 |
// Graphic Modeling |
|
180 |
RunGraphicModeling(); |
|
177 | 181 |
// log file 생성 |
178 | 182 |
document.CheckModelingResult(); |
179 | 183 |
} |
... | ... | |
1091 | 1095 |
SPPIDUtil.BulkAttribute(dataSource, select, BulkAttributeItemType.Symbol); |
1092 | 1096 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
1093 | 1097 |
} |
1098 |
private void RunGraphicModeling() |
|
1099 |
{ |
|
1100 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetAllProgress, document.SYMBOLS.Count); |
|
1101 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.SetStep, "Graphic Modeling"); |
|
1102 |
foreach (var item in document.Graphics) |
|
1103 |
{ |
|
1104 |
try |
|
1105 |
{ |
|
1106 |
GraphicModeling(item); |
|
1107 |
SplashScreenManager.Default.SendCommand(SPPIDSplashScreen.SplashScreenCommand.UpProgress, null); |
|
1108 |
} |
|
1109 |
catch (Exception ex) |
|
1110 |
{ |
|
1111 |
Log.Write("Error in GrahicModeling"); |
|
1112 |
Log.Write("UID : " + item.UID); |
|
1113 |
Log.Write(ex.Message); |
|
1114 |
Log.Write(ex.StackTrace); |
|
1115 |
} |
|
1116 |
} |
|
1117 |
} |
|
1094 | 1118 |
/// <summary> |
1095 | 1119 |
/// 도면 생성 메서드 |
1096 | 1120 |
/// </summary> |
... | ... | |
2176 | 2200 |
} |
2177 | 2201 |
} |
2178 | 2202 |
|
2203 |
private void GraphicModeling(Graphic graphic) |
|
2204 |
{ |
|
2205 |
Ingr.RAD2D.SmartFrame2d borderFrame = radApp.ActiveDocument.ActiveSheet.SmartFrames2d[0]; |
|
2206 |
string styleName = "SFStyleConverter"; |
|
2207 |
string projectPah = Settings.Default.ProjectPath; |
|
2208 |
string graphicDirectory = Path.Combine(projectPah, "graphic"); |
|
2209 |
string filePath = Path.Combine(graphicDirectory, string.Format("{0}.igr", graphic.NAME)); |
|
2210 |
if (!File.Exists(filePath)) return; |
|
2211 |
|
|
2212 |
int styleCount = radApp.ActiveDocument.SmartFrame2dStyles.Count(c => c.Name.StartsWith(styleName)); |
|
2213 |
styleName = string.Format("{0}_{1}", styleName, styleCount); |
|
2214 |
Ingr.RAD2D.SmartFrame2dStyle StyleConverter = radApp.ActiveDocument.SmartFrame2dStyles.Add(styleName, ""); |
|
2215 |
|
|
2216 |
Ingr.RAD2D.SmartFrame2d smartFrame = radApp.ActiveDocument.ActiveSheet.SmartFrames2d.AddBy2Points(styleName, 0.01, 0.01, 0.1, 0.1, false, filePath); |
|
2217 |
smartFrame.BorderVisible = false; |
|
2218 |
smartFrame.SetLayerDisplay("default", true); |
|
2219 |
|
|
2220 |
double oMinx = 0, oMinY = 0, oMaxX = 0, oMaxY = 0; |
|
2221 |
smartFrame.Range(out oMinx, out oMinY, out oMaxX, out oMaxY); |
|
2222 |
double cWidth = oMaxX - oMinx; |
|
2223 |
double cHeight = oMaxY - oMinY; |
|
2224 |
double height = Math.Abs(graphic.SPPIDGraphicLocation.Y2 - graphic.SPPIDGraphicLocation.Y1); |
|
2225 |
double width = Math.Abs(graphic.SPPIDGraphicLocation.X2 - graphic.SPPIDGraphicLocation.X1); |
|
2226 |
double scaleFactor = width / cWidth; |
|
2227 |
smartFrame.ScaleFactor = scaleFactor; |
|
2228 |
smartFrame.SetOrigin(graphic.SPPIDGraphicLocation.X1, graphic.SPPIDGraphicLocation.Y1); |
|
2229 |
} |
|
2230 |
|
|
2179 | 2231 |
/// <summary> |
2180 | 2232 |
/// 첫 진입점 |
2181 | 2233 |
/// </summary> |
... | ... | |
6453 | 6505 |
/// <param name="originY"></param> |
6454 | 6506 |
/// <param name="SPPIDLabelLocation"></param> |
6455 | 6507 |
/// <param name="location"></param> |
6456 |
private void CalcLabelLocation(ref double x, ref double y, double originX, double originY, SPPIDLabelLocationInfo SPPIDLabelLocation, Location location)
|
|
6508 |
private void CalcLabelLocation(ref double x, ref double y, double originX, double originY, SPPIDEtcLocationInfo SPPIDLabelLocation, Location location)
|
|
6457 | 6509 |
{ |
6458 | 6510 |
if (location == Location.None) |
6459 | 6511 |
{ |
DTI_PID/SPPIDConverter/BaseModel/Document.cs | ||
---|---|---|
31 | 31 |
private List<SpecBreak> _SpecBreaks = new List<SpecBreak>(); |
32 | 32 |
private List<Equipment> _Equipments = new List<Equipment>(); |
33 | 33 |
private List<VendorPackage> _VendorPackages = new List<VendorPackage>(); |
34 |
private List<Graphic> _Graphics = new List<Graphic>(); |
|
34 | 35 |
private bool _Enable; |
35 | 36 |
private bool _Validation; |
36 | 37 |
private bool _MappingValidation; |
... | ... | |
49 | 50 |
public List<SpecBreak> SpecBreaks { get => _SpecBreaks; set => _SpecBreaks = value; } |
50 | 51 |
public List<Equipment> Equipments { get => _Equipments; set => _Equipments = value; } |
51 | 52 |
public List<VendorPackage> VendorPackages { get => _VendorPackages; set => _VendorPackages = value; } |
53 |
public List<Graphic> Graphics { get => _Graphics; set => _Graphics = value; } |
|
52 | 54 |
public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; } |
53 | 55 |
public string SIZE |
54 | 56 |
{ |
... | ... | |
102 | 104 |
SetLineNumber(xml.Element("LINENOS")); |
103 | 105 |
SetTrimLine(xml.Element("TRIMLINENOS")); |
104 | 106 |
SetVendorPackage(xml.Element("VENDORS")); |
107 |
SetGraphic(xml.Element("GRAPHICS")); |
|
105 | 108 |
|
106 | 109 |
SetAllConnectors(); |
107 | 110 |
Enable = true; |
... | ... | |
379 | 382 |
} |
380 | 383 |
} |
381 | 384 |
|
385 |
private void SetGraphic(XElement node) |
|
386 |
{ |
|
387 |
foreach (XElement item in node.Elements("GRAPHIC")) |
|
388 |
{ |
|
389 |
Graphic graphic = new Graphic() |
|
390 |
{ |
|
391 |
UID = item.Element("UID").Value, |
|
392 |
NAME = item.Element("NAME").Value, |
|
393 |
LOCATION_1 = item.Element("LOCATION1").Value, |
|
394 |
LOCATION_2 = item.Element("LOCATION2").Value, |
|
395 |
}; |
|
396 |
Graphics.Add(graphic); |
|
397 |
} |
|
398 |
} |
|
399 |
|
|
382 | 400 |
private void SetAssociations(XElement node, List<Association> associations) |
383 | 401 |
{ |
384 | 402 |
foreach (XElement item in node.Elements("ASSOCIATION")) |
DTI_PID/SPPIDConverter/BaseModel/Graphic.cs | ||
---|---|---|
1 |
using System; |
|
2 |
using System.Collections.Generic; |
|
3 |
using System.Linq; |
|
4 |
using System.Text; |
|
5 |
using System.Threading.Tasks; |
|
6 |
|
|
7 |
namespace Converter.BaseModel |
|
8 |
{ |
|
9 |
public class Graphic |
|
10 |
{ |
|
11 |
private string _UID; |
|
12 |
private string _NAME; |
|
13 |
private string _LOCATION_1; |
|
14 |
private string _LOCATION_2; |
|
15 |
private SPPIDSymbolInfo _SPPID; |
|
16 |
|
|
17 |
public string UID { get => _UID; set => _UID = value; } |
|
18 |
public string NAME { get => _NAME; set => _NAME = value; } |
|
19 |
public string LOCATION_1 |
|
20 |
{ |
|
21 |
get |
|
22 |
{ |
|
23 |
return _LOCATION_1; |
|
24 |
} |
|
25 |
set |
|
26 |
{ |
|
27 |
_LOCATION_1 = value; |
|
28 |
double x = 0; |
|
29 |
double y = 0; |
|
30 |
Converter.SPPID.Util.SPPIDUtil.ConvertPointBystring(_LOCATION_1, ref x, ref y); |
|
31 |
X1 = x; |
|
32 |
Y1 = y; |
|
33 |
} |
|
34 |
} |
|
35 |
public string LOCATION_2 |
|
36 |
{ |
|
37 |
get |
|
38 |
{ |
|
39 |
return _LOCATION_2; |
|
40 |
} |
|
41 |
set |
|
42 |
{ |
|
43 |
_LOCATION_2 = value; |
|
44 |
double x = 0; |
|
45 |
double y = 0; |
|
46 |
Converter.SPPID.Util.SPPIDUtil.ConvertPointBystring(_LOCATION_2, ref x, ref y); |
|
47 |
X2 = x; |
|
48 |
Y2 = y; |
|
49 |
} |
|
50 |
} |
|
51 |
public SPPIDSymbolInfo SPPID { get => _SPPID; set => _SPPID = value; } |
|
52 |
public double X1 { get; set; } |
|
53 |
public double X2 { get; set; } |
|
54 |
public double Y1 { get; set; } |
|
55 |
public double Y2 { get; set; } |
|
56 |
public SPPIDEtcLocationInfo SPPIDGraphicLocation { get; set; } |
|
57 |
} |
|
58 |
} |
|
59 |
|
DTI_PID/SPPIDConverter/BaseModel/LineNumber.cs | ||
---|---|---|
75 | 75 |
public double Y1 { get; set; } |
76 | 76 |
public double Y2 { get; set; } |
77 | 77 |
|
78 |
public SPPIDLabelLocationInfo SPPIDLabelLocation { get; set; }
|
|
78 |
public SPPIDEtcLocationInfo SPPIDLabelLocation { get; set; }
|
|
79 | 79 |
} |
80 | 80 |
} |
DTI_PID/SPPIDConverter/BaseModel/Note.cs | ||
---|---|---|
90 | 90 |
public double X2 { get; set; } |
91 | 91 |
public double Y1 { get; set; } |
92 | 92 |
public double Y2 { get; set; } |
93 |
public SPPIDLabelLocationInfo SPPIDLabelLocation { get; set; }
|
|
93 |
public SPPIDEtcLocationInfo SPPIDLabelLocation { get; set; }
|
|
94 | 94 |
public string OWNER { get => _OWNER; set => _OWNER = value; } |
95 | 95 |
} |
96 | 96 |
} |
DTI_PID/SPPIDConverter/BaseModel/SPPID/SPPIDLabelLocationInfo.cs | ||
---|---|---|
6 | 6 |
|
7 | 7 |
namespace Converter.BaseModel |
8 | 8 |
{ |
9 |
public class SPPIDLabelLocationInfo
|
|
9 |
public class SPPIDEtcLocationInfo
|
|
10 | 10 |
{ |
11 | 11 |
public double X1 { get; set; } |
12 | 12 |
public double X2 { get; set; } |
DTI_PID/SPPIDConverter/BaseModel/Text.cs | ||
---|---|---|
93 | 93 |
public double X2 { get; set; } |
94 | 94 |
public double Y1 { get; set; } |
95 | 95 |
public double Y2 { get; set; } |
96 |
public SPPIDLabelLocationInfo SPPIDLabelLocation { get; set; }
|
|
96 |
public SPPIDEtcLocationInfo SPPIDLabelLocation { get; set; }
|
|
97 | 97 |
} |
98 | 98 |
} |
DTI_PID/SPPIDConverter/ConverterDocking.cs | ||
---|---|---|
148 | 148 |
{ |
149 | 149 |
modeling.DocumentLabelText = string.Format("Drawing Name : {0} ({1}/{2})", document.DrawingName, i + 1, converterForm.Documents.Count); |
150 | 150 |
modeling.Run(); |
151 |
|
|
152 |
List<string> endLine = new List<string>(); |
|
153 |
Placement placement = new Placement(); |
|
154 |
LMADataSource dataSource = placement.PIDDataSource; |
|
155 |
|
|
156 |
foreach (var lineNumber in document.LINENUMBERS) |
|
157 |
{ |
|
158 |
foreach (LineRun run in lineNumber.RUNS) |
|
159 |
{ |
|
160 |
foreach (var item in run.RUNITEMS) |
|
161 |
{ |
|
162 |
if (item.GetType() == typeof(Line)) |
|
163 |
{ |
|
164 |
Line line = item as Line; |
|
165 |
if (line != null && !endLine.Contains(line.SPPID.ModelItemId)) |
|
166 |
{ |
|
167 |
LMModelItem _LMModelItem = dataSource.GetModelItem(line.SPPID.ModelItemId); |
|
168 |
if (_LMModelItem != null && _LMModelItem.get_ItemStatus() == "Active") |
|
169 |
{ |
|
170 |
foreach (var attribute in lineNumber.ATTRIBUTES) |
|
171 |
{ |
|
172 |
LineNumberMapping mapping = document.LineNumberMappings.Find(x => x.UID == attribute.UID); |
|
173 |
if (mapping != null && !string.IsNullOrEmpty(attribute.VALUE) && attribute.VALUE != "None" && mapping.SPPIDATTRIBUTENAME == "PlantGroup.Name") |
|
174 |
{ |
|
175 |
LMAAttribute _LMAAttribute = _LMModelItem.Attributes[mapping.SPPIDATTRIBUTENAME]; |
|
176 |
if (_LMAAttribute != null) |
|
177 |
{ |
|
178 |
if (DBNull.Value.Equals(_LMAAttribute.get_Value())) |
|
179 |
_LMAAttribute.set_Value(attribute.VALUE); |
|
180 |
else if (_LMAAttribute.get_Value() != attribute.VALUE) |
|
181 |
_LMAAttribute.set_Value(attribute.VALUE); |
|
182 |
} |
|
183 |
} |
|
184 |
} |
|
185 |
_LMModelItem.Commit(); |
|
186 |
} |
|
187 |
if (_LMModelItem != null) |
|
188 |
ReleaseCOMObjects(_LMModelItem); |
|
189 |
endLine.Add(line.SPPID.ModelItemId); |
|
190 |
} |
|
191 |
} |
|
192 |
} |
|
193 |
} |
|
194 |
} |
|
195 |
|
|
196 |
ReleaseCOMObjects(dataSource); |
|
197 |
ReleaseCOMObjects(placement); |
|
198 | 151 |
} |
199 | 152 |
} |
200 | 153 |
} |
... | ... | |
1142 | 1095 |
#endregion |
1143 | 1096 |
|
1144 | 1097 |
#region SpecBreak |
1098 |
//private void btnSpecBreakRelocation_Click(object sender, EventArgs e) |
|
1099 |
//{ |
|
1100 |
// dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application"); |
|
1101 |
// WrapperApplication wApp = new WrapperApplication(dApplication.Application); |
|
1102 |
// application = wApp.RADApplication; |
|
1103 |
|
|
1104 |
// int count = application.ActiveSelectSet.Count; |
|
1105 |
// int dependencyCount = 0; |
|
1106 |
// foreach (var item in application.ActiveSelectSet) |
|
1107 |
// if (item.GetType() == typeof(DependencyObject)) |
|
1108 |
// dependencyCount++; |
|
1109 |
|
|
1110 |
// if (count > 0 && application.ActiveSelectSet[0].GetType() == typeof(DependencyObject)) |
|
1111 |
// { |
|
1112 |
// MessageBox.Show("First selected item is DependencyObject!\r\nPlease move symbol", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
1113 |
// return; |
|
1114 |
// } |
|
1115 |
|
|
1116 |
// if ((count == 3 || count == 4) && application.ActiveSelectSet[0].GetType() == typeof(Symbol2d) && |
|
1117 |
// (dependencyCount == 2 || dependencyCount == 3)) |
|
1118 |
// { |
|
1119 |
// Symbol2d symbol = application.ActiveSelectSet[0] as Symbol2d; |
|
1120 |
|
|
1121 |
// if (!symbol.DefinitionName.Contains(@"Design\Annotation\Graphics\")) |
|
1122 |
// { |
|
1123 |
// MessageBox.Show("Select SpecBreak!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
1124 |
// return; |
|
1125 |
// } |
|
1126 |
|
|
1127 |
// DependencyObject dependency1 = application.ActiveSelectSet[1] as DependencyObject; |
|
1128 |
// DependencyObject dependency2 = application.ActiveSelectSet[2] as DependencyObject; |
|
1129 |
// DependencyObject dependency3 = null; |
|
1130 |
// if (count == 4) |
|
1131 |
// dependency3 = application.ActiveSelectSet[3] as DependencyObject; |
|
1132 |
|
|
1133 |
// application.ActiveSelectSet.RemoveAll(); |
|
1134 |
// double angle = symbol.Angle; |
|
1135 |
// if (symbol.GetTransform().HasReflection) |
|
1136 |
// angle += Math.PI; |
|
1137 |
|
|
1138 |
// double degree = double.NaN; |
|
1139 |
// if (angle > -0.1 && angle < 0.1) |
|
1140 |
// degree = 0; |
|
1141 |
// else if (angle > 1.56 && angle < 1.58) |
|
1142 |
// degree = 90; |
|
1143 |
// else if (angle > 3.13 && angle < 3.15) |
|
1144 |
// degree = 180; |
|
1145 |
// else if (angle > 4.7 && angle < 4.72) |
|
1146 |
// degree = 270; |
|
1147 |
// else if (angle > 6.27 && angle < 6.29) |
|
1148 |
// degree = 0; |
|
1149 |
// else if (angle > -1.58 && angle < -1.56) |
|
1150 |
// degree = 270; |
|
1151 |
// else if (angle > -3.15 && angle < -3.13) |
|
1152 |
// degree = 180; |
|
1153 |
// else |
|
1154 |
// throw new Exception("Check Angle"); |
|
1155 |
|
|
1156 |
|
|
1157 |
// double originX, originY; |
|
1158 |
// symbol.GetOrigin(out originX, out originY); |
|
1159 |
|
|
1160 |
// double crossX = 0; |
|
1161 |
// double crossY = 0; |
|
1162 |
// double topX = 0; |
|
1163 |
// double topY = 0; |
|
1164 |
// foreach (var item in symbol.DrawingObjects) |
|
1165 |
// { |
|
1166 |
// Line2d line2d = item as Line2d; |
|
1167 |
// if (line2d != null) |
|
1168 |
// { |
|
1169 |
// double x1, y1, x2, y2; |
|
1170 |
// line2d.GetStartPoint(out x1, out y1); |
|
1171 |
// line2d.GetEndPoint(out x2, out y2); |
|
1172 |
// SlopeType slopeType = SPPIDUtil.CalcSlope(x1, y1, x2, y2, 0.1); |
|
1173 |
|
|
1174 |
// if (slopeType == SlopeType.HORIZONTAL) |
|
1175 |
// { |
|
1176 |
// if (crossY == 0) |
|
1177 |
// crossY = y1; |
|
1178 |
// else |
|
1179 |
// crossY = (crossY + y1) / 2; |
|
1180 |
|
|
1181 |
// switch (degree) |
|
1182 |
// { |
|
1183 |
// case 90: |
|
1184 |
// if (topX == 0) |
|
1185 |
// topX = Math.Min(x1, x2); |
|
1186 |
// else |
|
1187 |
// topX = Math.Min(topX, Math.Min(x1, x2)); |
|
1188 |
// break; |
|
1189 |
// case 270: |
|
1190 |
// if (topX == 0) |
|
1191 |
// topX = Math.Max(x1, x2); |
|
1192 |
// else |
|
1193 |
// topX = Math.Max(topX, Math.Max(x1, x2)); |
|
1194 |
// break; |
|
1195 |
// default: |
|
1196 |
// break; |
|
1197 |
// } |
|
1198 |
// } |
|
1199 |
// else if (slopeType == SlopeType.VERTICAL) |
|
1200 |
// { |
|
1201 |
// if (crossX == 0) |
|
1202 |
// crossX = x1; |
|
1203 |
// else |
|
1204 |
// crossX = (crossX + x1) / 2; |
|
1205 |
|
|
1206 |
// switch (degree) |
|
1207 |
// { |
|
1208 |
// case 0: |
|
1209 |
// if (topY == 0) |
|
1210 |
// topY = Math.Max(y1, y2); |
|
1211 |
// else |
|
1212 |
// topY = Math.Max(topY, Math.Max(y1, y2)); |
|
1213 |
// break; |
|
1214 |
// case 180: |
|
1215 |
// if (topY == 0) |
|
1216 |
// topY = Math.Min(y1, y2); |
|
1217 |
// else |
|
1218 |
// topY = Math.Min(topY, Math.Min(y1, y2)); |
|
1219 |
// break; |
|
1220 |
// default: |
|
1221 |
// break; |
|
1222 |
// } |
|
1223 |
// } |
|
1224 |
// } |
|
1225 |
// } |
|
1226 |
// switch (degree) |
|
1227 |
// { |
|
1228 |
// case 0: |
|
1229 |
// crossX = originX; |
|
1230 |
// topX = crossX; |
|
1231 |
// break; |
|
1232 |
// case 90: |
|
1233 |
// crossY = originY; |
|
1234 |
// topY = crossY; |
|
1235 |
// break; |
|
1236 |
// case 180: |
|
1237 |
// crossX = originX; |
|
1238 |
// topX = crossX; |
|
1239 |
// break; |
|
1240 |
// case 270: |
|
1241 |
// crossY = originY; |
|
1242 |
// topY = crossY; |
|
1243 |
// break; |
|
1244 |
// default: |
|
1245 |
// break; |
|
1246 |
// } |
|
1247 |
|
|
1248 |
// SpecBreakRelocation(degree, originX, originY, crossX, crossY, topX, topY, dependency1, dependency2, dependency3); |
|
1249 |
// SetSpecBreakParameters(symbol, dependency1, dependency2, degree); |
|
1250 |
// } |
|
1251 |
// else |
|
1252 |
// { |
|
1253 |
// MessageBox.Show("Check Rule!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
1254 |
// } |
|
1255 |
//} |
|
1145 | 1256 |
private void btnSpecBreakRelocation_Click(object sender, EventArgs e) |
1146 | 1257 |
{ |
1147 | 1258 |
dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application"); |
1148 | 1259 |
WrapperApplication wApp = new WrapperApplication(dApplication.Application); |
1149 | 1260 |
application = wApp.RADApplication; |
1150 | 1261 |
|
1151 |
int count = application.ActiveSelectSet.Count; |
|
1152 |
int dependencyCount = 0; |
|
1153 |
foreach (var item in application.ActiveSelectSet) |
|
1154 |
if (item.GetType() == typeof(DependencyObject)) |
|
1155 |
dependencyCount++; |
|
1156 |
|
|
1157 |
if (count > 0 && application.ActiveSelectSet[0].GetType() == typeof(DependencyObject)) |
|
1158 |
{ |
|
1159 |
MessageBox.Show("First selected item is DependencyObject!\r\nPlease move symbol", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
1160 |
return; |
|
1161 |
} |
|
1162 |
|
|
1163 |
if ((count == 3 || count == 4) && application.ActiveSelectSet[0].GetType() == typeof(Symbol2d) && |
|
1164 |
(dependencyCount == 2 || dependencyCount == 3)) |
|
1262 |
Ingr.RAD2D.SmartFrame2d borderFrame = application.ActiveDocument.ActiveSheet.SmartFrames2d[0]; |
|
1263 |
string styleName = borderFrame.Style.Name; |
|
1264 |
// |
|
1265 |
foreach (var item in application.ActiveDocument.SmartFrame2dStyles) |
|
1165 | 1266 |
{ |
1166 |
Symbol2d symbol = application.ActiveSelectSet[0] as Symbol2d; |
|
1167 |
|
|
1168 |
if (!symbol.DefinitionName.Contains(@"Design\Annotation\Graphics\")) |
|
1169 |
{ |
|
1170 |
MessageBox.Show("Select SpecBreak!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); |
|
1171 |
return; |
|
1172 |
} |
|
1173 |
|
|
1174 |
DependencyObject dependency1 = application.ActiveSelectSet[1] as DependencyObject; |
|
1175 |
DependencyObject dependency2 = application.ActiveSelectSet[2] as DependencyObject; |
|
1176 |
DependencyObject dependency3 = null; |
|
1177 |
if (count == 4) |
|
1178 |
dependency3 = application.ActiveSelectSet[3] as DependencyObject; |
|
1179 |
|
|
1180 |
application.ActiveSelectSet.RemoveAll(); |
|
1181 |
double angle = symbol.Angle; |
|
1182 |
if (symbol.GetTransform().HasReflection) |
|
1183 |
angle += Math.PI; |
|
1184 |
|
|
1185 |
double degree = double.NaN; |
|
1186 |
if (angle > -0.1 && angle < 0.1) |
|
1187 |
degree = 0; |
|
1188 |
else if (angle > 1.56 && angle < 1.58) |
|
1189 |
degree = 90; |
|
1190 |
else if (angle > 3.13 && angle < 3.15) |
|
1191 |
degree = 180; |
|
1192 |
else if (angle > 4.7 && angle < 4.72) |
|
1193 |
degree = 270; |
|
1194 |
else if (angle > 6.27 && angle < 6.29) |
|
1195 |
degree = 0; |
|
1196 |
else if (angle > -1.58 && angle < -1.56) |
|
1197 |
degree = 270; |
|
1198 |
else if (angle > -3.15 && angle < -3.13) |
|
1199 |
degree = 180; |
|
1200 |
else |
|
1201 |
throw new Exception("Check Angle"); |
|
1202 |
|
|
1203 |
|
|
1204 |
double originX, originY; |
|
1205 |
symbol.GetOrigin(out originX, out originY); |
|
1206 |
|
|
1207 |
double crossX = 0; |
|
1208 |
double crossY = 0; |
|
1209 |
double topX = 0; |
|
1210 |
double topY = 0; |
|
1211 |
foreach (var item in symbol.DrawingObjects) |
|
1212 |
{ |
|
1213 |
Line2d line2d = item as Line2d; |
|
1214 |
if (line2d != null) |
|
1215 |
{ |
|
1216 |
double x1, y1, x2, y2; |
|
1217 |
line2d.GetStartPoint(out x1, out y1); |
|
1218 |
line2d.GetEndPoint(out x2, out y2); |
|
1219 |
SlopeType slopeType = SPPIDUtil.CalcSlope(x1, y1, x2, y2, 0.1); |
|
1220 |
|
|
1221 |
if (slopeType == SlopeType.HORIZONTAL) |
|
1222 |
{ |
|
1223 |
if (crossY == 0) |
|
1224 |
crossY = y1; |
|
1225 |
else |
|
1226 |
crossY = (crossY + y1) / 2; |
|
1227 |
|
|
1228 |
switch (degree) |
|
1229 |
{ |
|
1230 |
case 90: |
|
1231 |
if (topX == 0) |
|
1232 |
topX = Math.Min(x1, x2); |
|
1233 |
else |
|
1234 |
topX = Math.Min(topX, Math.Min(x1, x2)); |
|
1235 |
break; |
|
1236 |
case 270: |
|
1237 |
if (topX == 0) |
|
1238 |
topX = Math.Max(x1, x2); |
|
1239 |
else |
|
1240 |
topX = Math.Max(topX, Math.Max(x1, x2)); |
|
1241 |
break; |
|
1242 |
default: |
|
1243 |
break; |
|
1244 |
} |
|
1245 |
} |
|
1246 |
else if (slopeType == SlopeType.VERTICAL) |
|
1247 |
{ |
|
1248 |
if (crossX == 0) |
|
1249 |
crossX = x1; |
|
1250 |
else |
|
1251 |
crossX = (crossX + x1) / 2; |
|
1252 |
|
|
1253 |
switch (degree) |
|
1254 |
{ |
|
1255 |
case 0: |
|
1256 |
if (topY == 0) |
|
1257 |
topY = Math.Max(y1, y2); |
|
1258 |
else |
|
1259 |
topY = Math.Max(topY, Math.Max(y1, y2)); |
|
1260 |
break; |
|
1261 |
case 180: |
|
1262 |
if (topY == 0) |
|
1263 |
topY = Math.Min(y1, y2); |
|
1264 |
else |
|
1265 |
topY = Math.Min(topY, Math.Min(y1, y2)); |
|
1266 |
break; |
|
1267 |
default: |
|
1268 |
break; |
|
1269 |
} |
|
1270 |
} |
|
1271 |
} |
|
1272 |
} |
|
1273 |
switch (degree) |
|
1274 |
{ |
|
1275 |
case 0: |
|
1276 |
crossX = originX; |
|
1277 |
topX = crossX; |
|
1278 |
break; |
|
1279 |
case 90: |
|
1280 |
crossY = originY; |
|
1281 |
topY = crossY; |
|
1282 |
break; |
|
1283 |
case 180: |
|
1284 |
crossX = originX; |
|
1285 |
topX = crossX; |
|
1286 |
break; |
|
1287 |
case 270: |
|
1288 |
crossY = originY; |
|
1289 |
topY = crossY; |
|
1290 |
break; |
|
1291 |
default: |
|
1292 |
break; |
|
1293 |
} |
|
1294 |
|
|
1295 |
SpecBreakRelocation(degree, originX, originY, crossX, crossY, topX, topY, dependency1, dependency2, dependency3); |
|
1296 |
SetSpecBreakParameters(symbol, dependency1, dependency2, degree); |
|
1267 |
string dd = item.Name; |
|
1297 | 1268 |
} |
1298 |
else
|
|
1269 |
foreach (var item in application.ActiveDocument.ActiveSheet.SmartFrames2d)
|
|
1299 | 1270 |
{ |
1300 |
MessageBox.Show("Check Rule!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
1271 |
var aa = item.Style;
|
|
1301 | 1272 |
} |
1302 | 1273 |
} |
1303 | 1274 |
private void SetSpecBreakParameters(Symbol2d symbol, DependencyObject dependency1, DependencyObject dependency2, double degree) |
DTI_PID/SPPIDConverter/SPPIDConverter.csproj | ||
---|---|---|
152 | 152 |
<Compile Include="Form\SymmetryForm.Designer.cs"> |
153 | 153 |
<DependentUpon>SymmetryForm.cs</DependentUpon> |
154 | 154 |
</Compile> |
155 |
<Compile Include="BaseModel\Graphic.cs" /> |
|
155 | 156 |
<Compile Include="License.cs" /> |
156 | 157 |
<Compile Include="OPC\AutoModeling_OPC.cs" /> |
157 | 158 |
<Compile Include="BaseModel\ChildSymbol.cs" /> |
DTI_PID/SPPIDConverter/SPPIDModel/SPPID_Document.cs | ||
---|---|---|
90 | 90 |
if (item.SPPID == null) |
91 | 91 |
item.SPPID = new SPPIDSymbolInfo(); |
92 | 92 |
} |
93 |
|
|
94 |
foreach (var item in Graphics) |
|
95 |
{ |
|
96 |
if (item.SPPID == null) |
|
97 |
item.SPPID = new SPPIDSymbolInfo(); |
|
98 |
} |
|
93 | 99 |
} |
94 | 100 |
|
95 | 101 |
public void SetSPPIDLocation(double SPPIDDocumentX, double SPPIDDocumentY) |
... | ... | |
167 | 173 |
item.SPPID.ORIGINAL_X = x; |
168 | 174 |
item.SPPID.ORIGINAL_Y = y; |
169 | 175 |
|
170 |
item.SPPIDLabelLocation = new SPPIDLabelLocationInfo();
|
|
176 |
item.SPPIDLabelLocation = new SPPIDEtcLocationInfo();
|
|
171 | 177 |
double x1 = item.X1; |
172 | 178 |
double y1 = item.Y1; |
173 | 179 |
double x2 = item.X2; |
... | ... | |
189 | 195 |
item.SPPID.ORIGINAL_X = x; |
190 | 196 |
item.SPPID.ORIGINAL_Y = y; |
191 | 197 |
|
192 |
item.SPPIDLabelLocation = new SPPIDLabelLocationInfo();
|
|
198 |
item.SPPIDLabelLocation = new SPPIDEtcLocationInfo();
|
|
193 | 199 |
double x1 = item.X1; |
194 | 200 |
double y1 = item.Y1; |
195 | 201 |
double x2 = item.X2; |
... | ... | |
211 | 217 |
item.SPPID.ORIGINAL_X = x; |
212 | 218 |
item.SPPID.ORIGINAL_Y = y; |
213 | 219 |
|
214 |
item.SPPIDLabelLocation = new SPPIDLabelLocationInfo();
|
|
220 |
item.SPPIDLabelLocation = new SPPIDEtcLocationInfo();
|
|
215 | 221 |
double x1 = item.X1; |
216 | 222 |
double y1 = item.Y1; |
217 | 223 |
double x2 = item.X2; |
... | ... | |
232 | 238 |
item.SPPID.ORIGINAL_X = x; |
233 | 239 |
item.SPPID.ORIGINAL_Y = y; |
234 | 240 |
} |
241 |
|
|
242 |
foreach (var item in Graphics) |
|
243 |
{ |
|
244 |
item.SPPIDGraphicLocation = new SPPIDEtcLocationInfo(); |
|
245 |
double x1 = item.X1; |
|
246 |
double y1 = item.Y1; |
|
247 |
double x2 = item.X2; |
|
248 |
double y2 = item.Y2; |
|
249 |
SPPIDUtil.ConvertSPPIDPoint(ref x1, ref y1, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY); |
|
250 |
SPPIDUtil.ConvertSPPIDPoint(ref x2, ref y2, SIZE_WIDTH, SIZE_HEIGHT, SPPIDDocumentX, SPPIDDocumentY); |
|
251 |
item.SPPIDGraphicLocation.X1 = Math.Min(x1, x2); |
|
252 |
item.SPPIDGraphicLocation.Y1 = Math.Min(y1, y2); |
|
253 |
item.SPPIDGraphicLocation.X2 = Math.Max(x1, x2); |
|
254 |
item.SPPIDGraphicLocation.Y2 = Math.Max(y1, y2); |
|
255 |
} |
|
235 | 256 |
} |
236 | 257 |
|
237 | 258 |
/// <summary> |
... | ... | |
565 | 586 |
int failSymbolCnt = 0; |
566 | 587 |
int failLineCnt = 0; |
567 | 588 |
int failTextCnt = 0; |
589 |
int failGraphicCnt = 0; |
|
568 | 590 |
foreach (var item in Equipments) |
569 | 591 |
{ |
570 | 592 |
if (string.IsNullOrEmpty(item.SPPID.RepresentationId)) |
... | ... | |
635 | 657 |
failSymbolCnt++; |
636 | 658 |
} |
637 | 659 |
} |
660 |
foreach (var item in Graphics) |
|
661 |
{ |
|
662 |
if (string.IsNullOrEmpty(item.SPPID.RepresentationId)) |
|
663 |
{ |
|
664 |
sb.AppendLine("Fail Grphic Modeling UID : " + item.UID); |
|
665 |
failGraphicCnt++; |
|
666 |
} |
|
667 |
} |
|
638 | 668 |
sb.AppendLine("End Modeling Result"); |
639 | 669 |
Log.Write(sb.ToString()); |
640 | 670 |
|
641 |
int allSymbol = Equipments.Count + SYMBOLS.Count + EndBreaks.Count + SpecBreaks.Count; |
|
671 |
int allSymbol = Equipments.Count + SYMBOLS.Count + EndBreaks.Count + SpecBreaks.Count + Graphics.Count;
|
|
642 | 672 |
|
643 | 673 |
Log.Write("Success Symbol Modeling : " + (allSymbol - failSymbolCnt)); |
644 | 674 |
Log.Write("Fail Symbol Modeling : " + failSymbolCnt); |
... | ... | |
646 | 676 |
Log.Write("Fail Line Modeling : " + failLineCnt); |
647 | 677 |
Log.Write("Success Text/Note Modeling : " + (TEXTINFOS.Count + NOTES.Count - failTextCnt)); |
648 | 678 |
Log.Write("Fail Text/Note Modeling : " + failTextCnt); |
679 |
Log.Write("Success Graphic Modeling : " + (Graphics.Count - failGraphicCnt)); |
|
680 |
Log.Write("Fail Graphic Modeling : " + failGraphicCnt); |
|
649 | 681 |
} |
650 | 682 |
|
651 | 683 |
private void loop(ChildSymbol childLoop, Symbol item, StringBuilder sb) |
내보내기 Unified diff