프로젝트

일반

사용자정보

개정판 f1c9dbaa

IDf1c9dbaa013712d490f6dc2447174205610e4966
상위 7af9b30c
하위 33ed83c7, 809a7640

gaqhf 이(가) 5년 이상 전에 추가함

dev issue #000 : ID2 Line Number 기준 모델링 및 Equipment, EndBreak 구별

Change-Id: Ifd40906e19bbee1579306fb7620cc739d4268916

차이점 보기:

DTI_PID/SPPIDConverter/AutoModeling.cs
22 22
    public class AutoModeling
23 23
    {
24 24
        Placement _placement = new Placement();
25

  
25 26
        SPPID_Document document;
27

  
28

  
26 29
        public AutoModeling(SPPID_Document document)
27 30
        {
28 31
            this.document = document;
29 32
        }
30 33

  
34

  
35

  
31 36
        public void Run()
32 37
        {
33 38
            //dynamic application = Interaction.GetObject("", "PIDAutomation.Application");
......
44 49
                {
45 50
                    // Run 별로 Modeling
46 51
                    Symbol prevSymbol = null;
52
                    object prevItem = null;
47 53
                    // Symbol 먼저
48 54
                    foreach (var item in run.RUNITEMS)
49 55
                    {
50 56
                        if (item.GetType() == typeof(Symbol))
51 57
                        {
52 58
                            Symbol symbol = item as Symbol;
53
                            SymbolModeling(symbol, prevSymbol);
59
                            SymbolModeling(symbol, prevSymbol, prevItem);
54 60
                            prevSymbol = symbol;
55 61
                        }
62
                        prevItem = item;
56 63
                    }
57 64

  
58
                    object prevItem = null;
65

  
66
                    Line prevLine = null;
59 67
                    prevSymbol = null;
68
                    prevItem = null;
69
                    List<Line> lines = new List<Line>();
60 70
                    foreach (var item in run.RUNITEMS)
61 71
                    {
72
                        // Line일 경우
62 73
                        if (item.GetType() == typeof(Line))
63 74
                        {
64
                            
75
                            Line line = item as Line;
76
                            if (prevLine == null)
77
                                lines.Add(line);
78
                            else if (prevLine != null)
79
                            {
80
                                if (prevLine.SPPID.MAPPINGNAME == line.SPPID.MAPPINGNAME)
81
                                    lines.Add(line);
82
                                else
83
                                {
84
                                    LineModeling(lines);
85
                                    lines.Clear();
86
                                    lines.Add(line);
87
                                }
88
                            }
89

  
90
                            prevLine = line;
91
                        }
92
                        // Symbol 일 경우
93
                        else if (item.GetType() == typeof(Symbol))
94
                        {
95
                            if (lines.Count > 0)
96
                            {
97
                                LineModeling(lines);
98
                                lines.Clear();
99
                            }
65 100
                        }
66 101

  
67 102
                        prevItem = item;
68 103
                    }
69 104

  
70

  
105
                    if (lines.Count > 0)
106
                        LineModeling(lines);
71 107
                }
72 108
            }
73 109

  
......
82 118

  
83 119
        }
84 120

  
85
        private void SymbolModeling(Symbol symbol, Symbol prevSymbol)
121
        private void SymbolModeling(Symbol symbol, Symbol prevSymbol, object prevItem)
86 122
        {
87 123
            LMSymbol _LMSymbol = null;
124
            LMADataSource dataSource = _placement.PIDDataSource;
88 125

  
89 126
            string mappingPath = symbol.SPPID.MAPPINGNAME;
90 127
            double x = symbol.SPPID.ORIGINAL_X;
......
93 130
            double angle = symbol.ANGLE;
94 131
            LMSymbol _TargetItem = null;
95 132

  
133
            if (prevItem != null && prevItem.GetType() == typeof(Symbol))
134
                _TargetItem = dataSource.GetSymbol(((Symbol)prevItem).SPPID.RepresentationId);
135

  
96 136
            if (prevSymbol != null)
97 137
            {
98 138
                SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, prevSymbol.SPPID.ORIGINAL_X, prevSymbol.SPPID.ORIGINAL_Y);
99
                LMADataSource dataSource = _placement.PIDDataSource;
100
                LMSymbol prevLMSymbol = dataSource.GetSymbol(prevSymbol.SPPID.ITEMOBJECT);
139
                LMSymbol prevLMSymbol = dataSource.GetSymbol(prevSymbol.SPPID.RepresentationId);
101 140
                double prevX = prevLMSymbol.get_XCoordinate();
102 141
                double prevY = prevLMSymbol.get_YCoordinate();
103 142
                if (slopeType == SlopeType.HORIZONTAL)
......
105 144
                else if (slopeType == SlopeType.VERTICAL)
106 145
                    x = prevX;
107 146

  
108
            }
109
            else
110
            {
111
                
147
                ReleaseCOMObjects(prevLMSymbol);
112 148
            }
113 149

  
114 150
            if (_TargetItem == null)
115 151
                _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle);
116 152
            else
117
            {
118 153
                _LMSymbol = _placement.PIDPlaceSymbol(mappingPath, x, y, Mirror: mirror, Rotation: angle, TargetItem: _TargetItem);
119
                ReleaseCOMObjects(_TargetItem);
120
            }
121 154

  
122 155
            if (_LMSymbol != null)
123 156
            {
124
                symbol.SPPID.ITEMOBJECT = _LMSymbol.AsLMRepresentation().Id;
157
                _LMSymbol.Commit();
158
                symbol.SPPID.RepresentationId = _LMSymbol.AsLMRepresentation().Id;
125 159
            }
126 160

  
127
            ReleaseCOMObjects(_LMSymbol);
128
        }
129

  
130
        private void LineModeling(Line line)
131
        {
132
            object DrwingID = "0";
133
            _LMAItem _LMAItem = _placement.PIDCreateItem(line.SPPID.MAPPINGNAME, ref DrwingID);
134
            PlaceRunInputs placeRunInputs = new PlaceRunInputs();
135
            placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
136
            placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y);
137

  
138
            LMConnector lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs);
139
            lMConnector.Commit();
140 161

  
141
            ReleaseCOMObjects(lMConnector);
142
            ReleaseCOMObjects(placeRunInputs);
143
            ReleaseCOMObjects(_LMAItem);
162
            if (_TargetItem != null)
163
                ReleaseCOMObjects(_TargetItem);
164
            ReleaseCOMObjects(dataSource);
165
            ReleaseCOMObjects(_LMSymbol);
144 166
        }
145 167

  
146 168
        private void LineModeling(List<Line> lines)
147 169
        {
148 170
            object DrwingID = "0";
171
            LMADataSource dataSource = _placement.PIDDataSource;
149 172
            _LMAItem _LMAItem = _placement.PIDCreateItem(lines[0].SPPID.MAPPINGNAME, ref DrwingID);
150 173
            PlaceRunInputs placeRunInputs = new PlaceRunInputs();
174
            LMSymbol _LMSymbol1 = null;
175
            LMSymbol _LMSymbol2 = null;
151 176
            for (int i = 0; i < lines.Count; i++)
152 177
            {
153 178
                Line line = lines[i];
154
                placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
155
                placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y);
179
                if (i == 0 || i + 1 != lines.Count)
180
                {
181
                    object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[0].CONNECTEDITEM);
182
                    if (connItem != null && connItem.GetType() == typeof(Symbol))
183
                    {
184
                        _LMSymbol1 = dataSource.GetSymbol(((Symbol)connItem).SPPID.RepresentationId);
185
                        if (_LMSymbol1 != null)
186
                            placeRunInputs.AddSymbolTarget(_LMSymbol1, line.SPPID.START_X, line.SPPID.START_Y);
187
                        else
188
                            placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
189
                    }
190
                    else
191
                        placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
192
                }
193

  
194
                if (i + 1 == lines.Count)
195
                {
196
                    object connItem = SPPIDUtil.FindObjectByUID(document, line.CONNECTORS[1].CONNECTEDITEM);
197
                    if (connItem != null && connItem.GetType() == typeof(Symbol))
198
                    {
199
                        _LMSymbol2 = dataSource.GetSymbol(((Symbol)connItem).SPPID.RepresentationId);
200
                        if (_LMSymbol2 != null)
201
                        {
202
                            if (i != 0)
203
                                placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
204

  
205
                            placeRunInputs.AddSymbolTarget(_LMSymbol2, line.SPPID.END_X, line.SPPID.END_Y);
206
                        }
207
                        else
208
                        {
209
                            if (i != 0)
210
                                placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
211
                            placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y);
212
                        }
213
                            
214
                    }
215
                    else
216
                    {
217
                        if (i != 0)
218
                            placeRunInputs.AddPoint(line.SPPID.START_X, line.SPPID.START_Y);
219
                        placeRunInputs.AddPoint(line.SPPID.END_X, line.SPPID.END_Y);
220
                    }
221
                }
222
            }
223
            
224

  
225
            LMConnector _lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs);
226
            if (_lMConnector != null)
227
            {
228
                foreach (var line in lines)
229
                    line.SPPID.RepresentationId = _lMConnector.AsLMRepresentation().Id;
230
                _lMConnector.Commit();
156 231
            }
157 232
            
158 233

  
159
            LMConnector lMConnector = _placement.PIDPlaceRun(_LMAItem, placeRunInputs);
160
            lMConnector.Commit();
234
            if (_LMSymbol1 != null)
235
                ReleaseCOMObjects(_LMSymbol1);
236
            if (_LMSymbol2 != null)
237
                ReleaseCOMObjects(_LMSymbol2);
161 238

  
162
            ReleaseCOMObjects(lMConnector);
239
            ReleaseCOMObjects(dataSource);
240
            ReleaseCOMObjects(_lMConnector);
163 241
            ReleaseCOMObjects(placeRunInputs);
164 242
            ReleaseCOMObjects(_LMAItem);
165 243
        }

내보내기 Unified diff

클립보드 이미지 추가 (최대 크기: 500 MB)