프로젝트

일반

사용자정보

개정판 ca6e0f51

IDca6e0f519f64f5772705dea5a85242f593e8b64a
상위 2800c367
하위 24515a3a

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

dev issue #000 : 안정화

Change-Id: I0841f03ded95d09a89f5a939aa0a23ec1e78a5bc

차이점 보기:

DTI_PID/SPPIDConverter/ConverterDocking.cs
35 35
            application = Interaction.GetObject("", "PIDAutomation.Application");
36 36
            WrapperApplication wApp = new WrapperApplication(application.Application);
37 37
            radApp = wApp.RADApplication;
38

  
38
            
39 39
            try
40 40
            {
41 41
                textEditDrawingX.EditValue = Settings.Default.DrawingX;
......
188 188
        }
189 189

  
190 190
        #region TEST
191
        Placement _placement = new Placement();
192
        LMADataSource dataSource;
191 193
        bool first = true;
192 194
        LMDrawing currentDrawing;
193 195
        private void simpleButton1_Click(object sender, EventArgs e)
194 196
        {
195
            Placement _placement = new Placement();
196
            LMADataSource dataSource = _placement.PIDDataSource;//placement.PIDDataSource;
197
            dataSource = _placement.PIDDataSource;
198

  
199
            string projectNumber = dataSource.ProjectNumber;
200
            LMActiveProject activeProject = dataSource.GetActiveProject();
201
            LMAEnumAttLists enumAttLists = dataSource.CodeLists;
197 202

  
198
            LMModelItem modelitem = dataSource.GetModelItem("F462457D634C401B9D9FB425A2AC88EA");
199
            foreach (LMRepresentation item in modelitem.Representations)
203
            AutoJoinPipeRun();
204
        }
205
        private void AutoJoinPipeRun()
206
        {
207
            string modelItemId = null;
208
            List<double[]> vertices = new List<double[]>();
209
            dynamic OID = radApp.ActiveSelectSet[0].Key();
210
            DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID];
211
            foreach (var attributes in drawingObject.AttributeSets)
200 212
            {
201
                LMSymbol symbol = dataSource.GetSymbol(item.Id);
202
                foreach (LMRelationship relationship in symbol.Relation1Relationships)
213
                foreach (var attribute in attributes)
203 214
                {
204
                    if (relationship.Item1RepresentationObject != null && relationship.Item1RepresentationObject.Id != symbol.Id)
205
                    {
215
                    if (attribute.Name == "ModelID")
216
                        modelItemId = attribute.GetValue().ToString();
217
                }
218
            }
219
            radApp.ActiveSelectSet.RemoveAll();
206 220

  
207
                    }
208
                    else if (relationship.Item2RepresentationObject != null && relationship.Item2RepresentationObject.Id != symbol.Id)
209
                    {
210 221

  
222
            LMModelItem modelItem = dataSource.GetModelItem(modelItemId);
223

  
224
            List<string> endModelItemIDs = new List<string>();
225

  
226
            if (modelItem != null)
227
            {
228
                List<string> otherModelIds = new List<string>();
229
                foreach (LMRepresentation rep in modelItem.Representations)
230
                {
231
                    if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active")
232
                    {
233
                        LMConnector connector = dataSource.GetConnector(rep.Id);
234
                        if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch")
235
                        {
236
                            LMSymbol symbol = connector.ConnectItem1SymbolObject;
237
                            otherModelIds.AddRange(FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id));
238
                        }
239
                        if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch")
240
                        {
241
                            LMSymbol symbol = connector.ConnectItem2SymbolObject;
242
                            otherModelIds.AddRange(FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id));
243
                        }
211 244
                    }
212 245
                }
213
                foreach (LMRelationship relationship in symbol.Relation2Relationships)
246

  
247
            }
248
        }
249
        private void JoinRun(string mainModelId, string modelId)
250
        {
251
            LMModelItem modelItem = dataSource.GetModelItem(mainModelId);
252
            if (modelItem != null)
253
            {
254
                foreach (LMRepresentation rep in modelItem.Representations)
214 255
                {
215
                    if (relationship.Item1RepresentationObject != null && relationship.Item1RepresentationObject.Id != symbol.Id)
256
                    if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active")
216 257
                    {
258
                        LMConnector connector = dataSource.GetConnector(rep.Id);
259
                        if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch")
260
                        {
261
                            LMSymbol symbol = connector.ConnectItem1SymbolObject;
217 262

  
263
                        }
264
                        if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch")
265
                        {
266
                            LMSymbol symbol = connector.ConnectItem2SymbolObject;
267
                            string typeName = symbol.ModelItemObject.get_ItemTypeName().ToString();
268
                            if (typeName == "Instrument")
269
                            {
270
                                LMInstrument instrument = dataSource.GetInstrument(symbol.ModelItemID);
271
                            }
272
                            else if (typeName == "PipingComp")
273
                            {
274
                                LMPipingComp pipingComp = dataSource.GetPipingComp(symbol.ModelItemID);
275
                            }
276
                        }
218 277
                    }
219
                    else if (relationship.Item2RepresentationObject != null && relationship.Item2RepresentationObject.Id != symbol.Id)
220
                    {
278
                }
279
            }
280
        }
221 281

  
282
        private void GetModelItemForJoin(string modelItemId, List<string> otherModelIds)
283
        {
284
            LMModelItem modelItem = dataSource.GetModelItem(modelItemId);
285
            List<string> endModelItemIDs = new List<string>();
286
            if (modelItem != null)
287
            {
288
                foreach (LMRepresentation rep in modelItem.Representations)
289
                {
290
                    if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active")
291
                    {
292
                        LMConnector connector = dataSource.GetConnector(rep.Id);
293
                        if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch")
294
                        {
295
                            LMSymbol symbol = connector.ConnectItem1SymbolObject;
296
                            otherModelIds.AddRange(FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id));
297
                        }
298
                        if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch")
299
                        {
300
                            LMSymbol symbol = connector.ConnectItem2SymbolObject;
301
                            otherModelIds.AddRange(FindOtherModelItemBySymbolWhereTypePipeRun(symbol, modelItem.Id));
302
                        }
222 303
                    }
223 304
                }
305

  
306
            }
307
        }
308

  
309
        private List<string> FindOtherModelItemBySymbolWhereTypePipeRun(LMSymbol symbol, string modelId)
310
        {
311
            List<string> modelItemIDs = new List<string>();
312
            foreach (LMConnector connector in symbol.Connect1Connectors)
313
            {
314
                LMModelItem modelItem = connector.ModelItemObject;
315
                if (modelItem.get_ItemStatus() == "Active" && modelItem.get_ItemTypeName().ToString() == "PipeRun" && modelItem.Id != modelId)
316
                    modelItemIDs.Add(modelItem.Id);
317
                ReleaseCOMObjects(modelItem);
318
            }
319

  
320
            foreach (LMConnector connector in symbol.Connect2Connectors)
321
            {
322
                LMModelItem modelItem = connector.ModelItemObject;
323
                if (modelItem.get_ItemStatus() == "Active" && modelItem.get_ItemTypeName().ToString() == "PipeRun" && modelItem.Id != modelId)
324
                    modelItemIDs.Add(modelItem.Id);
325
                ReleaseCOMObjects(modelItem);
224 326
            }
225 327

  
328
            return modelItemIDs;
329
        }
330

  
331
        private void FindOtherModelItemBySymbolWhereTypePipeRunLoop()
332
        {
333

  
334
        }
335

  
336
        private void JoinRunOnlyPipeRun()
337
        {
338

  
339
        }
226 340

  
227
            //LMConnector connector = GetLMConnectorOnlyOne("E12B6DC30C224B51911F2AFFEFB8ED14");
228
            //if (connector != null)
229
            //{
230
            //    string mappingPath = @"\Piping\Labels - Piping Segments\Flow Direction.sym";
231
            //    List<double[]> vertices = GetConnectorVertices();
232
            //    vertices = vertices.FindAll(x => x[0] > 0 && x[1] > 0);
233
            //    double[] point = vertices[vertices.Count - 1];
234
            //    double[] temp = vertices[vertices.Count - 2];
235
            //    double angle = SPPIDUtil.CalcAngle(point[0], point[1], temp[0], temp[1]);
236
            //    Array array = new double[] { 0, point[0], point[1] };
237
            //    LMLabelPersist _LMLabelPersist = _placement.PIDPlaceLabel(mappingPath, ref array, LabeledItem: connector.AsLMRepresentation());
238
            //    if (_LMLabelPersist != null)
239
            //        ReleaseCOMObjects(_LMLabelPersist);
240
            //}
241

  
242
            //LMConnector GetLMConnectorOnlyOne(string modelItemID)
243
            //{
244
            //    LMConnector result = null;
245
            //    List<LMConnector> connectors = new List<LMConnector>();
246
            //    LMModelItem modelItem = dataSource.GetModelItem(modelItemID);
247

  
248
            //    if (modelItem != null)
249
            //    {
250
            //        foreach (LMRepresentation rep in modelItem.Representations)
251
            //        {
252
            //            if (rep.Attributes["RepresentationType"].get_Value() == "Connector" && rep.Attributes["ItemStatus"].get_Value() == "Active")
253
            //                connectors.Add(dataSource.GetConnector(rep.Id));
254
            //        }
255

  
256
            //        ReleaseCOMObjects(modelItem);
257
            //    }
258

  
259
            //    if (connectors.Count == 1)
260
            //        result = connectors[0];
261
            //    else
262
            //        foreach (var item in connectors)
263
            //            ReleaseCOMObjects(item);
264

  
265
            //    return result;
266
            //}
267

  
268
            //List<double[]> GetConnectorVertices()
269
            //{
270
            //    List<double[]> vertices = new List<double[]>();
271
            //    dynamic OID = radApp.ActiveSelectSet[0].Key();
272
            //    DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID];
273
            //    Ingr.RAD2D.LineStringGeometry2d lineStringGeometry = drawingObject.GetGeometry() as Ingr.RAD2D.LineStringGeometry2d;
274
            //    int verticesCount = lineStringGeometry.VertexCount;
275
            //    double[] value = null;
276
            //    lineStringGeometry.GetVertices(ref verticesCount, ref value);
277
            //    for (int i = 0; i < verticesCount; i++)
278
            //    {
279
            //        double x = 0;
280
            //        double y = 0;
281
            //        lineStringGeometry.GetVertex(i + 1, ref x, ref y);
282
            //        vertices.Add(new double[] { x, y });
283
            //    }
284
            //    return vertices;
285
            //}
341
        private void GetConnectPointsCount(LMSymbol symbol,ref int pipeRunCount, ref int signalCount)
342
        {
343
            string typeName = symbol.ModelItemObject.get_ItemTypeName().ToString();
344
            if (typeName == "Instrument")
345
            {
346
                LMInstrument item = dataSource.GetInstrument(symbol.ModelItemID);
347
                pipeRunCount = item.PipingPoints.Count;
348
                signalCount = item.SignalPoints.Count;
349
                ReleaseCOMObjects(item);
350
            }
351
            else if (typeName == "PipingComp")
352
            {
353
                LMPipingComp item = dataSource.GetPipingComp(symbol.ModelItemID);
354
                pipeRunCount = item.PipingPoints.Count;
355
                signalCount = item.SignalPoints.Count;
356
                ReleaseCOMObjects(item);
357
            }
286 358
        }
359

  
360
        
361

  
287 362
        private void TESTLine()
288 363
        {
289 364
            Placement _placement = new Placement();

내보내기 Unified diff

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