개정판 5dfb8a24
dev issue #000 : ID2의 LineNumber 기준으로 모델링 초기 시작
Change-Id: I1aa4d167b19893ad7aadbe06363444a903a61590
DTI_PID/SPPIDConverter/AutoModeling.cs | ||
---|---|---|
11 | 11 |
using Converter.SPPID.Util; |
12 | 12 |
using Converter.SPPID.DB; |
13 | 13 |
|
14 |
using System.Windows; |
|
14 | 15 |
using System.Threading; |
16 |
using System.Drawing; |
|
15 | 17 |
using Microsoft.VisualBasic; |
16 | 18 |
using Newtonsoft.Json; |
17 | 19 |
|
... | ... | |
19 | 21 |
{ |
20 | 22 |
public class AutoModeling |
21 | 23 |
{ |
24 |
Placement _placement = new Placement(); |
|
22 | 25 |
SPPID_Document document; |
23 | 26 |
public AutoModeling(SPPID_Document document) |
24 | 27 |
{ |
... | ... | |
27 | 30 |
|
28 | 31 |
public void Run() |
29 | 32 |
{ |
30 |
dynamic application = Interaction.GetObject("", "PIDAutomation.Application"); |
|
31 |
dynamic newDrawing = application.Drawings.Add(document.Unit, document.Template, document.DrawingNumber, document.DrawingName); |
|
32 |
application.ActiveWindow.Fit(); |
|
33 |
Thread.Sleep(100); |
|
34 |
application.ActiveWindow.Zoom = 60; |
|
35 |
Thread.Sleep(100); |
|
33 |
//dynamic application = Interaction.GetObject("", "PIDAutomation.Application"); |
|
34 |
//dynamic newDrawing = application.Drawings.Add(document.Unit, document.Template, document.DrawingNumber, document.DrawingName); |
|
35 |
//application.ActiveWindow.Fit(); |
|
36 |
//Thread.Sleep(100); |
|
37 |
//application.ActiveWindow.Zoom = 60; |
|
38 |
//Thread.Sleep(100); |
|
39 |
|
|
40 |
|
|
41 |
foreach (LineNumber lineNumber in document.LINENUMBERS) |
|
42 |
{ |
|
43 |
foreach (LineNumberRun run in lineNumber.RUNS) |
|
44 |
{ |
|
45 |
// Run 별로 Modeling |
|
46 |
Symbol prevSymbol = null; |
|
47 |
object prevItem = null; |
|
48 |
foreach (object item in run.RUNITEMS) |
|
49 |
{ |
|
50 |
if (item.GetType() == typeof(Symbol)) |
|
51 |
{ |
|
52 |
Symbol symbol = item as Symbol; |
|
53 |
SymbolModeling(symbol, prevSymbol); |
|
54 |
//// 바로 전 아이템이 Symbol |
|
55 |
//if (prevItem != null && prevItem.GetType() == typeof(Symbol)) |
|
56 |
//{ |
|
57 |
|
|
58 |
//} |
|
59 |
//// 바로 전 아이템 Line 예전 Item 이 Symbol |
|
60 |
//else if (prevItem != null && prevSymbol != null) |
|
61 |
//{ |
|
62 |
|
|
63 |
//} |
|
64 |
prevSymbol = symbol; |
|
65 |
} |
|
66 |
else if (item.GetType() == typeof(Line)) |
|
67 |
{ |
|
68 |
Line line = item as Line; |
|
69 |
LineModeling(item as Line); |
|
70 |
} |
|
71 |
|
|
72 |
prevItem = item; |
|
73 |
} |
|
74 |
|
|
75 |
|
|
76 |
|
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 |
|
|
81 |
ReleaseCOMObjects(_placement); |
|
82 |
System.Windows.Forms.MessageBox.Show("end"); |
|
83 |
} |
|
36 | 84 |
|
85 |
private void TestSource() |
|
86 |
{ |
|
37 | 87 |
|
38 | 88 |
} |
39 | 89 |
|
40 |
|
|
41 |
private void SymbolModeling(Symbol symbol) |
|
90 |
private void SymbolModeling(Symbol symbol, Symbol prevSymbol) |
|
42 | 91 |
{ |
43 |
|
|
92 |
LMSymbol _LMSymbol = null; |
|
93 |
|
|
94 |
string mappingPath = symbol.SPPID.MAPPINGNAME; |
|
95 |
double x = symbol.SPPID.LOCATION_X; |
|
96 |
double y = symbol.SPPID.LOCATION_Y; |
|
97 |
int mirror = 0; |
|
98 |
double angle = symbol.ANGLE; |
|
99 |
LMSymbol _TargetItem = null; |
|
100 |
|
|
101 |
if (prevSymbol != null) |
|
102 |
{ |
|
103 |
SlopeType slopeType = SPPIDUtil.CalcSlope(symbol.SPPID.LOCATION_X, symbol.SPPID.LOCATION_Y, prevSymbol.SPPID.LOCATION_X, prevSymbol.SPPID.LOCATION_Y); |
|
104 |
if (slopeType == SlopeType.HORIZONTAL) |
|
105 |
{ |
|
106 |
|
|
107 |
} |
|
108 |
else if (slopeType == SlopeType.VERTICAL) |
|
109 |
{ |
|
110 |
|
|
111 |
} |
|
112 |
} |
|
113 |
else |
|
114 |
{ |
|
115 |
|
|
116 |
} |
|
117 |
|
|
118 |
if (_TargetItem == null) |
|
119 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle); |
|
120 |
else |
|
121 |
{ |
|
122 |
_LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem); |
|
123 |
ReleaseCOMObjects(_TargetItem); |
|
124 |
} |
|
125 |
|
|
126 |
if (_LMSymbol != null) |
|
127 |
{ |
|
128 |
|
|
129 |
} |
|
130 |
|
|
131 |
ReleaseCOMObjects(_LMSymbol); |
|
44 | 132 |
} |
45 | 133 |
|
46 | 134 |
private void LineModeling(Line line) |
47 | 135 |
{ |
48 |
|
|
136 |
object DrwingID = "0"; |
|
137 |
_LMAItem _LMAItem = _placement.PIDCreateItem(line.SPPID.MAPPINGNAME, ref DrwingID); |
|
138 |
PlaceRunInputs placeRunInputs = new PlaceRunInputs(); |
|
139 |
placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y); |
|
140 |
placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y); |
|
141 |
|
|
142 |
LMConnector lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs); |
|
143 |
lMConnector.Commit(); |
|
144 |
|
|
145 |
ReleaseCOMObjects(lMConnector); |
|
146 |
ReleaseCOMObjects(placeRunInputs); |
|
147 |
ReleaseCOMObjects(_LMAItem); |
|
49 | 148 |
} |
50 | 149 |
|
51 | 150 |
private void LineNumberModeling(LineNumber lineNumber) |
... | ... | |
63 | 162 |
|
64 | 163 |
} |
65 | 164 |
|
165 |
|
|
166 |
public void ReleaseCOMObjects(params object[] objVars) |
|
167 |
{ |
|
168 |
int intNewRefCount = 0; |
|
169 |
foreach (object obj in objVars) |
|
170 |
{ |
|
171 |
if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj)) |
|
172 |
intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj); |
|
173 |
} |
|
174 |
} |
|
66 | 175 |
} |
67 | 176 |
} |
내보내기 Unified diff