프로젝트

일반

사용자정보

통계
| 개정판:

hytos / DTI_PID / SPPIDAutoModeling / ItemObject.cs @ 07bf38e1

이력 | 보기 | 이력해설 | 다운로드 (28.5 KB)

1
using System;
2
using System.Collections.Generic;
3
using System.ComponentModel;
4
using System.Linq;
5
using System.Runtime.InteropServices;
6
using System.Text;
7
using System.Threading.Tasks;
8
using Llama;
9
using Plaice;
10

    
11
namespace SPPIDAutoModeling
12
{
13
    public enum SPPID_ITEM_TYPE
14
    {
15
        SYMBOL = 1,
16
        LINE = 2,
17
        LABEL = 3,
18
        TEXT = 4,
19
    }
20

    
21
    public class SymbolChild
22
    {
23
        private string _Arrow;
24
        private string _Name;
25
        private int _Index;
26
        private string _SPPIDMAPPINGNAME;
27
        private object _SPPID_ITEM_OBJECT;
28

    
29
        public string Arrow { get => _Arrow; set => _Arrow = value; }
30
        public string Name { get => _Name; set => _Name = value; }
31
        public int Index { get => _Index; set => _Index = value; }
32
        public string SPPIDMAPPINGNAME { get => _SPPIDMAPPINGNAME; set => _SPPIDMAPPINGNAME = value; }
33
        public object SPPID_ITEM_OBJECT { get => _SPPID_ITEM_OBJECT; set => _SPPID_ITEM_OBJECT = value; }
34
    }
35

    
36

    
37
    public class Group
38
    {
39
        private List<object> _Items = new List<object>();
40
        private bool _Enable = true;
41

    
42
        public List<object> Items { get => _Items; set => _Items = value; }
43
        public bool Enable { get => _Enable; set => _Enable = value; }
44
    }
45

    
46
    public class Association
47
    {
48
        private string _TYPE;
49
        private string _TYPE_VALUE;
50

    
51
        public string TYPE { get => _TYPE; set => _TYPE = value; }
52
        public string TYPE_VALUE { get => _TYPE_VALUE; set => _TYPE_VALUE = value; }
53
    }
54

    
55
    
56

    
57
    public class Drawing
58
    {
59
        #region Property
60
        private string _DWGNAME;
61
        private string _SIZE;
62
        private string _UNIT;
63
        private List<Symbol> _SYMBOLS = new List<Symbol>();
64
        private List<Line> _LINES = new List<Line>();
65
        private List<LineNumber> _LINENUMBERS = new List<LineNumber>();
66
        private List<Text> _TEXTS = new List<Text>();
67
        private Dictionary<string, List<PointInfo>> _PipeRunPoint = new Dictionary<string, List<PointInfo>>();
68
        private List<Group> _GROUPS = new List<Group>();
69

    
70
        private double _WIDTH;
71
        private double _HEIGHT;
72

    
73
        public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; }
74
        public string SIZE
75
        {
76
            get { return _SIZE; }
77
            set
78
            {
79
                _SIZE = value;
80
                SPPIDUtill.ConvertPointBystring(_SIZE, ref _WIDTH, ref _HEIGHT);
81
            }
82
        }
83
        public string UNIT { get => _UNIT; set => _UNIT = value; }
84
        public Dictionary<string, List<PointInfo>> PipeRunPoint { get => _PipeRunPoint; set => _PipeRunPoint = value; }
85
        public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; }
86
        public List<Line> LINES { get => _LINES; set => _LINES = value; }
87
        public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; }
88
        public List<Text> TEXTS { get => _TEXTS; set => _TEXTS = value; }
89
        public double WIDTH { get => _WIDTH; set => _WIDTH = value; }
90
        public double HEIGHT { get => _HEIGHT; set => _HEIGHT = value; }
91
        public List<Group> GROUPS { get => _GROUPS; set => _GROUPS = value; }
92
        #endregion
93
    }
94

    
95
    public class PointInfo
96
    {
97
        public PointInfo(double x, double y)
98
        {
99
            this.x = x;
100
            this.y = y;
101
        }
102

    
103
        public enum PointType
104
        {
105
            None = 0,
106
            Run = 1,
107
            Branch = 2,
108
        }
109
        #region Property
110
        private double x;
111
        private double y;
112
        private PointType _Type;
113
        private string _ConnectedItem;
114
        private string _SP_ID;
115
        private SPPID_ITEM _ConnectedItemObject;
116

    
117
        public double X { get { return x; } set { x = value; } }
118
        public double Y { get { return y; } set { y = value; } }
119
        public PointType Type { get => _Type; set => _Type = value; }
120
        public string ConnectedItem { get => _ConnectedItem; set => _ConnectedItem = value; }
121
        public SPPID_ITEM ConnectedItemObject { get => _ConnectedItemObject; set => _ConnectedItemObject = value; }
122
        public string SP_ID { get => _SP_ID; set => _SP_ID = value; }
123
        #endregion
124
    }
125

    
126

    
127
    public abstract class SPPID_ITEM
128
    {
129
        #region Property
130
        private string _UID;
131
        private string _TYPE;
132
        private string _NAME;
133
        private SPPID_ITEM_TYPE _SPPID_TYPE ;
134
        private string _SPPIDMAPPINGNAME;
135
        private bool _GROUPING;
136
        private string _AREA;
137
        private List<ItemAttribute> _ATTRIBUTES = new List<ItemAttribute>();
138
        private object _SPPID_ITEM_OBJECT;
139

    
140
        public string UID { get => _UID; set => _UID = value; }
141
        public string TYPE { get => _TYPE; set => _TYPE = value; }
142
        public string NAME { get => _NAME; set => _NAME = value; }
143
        public string SPPIDMAPPINGNAME { get => _SPPIDMAPPINGNAME; set => _SPPIDMAPPINGNAME = value; }
144
        public bool GROUPING { get => _GROUPING; set => _GROUPING = value; }
145
        public string AREA { get => _AREA; set => _AREA = value; }
146
        public object SPPID_ITEM_OBJECT { get => _SPPID_ITEM_OBJECT; set => _SPPID_ITEM_OBJECT = value; }
147
        public SPPID_ITEM_TYPE SPPID_TYPE { get => _SPPID_TYPE; set => _SPPID_TYPE = value; }
148
        public List<ItemAttribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; }
149
        #endregion
150

    
151
        public abstract bool Modeling();
152
        public abstract void AfterSetting();
153
        public abstract void SetAttribute();
154
    }
155

    
156
    public class Symbol : SPPID_ITEM
157
    {
158
        #region Property
159
        private string _ORIGINALPOINT;
160
        private List<Association> _ASSOCIATIONS = new List<Association>();
161
        private List<Connector> _CONNECTORS = new List<Connector>();
162
        private string _CONNECTIONPOINT;
163
        private string _LOCATION;
164
        private string _SIZE;
165
        private double _ANGLE;
166
        private string _PARENT;
167
        private string _CHILD;
168
        private List<SymbolChild> _CHILD_LIST = new List<SymbolChild>();
169
        private string _HASINSTRUMENTLABEL;
170
        private string _CURRENTPOINTMODEINDEX;
171
        private bool _DRAWCHECKED;
172
        private double _LOCATION_X;
173
        private double _LOCATION_Y;
174
        private int _MIRROR = 0;
175

    
176
        public string ORIGINALPOINT { get => _ORIGINALPOINT; set => _ORIGINALPOINT = value; }
177
        public string LOCATION { get => _LOCATION; set => _LOCATION = value; }
178
        public string SIZE { get => _SIZE; set => _SIZE = value; }
179
        public double ANGLE { get => _ANGLE; set => _ANGLE = value; }
180
        public string PARENT { get => _PARENT; set => _PARENT = value; }
181
        public string CHILD { get => _CHILD; set => _CHILD = value; }
182
        public string HASINSTRUMENTLABEL { get => _HASINSTRUMENTLABEL; set => _HASINSTRUMENTLABEL = value; }
183
        public string CURRENTPOINTMODEINDEX { get => _CURRENTPOINTMODEINDEX; set => _CURRENTPOINTMODEINDEX = value; }
184
        public bool DRAWCHECKED { get => _DRAWCHECKED; set => _DRAWCHECKED = value; }
185
        public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; }
186
        public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; }
187
        public int MIRROR { get => _MIRROR; set => _MIRROR = value; }
188
        public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; }
189
        public string CONNECTIONPOINT { get => _CONNECTIONPOINT; set => _CONNECTIONPOINT = value; }
190
        public List<SymbolChild> CHILD_LIST { get => _CHILD_LIST; set => _CHILD_LIST = value; }
191
        public List<Association> ASSOCIATIONS { get => _ASSOCIATIONS; set => _ASSOCIATIONS = value; }
192
        #endregion
193
        public override void AfterSetting()
194
        {
195
            // SPPIDMAPPINGNAME Setting
196
            SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(PARENT);
197
            // End
198

    
199
            // Angle Setting
200
            if (ANGLE == 1.57)
201
                ANGLE = 90 * Math.PI / 180;
202
            else if (ANGLE == 3.14)
203
                ANGLE = Math.PI;
204
            else if (ANGLE == 4.71)
205
                ANGLE = 270 * Math.PI / 180;
206
            else
207
                ANGLE = 0;
208
            // End
209

    
210
            // Location Setting
211
            SPPIDUtill.ConvertPointBystring(_ORIGINALPOINT, ref _LOCATION_X, ref _LOCATION_Y);
212
            SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
213
            // End
214

    
215
            // SPPID Type Setting
216
            SPPID_TYPE = SPPID_ITEM_TYPE.SYMBOL;
217
            // End
218

    
219
            // Child Setting
220
            if (!string.IsNullOrEmpty(CHILD) && CHILD != "None")
221
            {
222
                string[] array = CHILD.Split(new char[] { ',' });
223
                for (int i = 0; i < array.Length; i++)
224
                {
225
                    SymbolChild child = new SymbolChild()
226
                    {
227
                        Arrow = array[0],
228
                        Name = array[1],
229
                        Index = i + 1,
230
                    };
231
                    child.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(child.Name);
232
                    CHILD_LIST.Add(child);
233
                }
234
            }
235
            // End
236

    
237
            // ConnectionPoint Setting
238
            if (!string.IsNullOrEmpty(CONNECTIONPOINT) && CONNECTIONPOINT != "None")
239
            {
240
                string[] array = CONNECTIONPOINT.Split(new char[] { '/' });
241
                for (int i = 0; i < array.Length; i++)
242
                {
243
                    string[] arrConn = array[i].Split(new char[] { ',' });
244
                    CONNECTORS[i].INDEX = Convert.ToInt32(arrConn[3]);
245
                }
246
            }
247
            // End
248

    
249
            // Input Drawing
250
            AutoModeling.DrawingItem.SYMBOLS.Add(this);
251
            // End
252
        }
253

    
254
        public override bool Modeling()
255
        {
256
            try
257
            {
258
                Placement _placement = new Placement();
259
                LMSymbol lmSymbol = null;
260
                SPPID_ITEM_OBJECT = null;
261

    
262
                if (!string.IsNullOrEmpty(SPPIDMAPPINGNAME))
263
                {
264
                    LMSymbol connectedSymbol = null;
265
                    foreach (Connector connector in CONNECTORS)
266
                    {
267
                        if (!string.IsNullOrEmpty(connector.CONNECTEDITEM) || connector.CONNECTEDITEM != "None")
268
                        {
269
                            object _obj = SPPIDUtill.FindObjectByUID(connector.CONNECTEDITEM);
270
                            if (_obj != null && typeof(Symbol) == _obj.GetType())
271
                            {
272
                                Symbol _symbol = _obj as Symbol;
273
                                if (_symbol.SPPID_ITEM_OBJECT != null)
274
                                    connectedSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol;
275
                            }
276
                        }
277
                    }
278

    
279
                    if (connectedSymbol != null)
280
                        lmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Mirror: MIRROR, Rotation: ANGLE, TargetItem: connectedSymbol);
281
                    else
282
                        lmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Mirror: MIRROR, Rotation: ANGLE);
283

    
284
                    // Commit and input sppid item object
285
                    lmSymbol.Commit();
286
                    SPPID_ITEM_OBJECT = lmSymbol;
287
                    // End
288

    
289
                    // Check Child And Modeling
290
                    foreach (SymbolChild symoblChild in CHILD_LIST)
291
                    {
292
                        try
293
                        {
294
                            string sArrow = symoblChild.Arrow;
295
                            string sMappingName = symoblChild.SPPIDMAPPINGNAME;
296

    
297
                            double dChildAngle = 0;
298
                            if (sArrow == "UP")
299
                                dChildAngle = 0;
300
                            else if (sArrow == "RIGHT")
301
                                dChildAngle = 90 * Math.PI / 180;
302
                            else if (sArrow == "DOWN")
303
                                dChildAngle = Math.PI;
304
                            else
305
                                dChildAngle = 270 * Math.PI / 180;
306

    
307
                            LMSymbol _childLmSymbol = _placement.PIDPlaceSymbol(sMappingName, LOCATION_X, LOCATION_Y, Mirror: 0, Rotation: dChildAngle, TargetItem: SPPID_ITEM_OBJECT);
308
                            _childLmSymbol.Commit();
309
                            symoblChild.SPPID_ITEM_OBJECT = _childLmSymbol;
310
                        }
311
                        catch (Exception ex)
312
                        {
313
                            Console.WriteLine(ex.StackTrace);
314
                        }
315
                    }
316
                    // End
317

    
318
                    // Association Modeling
319
                    try
320
                    {
321
                        foreach (Association item in ASSOCIATIONS)
322
                        {
323
                            object _obj = SPPIDUtill.FindObjectByUID(item.TYPE_VALUE);
324
                            if (_obj != null && typeof(Text) == _obj.GetType())
325
                            {
326
                                Text text = _obj as Text;
327
                                if (text.NAME == "SIZE")
328
                                {
329
                                    text.OWNER = UID;
330
                                    text.Modeling();
331
                                    text.SetAttribute();
332
                                }
333
                            }
334
                        }
335
                    }
336
                    catch (Exception ex)
337
                    {
338
                        Console.WriteLine(ex.StackTrace);
339
                    }
340
                    // End
341
                }
342
            }
343
            catch (Exception ex)
344
            {
345
                Console.WriteLine(ex.StackTrace);
346
                return false;
347
            }
348
            return true;
349
        }
350

    
351
        public override void SetAttribute()
352
        {
353
            throw new NotImplementedException();
354
        }
355
    }
356

    
357
    public class Line : SPPID_ITEM
358
    {
359
        public enum SlopeType
360
        {
361
            NONE = 0,
362
            VERTICAL = 1,
363
            HORIZONTAL = 2,
364
            SLOPE = 3,
365
        }
366
        #region Property
367
        private string _STARTPOINT;
368
        private string _ENDPOINT;
369
        private List<Connector> _CONNECTORS = new List<Connector>();
370
        private SlopeType _SLOPTYPE;
371
        private double _START_X;
372
        private double _START_Y;
373
        private double _END_X;
374
        private double _END_Y;
375

    
376
        public string STARTPOINT { get => _STARTPOINT; set => _STARTPOINT = value; }
377
        public string ENDPOINT { get => _ENDPOINT; set => _ENDPOINT = value; }
378
        public double START_X { get => _START_X; set => _START_X = value; }
379
        public double START_Y { get => _START_Y; set => _START_Y = value; }
380
        public double END_X { get => _END_X; set => _END_X = value; }
381
        public double END_Y { get => _END_Y; set => _END_Y = value; }
382
        public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; }
383
        public SlopeType SLOPTYPE { get => _SLOPTYPE; set => _SLOPTYPE = value; }
384
        #endregion
385
        public override void AfterSetting()
386
        {
387
            // SPPIDMAPPINGNAME Setting
388
            SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(TYPE);
389
            // End
390

    
391
            // Point Setting
392
            SPPIDUtill.ConvertPointBystring(_STARTPOINT, ref _START_X, ref _START_Y);
393
            SPPIDUtill.ConvertSPPIDPoint(ref _START_X, ref _START_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
394
            SPPIDUtill.ConvertPointBystring(_ENDPOINT, ref _END_X, ref _END_Y);
395
            SPPIDUtill.ConvertSPPIDPoint(ref _END_X,ref _END_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
396
            // End
397

    
398
            // Slop Setting
399
            SLOPTYPE = SPPIDUtill.CalcSlop(new PointInfo(_START_X, _START_Y), new PointInfo(_END_X, _END_Y));
400
            // End
401

    
402
            // SPPID Type Setting
403
            SPPID_TYPE = SPPID_ITEM_TYPE.LINE;
404
            // End
405

    
406
            // Input Drawing
407
            AutoModeling.DrawingItem.LINES.Add(this);
408
            // End
409
        }
410

    
411
        public override bool Modeling()
412
        {
413
            throw new MissingMethodException();
414
        }
415

    
416
        public override void SetAttribute()
417
        {
418
            throw new NotImplementedException();
419
        }
420
    }
421

    
422
    public class LineNumber : SPPID_ITEM
423
    {
424
        public enum LineNumberType
425
        {
426
            LineNumber = 1,
427
            TrimLine = 2,
428
        }
429
        #region Property
430
        private double _ANGLE;
431
        private string _LOCATION;
432
        private double _LOCATION_X;
433
        private double _LOCATION_Y;
434
        private string _TEXT;
435
        private string _CONNECTLINE;
436
        private LineNumberType _LINENUMBERTYPE;
437

    
438
        public double ANGLE { get => _ANGLE; set => _ANGLE = value; }
439
        public string LOCATION { get => _LOCATION; set => _LOCATION = value; }
440
        public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; }
441
        public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; }
442
        public string TEXT { get => _TEXT; set => _TEXT = value; }
443
        public string CONNECTLINE { get => _CONNECTLINE; set => _CONNECTLINE = value; }
444
        public LineNumberType LINENUMBERTYPE { get => _LINENUMBERTYPE; set => _LINENUMBERTYPE = value; }
445
        #endregion
446

    
447
        public override void AfterSetting()
448
        {
449
            // SPPIDMAPPINGNAME Setting
450
            SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME);
451
            // End
452

    
453
            // Angle Setting
454
            if (ANGLE == 1.57)
455
                ANGLE = 90 * Math.PI / 180;
456
            else if (ANGLE == 3.14)
457
                ANGLE = Math.PI;
458
            else if (ANGLE == 4.71)
459
                ANGLE = 270 * Math.PI / 180;
460
            else
461
                ANGLE = 0;
462
            // End
463

    
464
            // Location Setting
465
            SPPIDUtill.ConvertPointBystring(_LOCATION, ref _LOCATION_X, ref _LOCATION_Y);
466
            SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
467
            // End
468

    
469
            // SPPID  Type Setting
470
            SPPID_TYPE = SPPID_ITEM_TYPE.LABEL;
471
            // End
472

    
473
            // Input Drawing
474
            AutoModeling.DrawingItem.LINENUMBERS.Add(this);
475
            // End
476
        }
477

    
478
        public override bool Modeling()
479
        {
480
            try
481
            {
482
                Line targetLine = SPPIDUtill.FindObjectByUID(CONNECTLINE) as Line;
483
                if (targetLine != null && !string.IsNullOrEmpty(targetLine.SPPID_ITEM_OBJECT.ToString()))
484
                {
485
                    Placement _placement = new Placement();
486
                    Array points = new double[] { 0, LOCATION_X, LOCATION_Y };
487
                    LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(targetLine.SPPID_ITEM_OBJECT.ToString());
488
                    if (_pipeRun != null)
489
                    {
490
                        foreach (LMRepresentation rep in _pipeRun.Representations)
491
                        {
492
                            if (rep.get_RepresentationType() == "Connector" && rep.get_ItemStatus() == "Active")
493
                            {
494
                                LMConnector _LmConnector = _placement.PIDDataSource.GetConnector(rep.Id);
495
                                LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref points, Rotation: ANGLE, LabeledItem: _LmConnector.AsLMRepresentation(), IsLeaderVisible: true);
496
                                _LmLabelPresist.Commit();
497
                                SPPID_ITEM_OBJECT = _LmLabelPresist;
498
                            }
499
                        }
500
                    }
501
                }
502
            }
503
            catch (Exception ex)
504
            {
505
                Console.WriteLine(ex.StackTrace);
506
                return false;
507
            }
508
            return true;
509
        }
510

    
511
        public override void SetAttribute()
512
        {
513
            try
514
            {
515
                Line targetLine = SPPIDUtill.FindObjectByUID(CONNECTLINE) as Line;
516
                if (targetLine != null)
517
                {
518
                    Placement _placement = new Placement();
519
                    LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(targetLine.SPPID_ITEM_OBJECT.ToString());
520

    
521
                    foreach (ItemAttribute attr in ATTRIBUTES)
522
                    {
523
                        if (string.IsNullOrEmpty(attr.VALUE))
524
                            continue;
525

    
526
                        LMAAttribute lMAAttribute = _pipeRun.Attributes[attr.Attribute];
527
                        if (lMAAttribute != null)
528
                            _pipeRun.Attributes[attr.Attribute].set_Value(attr.VALUE);
529
                    }
530
                    _pipeRun.Commit();
531
                }
532
            }
533
            catch (Exception ex)
534
            {
535
                Console.WriteLine(ex.StackTrace);
536
            }
537
        }
538
    }
539

    
540
    public class Text : SPPID_ITEM
541
    {
542
        #region Property
543
        private double _ANGLE;
544
        private string _LOCATION;
545
        private double _LOCATION_X;
546
        private double _LOCATION_Y;
547
        private string _VALUE;
548
        private string _OWNER;
549

    
550
        public double ANGLE { get => _ANGLE; set => _ANGLE = value; }
551
        public string LOCATION { get => _LOCATION; set => _LOCATION = value; }
552
        public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; }
553
        public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; }
554
        public string VALUE { get => _VALUE; set => _VALUE = value; }
555
        public string OWNER { get => _OWNER; set => _OWNER = value; }
556
        #endregion
557
        public override void AfterSetting()
558
        {
559
            // SPPIDMAPPINGNAME Setting
560
            SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME);
561
            // End
562

    
563
            // Angle Setting
564
            if (ANGLE == 1.57)
565
                ANGLE = 90 * Math.PI / 180;
566
            else if (ANGLE == 3.14)
567
                ANGLE = Math.PI;
568
            else if (ANGLE == 4.71)
569
                ANGLE = 270 * Math.PI / 180;
570
            else
571
                ANGLE = 0;
572
            // End
573

    
574
            // Location Setting
575
            SPPIDUtill.ConvertPointBystring(_LOCATION, ref _LOCATION_X, ref _LOCATION_Y);
576
            SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
577
            // End
578

    
579
            // SPPID  Type Setting
580
            SPPID_TYPE = SPPID_ITEM_TYPE.TEXT;
581
            // End
582

    
583
            // Input Drawing
584
            AutoModeling.DrawingItem.TEXTS.Add(this);
585
            // End
586
        }
587

    
588
        public override bool Modeling()
589
        {
590
            try
591
            {
592
                if (SPPID_ITEM_OBJECT == null)
593
                {
594
                    Placement _placement = new Placement();
595
                    if (NAME == "TEXT" || NAME == "NOTE")
596
                    {
597
                        LMSymbol _LmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Rotation: ANGLE);
598
                        LMItemNote _LmItemNote = _placement.PIDDataSource.GetItemNote(_LmSymbol.ModelItemID);
599
                        _LmItemNote.Attributes["Note.Body"].set_Value(VALUE);
600
                        _LmItemNote.Commit();
601
                        SPPID_ITEM_OBJECT = _LmItemNote;
602
                    }
603
                    else if (NAME == "SIZE" && !string.IsNullOrEmpty(OWNER))
604
                    {
605
                        object _obj = SPPIDUtill.FindObjectByUID(OWNER);
606
                        if (_obj != null && typeof(Symbol) == _obj.GetType())
607
                        {
608
                            Array array = new double[] { 0, LOCATION_X, LOCATION_Y };
609
                            Symbol _symbol = _obj as Symbol;
610
                            LMSymbol _LmSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol;
611

    
612
                            if (_LmSymbol != null)
613
                            {
614
                                string fileName = _LmSymbol.get_FileName();
615
                                if (fileName.Contains("Piping"))
616
                                    SPPIDMAPPINGNAME = @"\Piping\Labels - Piping Components\Nominal Diameter.sym";
617
                                else if (fileName.Contains("Instrumentation"))
618
                                    SPPIDMAPPINGNAME = @"\Instrumentation\Labels - General Instrument\Nominal Diameter.sym";
619

    
620
                                LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref array, Rotation: ANGLE, LabeledItem: _LmSymbol.AsLMRepresentation(), IsLeaderVisible: true);
621
                                _LmLabelPersist.Commit();
622

    
623
                                SPPID_ITEM_OBJECT = _LmLabelPersist;
624
                            }
625
                        }
626
                    }
627
                }
628
            }
629
            catch (Exception ex)
630
            {
631
                Console.WriteLine(ex.StackTrace);
632
                return false;
633
            }
634

    
635
            return true;
636
        }
637

    
638
        public override void SetAttribute()
639
        {
640
            try
641
            {
642
                Placement _placement = new Placement();
643
                if (NAME == "SIZE")
644
                {
645
                    object _obj = SPPIDUtill.FindObjectByUID(OWNER);
646
                    if (_obj != null && typeof(Symbol) == _obj.GetType())
647
                    {
648
                        Symbol _symbol = _obj as Symbol;
649
                        LMSymbol _LmSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol;
650

    
651
                        if (_LmSymbol != null)
652
                        {
653
                            string fileName = _LmSymbol.get_FileName();
654
                            if (fileName.Contains("Piping"))
655
                            {
656
                                LMPipingComp _LmPipingComp = _placement.PIDDataSource.GetPipingComp(_LmSymbol.ModelItemID);
657
                                if (_LmPipingComp != null && DBNull.Value.Equals(_LmPipingComp.Attributes["NominalDiameter"].get_Value()))
658
                                {
659
                                    _LmPipingComp.Attributes["NominalDiameter"].set_Value(VALUE);
660
                                    _LmPipingComp.Commit();
661
                                }
662
                            }
663
                            else if (fileName.Contains("Instrumentation"))
664
                            {
665
                                LMInstrument _LmInstrument = _placement.PIDDataSource.GetInstrument(_LmSymbol.ModelItemID);
666
                                if (_LmInstrument != null && DBNull.Value.Equals(_LmInstrument.Attributes["NominalDiameter"].get_Value()))
667
                                {
668
                                    _LmInstrument.Attributes["NominalDiameter"].set_Value(VALUE);
669
                                    _LmInstrument.Commit();
670
                                }
671
                            }
672
                        }
673
                    }
674
                }
675
            }
676
            catch (Exception ex)
677
            {
678
                Console.WriteLine(ex.StackTrace);
679
            }
680

    
681
            
682

    
683
            //throw new NotImplementedException();
684
        }
685
    }
686

    
687

    
688
    public class ItemAttribute
689
    {
690
        #region Property
691
        private string _UID;
692
        private string _Length;
693
        private string _Expression;
694
        private string _DisplayAttribute;
695
        private string _AttributeType;
696
        private string _Attribute;
697
        private string _AttrAt;
698

    
699
        private string _VALUE;
700

    
701
        public string UID { get => _UID; set => _UID = value; }
702
        public string VALUE { get => _VALUE; set => _VALUE = value; }
703
        public string Length { get => _Length; set => _Length = value; }
704
        public string Expression { get => _Expression; set => _Expression = value; }
705
        public string DisplayAttribute { get => _DisplayAttribute; set => _DisplayAttribute = value; }
706
        public string AttributeType { get => _AttributeType; set => _AttributeType = value; }
707
        public string Attribute { get => _Attribute; set => _Attribute = value; }
708
        public string AttrAt { get => _AttrAt; set => _AttrAt = value; }
709
        #endregion
710
    }
711

    
712
    public class Connector
713
    {
714
        #region Property
715
        private string _CONNECTEDITEM;
716
        private string _CONNECTPOINT;
717
        private string _SCENECONNECTPOINT;
718
        private int _INDEX;
719

    
720
        public string CONNECTEDITEM { get => _CONNECTEDITEM; set => _CONNECTEDITEM = value; }
721
        public string CONNECTPOINT { get => _CONNECTPOINT; set => _CONNECTPOINT = value; }
722
        public string SCENECONNECTPOINT { get => _SCENECONNECTPOINT; set => _SCENECONNECTPOINT = value; }
723
        public int INDEX { get => _INDEX; set => _INDEX = value; }
724
        #endregion
725
    }
726
}
클립보드 이미지 추가 (최대 크기: 500 MB)