프로젝트

일반

사용자정보

개정판 8056c558

ID8056c558189a8d78109a25d78ebab4e88b8e5731
상위 558105a1
하위 fcc1bea5, 9cb58d01

gaqhf 이(가) 약 6년 전에 추가함

dev issue #728: 소스 정리 및 C#언어로 개발

차이점 보기:

DTI_PID/SPPIDAutoModeling/AutoModeling.cs
3 3
using System.Linq;
4 4
using System.Text;
5 5
using System.Threading.Tasks;
6
using System.Xml;
6 7

  
7 8
namespace SPPIDAutoModeling
8 9
{
9 10
    public class AutoModeling
10 11
    {
12
        public static Drawing DrawingItem;
13
        XmlReader xml;
14

  
15
        #region Xml Read and Data Setting
16
        public void SetXMLFile(string filePath)
17
        {
18
            try
19
            {
20
                xml = XmlReader.Create(filePath);
21

  
22
            }
23
            catch (Exception)
24
            {
25

  
26
            }
27
        }
28
        #endregion
29

  
30

  
31
        public void Run()
32
        {
33

  
34
        }
11 35
    }
12 36
}
DTI_PID/SPPIDAutoModeling/ItemObject.cs
16 16
        TEXT = 4,
17 17
    }
18 18

  
19
    
19
    public class Group
20
    {
21
        private List<Symbol> _SYMBOLS = new List<Symbol>();
22
        private List<Line> _LINES = new List<Line>();
23

  
24
        public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; }
25
        public List<Line> LINES { get => _LINES; set => _LINES = value; }
26
    }
20 27

  
21 28
    public class Drawing
22 29
    {
......
24 31
        private string _DWGNAME;
25 32
        private string _SIZE;
26 33
        private string _UNIT;
27
        private List<Symbol> _SYMBOLS;
28
        private List<Line> _LINES;
29
        private List<LineNumber> _LINENUMBERS;
30
        private List<Text> _TEXTS;
34
        private List<Symbol> _SYMBOLS = new List<Symbol>();
35
        private List<Line> _LINES = new List<Line>();
36
        private List<LineNumber> _LINENUMBERS = new List<LineNumber>();
37
        private List<Text> _TEXTS = new List<Text>();
31 38
        private Dictionary<string, List<PointdInfo>> _PipeRunPoint = new Dictionary<string, List<PointdInfo>>();
39
        private List<Group> _GROUP = new List<Group>();
40

  
41
        private double _WIDTH;
42
        private double _HEIGHT;
32 43

  
33 44
        public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; }
34
        public string SIZE { get => _SIZE; set => _SIZE = value; }
45
        public string SIZE
46
        {
47
            get { return _SIZE; }
48
            set
49
            {
50
                _SIZE = value;
51
                SPPIDUtill.ConvertPointBystring(_SIZE, ref _WIDTH, ref _HEIGHT);
52
            }
53
        }
35 54
        public string UNIT { get => _UNIT; set => _UNIT = value; }
36 55
        public Dictionary<string, List<PointdInfo>> PipeRunPoint { get => _PipeRunPoint; set => _PipeRunPoint = value; }
37 56
        public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; }
38 57
        public List<Line> LINES { get => _LINES; set => _LINES = value; }
39 58
        public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; }
40 59
        public List<Text> TEXTS { get => _TEXTS; set => _TEXTS = value; }
60
        public double WIDTH { get => _WIDTH; set => _WIDTH = value; }
61
        public double HEIGHT { get => _HEIGHT; set => _HEIGHT = value; }
62
        public List<Group> GROUP { get => _GROUP; set => _GROUP = value; }
41 63
        #endregion
42 64
    }
43 65
    public class PointdInfo
44 66
    {
45 67
        public enum PointType
46 68
        {
47

  
69
            None = 0,
70
            Run = 1,
71
            Branch = 2,
48 72
        }
49 73
        #region Property
50 74
        private Pointd _Pointd;
......
91 115
        public SPPID_ITEM_TYPE SPPID_TYPE { get => _SPPID_TYPE; set => _SPPID_TYPE = value; }
92 116
        public List<Attribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; }
93 117
        #endregion
94
        public abstract void Modeling(Drawing drawing);
118

  
119
        public abstract void Modeling();
95 120
        public abstract void AfterSetting();
96 121
        public abstract void SetAttribute();
97 122
    }
......
100 125
    {
101 126
        #region Property
102 127
        private string _ORIGINALPOINT;
103
        private List<Connector> _CONNECTORS;
128
        private List<Connector> _CONNECTORS = new List<Connector>();
104 129
        private string _LOCATION;
105 130
        private string _SIZE;
106 131
        private double _ANGLE;
......
143 168
            // End
144 169

  
145 170
            // Location Setting
171
            SPPIDUtill.ConvertPointBystring(_ORIGINALPOINT, ref _LOCATION_X, ref _LOCATION_Y);
172
            SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
173
            // End
146 174

  
147

  
175
            // SPPID  Type Setting
176
            SPPID_TYPE = SPPID_ITEM_TYPE.SYMBOL;
148 177
            // End
149 178
        }
150 179

  
151
        public override void Modeling(Drawing drawing)
180
        public override void Modeling()
152 181
        {
153
            throw new NotImplementedException();
182
            try
183
            {
184
                Placement _placement = new Placement();
185
                LMSymbol lmSymbol = null;
186
                SPPID_ITEM_OBJECT = null;
187

  
188
                if (!string.IsNullOrEmpty(SPPIDMAPPINGNAME))
189
                {
190
                    LMSymbol connectedSymbol = null;
191
                    foreach (Connector connector in CONNECTORS)
192
                    {
193
                        if (!string.IsNullOrEmpty(connector.CONNECTEDITEM) || connector.CONNECTEDITEM != "None")
194
                        {
195
                            object _obj = SPPIDUtill.FindObjectByUID(connector.CONNECTEDITEM);
196
                            if (_obj != null && typeof(Symbol) == _obj.GetType())
197
                            {
198
                                Symbol _symbol = _obj as Symbol;
199
                                if (_symbol.SPPID_ITEM_OBJECT != null)
200
                                    connectedSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol;
201
                            }
202
                        }
203
                    }
204

  
205
                    if (connectedSymbol != null)
206
                        lmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Mirror: MIRROR, Rotation: ANGLE, TargetItem: connectedSymbol);
207
                    else
208
                        lmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Mirror: MIRROR, Rotation: ANGLE);
209

  
210
                    // Commit and input sppid item object
211
                    lmSymbol.Commit();
212
                    SPPID_ITEM_OBJECT = lmSymbol;
213
                    // End
214

  
215
                    // Check Child And Modeling
216
                    foreach (string sChild in CHILD)
217
                    {
218
                        try
219
                        {
220
                            string[] arrChild = sChild.Split(new char[',']);
221
                            string sArrow = arrChild[0];
222
                            string sMappingName = arrChild[1];
223

  
224
                            double dChildAngle = 0;
225
                            if (sArrow == "UP")
226
                                dChildAngle = 0;
227
                            else if (sArrow == "RIGHT")
228
                                dChildAngle = 90 * Math.PI / 180;
229
                            else if (sArrow == "DOWN")
230
                                dChildAngle = Math.PI;
231
                            else
232
                                dChildAngle = 270 * Math.PI / 180;
233

  
234
                            LMSymbol _childLmSymbol = _placement.PIDPlaceSymbol(sMappingName, LOCATION_X, LOCATION_Y, Mirror: 0, Rotation: dChildAngle, TargetItem: SPPID_ITEM_OBJECT);
235
                            _childLmSymbol.Commit();
236
                            CHILD_SPPID_ITEM_OBJECT.Add(_childLmSymbol);
237
                        }
238
                        catch (Exception)
239
                        {
240
                            
241
                        }
242
                    }
243
                    // End
244
                }
245
            }
246
            catch (Exception)
247
            {
248

  
249
            }
154 250
        }
155 251

  
156 252
        public override void SetAttribute()
......
171 267
        #region Property
172 268
        private string _STARTPOINT;
173 269
        private string _ENDPOINT;
174
        private List<Connector> _CONNECTORS;
270
        private List<Connector> _CONNECTORS = new List<Connector>();
175 271
        private string _LMCONNECTOR_MODELID;
176 272
        private SlopType _SLOPTYPE;
177 273
        private double _START_X;
......
191 287
        #endregion
192 288
        public override void AfterSetting()
193 289
        {
194
            throw new NotImplementedException();
290
            // Point Setting
291
            SPPIDUtill.ConvertPointBystring(_STARTPOINT, ref _START_X, ref _START_Y);
292
            SPPIDUtill.ConvertSPPIDPoint(ref _START_X, ref _START_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
293
            SPPIDUtill.ConvertPointBystring(_ENDPOINT, ref _END_X, ref _END_Y);
294
            SPPIDUtill.ConvertSPPIDPoint(ref _END_X,ref _END_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
295
            // End
296

  
297
            // Slop Setting
298
            _SLOPTYPE = SPPIDUtill.CalcSlop(new Pointd(_START_X, _START_Y), new Pointd(_END_X, _END_Y));
299
            // End
300

  
301
            // SPPID Type Setting
302
            SPPID_TYPE = SPPID_ITEM_TYPE.LINE;
303
            // End
195 304
        }
196 305

  
197
        public override void Modeling(Drawing drawing)
306
        public override void Modeling()
198 307
        {
199
            throw new NotImplementedException();
308
            throw new MissingMethodException();
200 309
        }
201 310

  
202 311
        public override void SetAttribute()
......
213 322
            TrimLine = 2,
214 323
        }
215 324
        #region Property
216
        private string _ANGLE;
325
        private double _ANGLE;
217 326
        private string _LOCATION;
218 327
        private double _LOCATION_X;
219 328
        private double _LOCATION_Y;
......
222 331
        private Line _TARGETLINE;
223 332
        private LineNumberType _LINENUMBERTYPE;
224 333

  
225
        public string ANGLE { get => _ANGLE; set => _ANGLE = value; }
334
        public double ANGLE { get => _ANGLE; set => _ANGLE = value; }
226 335
        public string LOCATION { get => _LOCATION; set => _LOCATION = value; }
227 336
        public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; }
228 337
        public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; }
......
234 343

  
235 344
        public override void AfterSetting()
236 345
        {
237
            throw new NotImplementedException();
346
            // Angle Setting
347
            if (ANGLE == 1.57)
348
                ANGLE = 90 * Math.PI / 180;
349
            else if (ANGLE == 3.14)
350
                ANGLE = Math.PI;
351
            else if (ANGLE == 4.71)
352
                ANGLE = 270 * Math.PI / 180;
353
            else
354
                ANGLE = 0;
355
            // End
356

  
357
            // Location Setting
358
            SPPIDUtill.ConvertPointBystring(_LOCATION, ref _LOCATION_X, ref _LOCATION_Y);
359
            SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
360
            // End
361

  
362
            // SPPID  Type Setting
363
            SPPID_TYPE = SPPID_ITEM_TYPE.LABEL;
364
            // End
238 365
        }
239 366

  
240
        public override void Modeling(Drawing drawing)
367
        public override void Modeling()
241 368
        {
242
            throw new NotImplementedException();
369
            try
370
            {
371
                if (TARGETLINE != null && !string.IsNullOrEmpty(TARGETLINE.LMCONNECTOR_MODELID))
372
                {
373
                    Placement _placement = new Placement();
374
                    Array points = new double[] { LOCATION_X, LOCATION_Y };
375
                    LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(TARGETLINE.LMCONNECTOR_MODELID);
376
                    if (_pipeRun != null)
377
                    {
378
                        foreach (LMRepresentation rep in _pipeRun.Representations)
379
                        {
380
                            if (rep.get_RepresentationType() == "Connector" && rep.get_ItemStatus() == "Active")
381
                            {
382
                                LMConnector _LmConnector = _placement.PIDDataSource.GetConnector(rep.Id);
383
                                LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref points, Rotation: ANGLE, LabeledItem: _LmConnector.AsLMRepresentation(), IsLeaderVisible: true);
384
                                _LmLabelPresist.Commit();
385
                                SPPID_ITEM_OBJECT = _LmLabelPresist;
386
                            }
387
                        }
388
                    }
389
                }
390
            }
391
            catch (Exception)
392
            {
393

  
394
            }
243 395
        }
244 396

  
245 397
        public override void SetAttribute()
......
251 403
    public class Text : SPPID_ITEM
252 404
    {
253 405
        #region Property
254
        private string _ANGLE;
406
        private double _ANGLE;
255 407
        private string _LOCATION;
256
        private string _LOCATION_X;
257
        private string _LOCATION_Y;
408
        private double _LOCATION_X;
409
        private double _LOCATION_Y;
258 410
        private string _TEXT;
259 411
        private string _OWNER;
260 412

  
261
        public string ANGLE { get => _ANGLE; set => _ANGLE = value; }
413
        public double ANGLE { get => _ANGLE; set => _ANGLE = value; }
262 414
        public string LOCATION { get => _LOCATION; set => _LOCATION = value; }
263
        public string LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; }
264
        public string LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; }
415
        public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; }
416
        public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; }
265 417
        public string TEXT { get => _TEXT; set => _TEXT = value; }
266 418
        public string OWNER { get => _OWNER; set => _OWNER = value; }
267 419
        #endregion
268 420
        public override void AfterSetting()
269 421
        {
270
            throw new NotImplementedException();
422
            // Angle Setting
423
            if (ANGLE == 1.57)
424
                ANGLE = 90 * Math.PI / 180;
425
            else if (ANGLE == 3.14)
426
                ANGLE = Math.PI;
427
            else if (ANGLE == 4.71)
428
                ANGLE = 270 * Math.PI / 180;
429
            else
430
                ANGLE = 0;
431
            // End
432

  
433
            // Location Setting
434
            SPPIDUtill.ConvertPointBystring(_LOCATION, ref _LOCATION_X, ref _LOCATION_Y);
435
            SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT);
436
            // End
437

  
438
            // SPPID  Type Setting
439
            SPPID_TYPE = SPPID_ITEM_TYPE.TEXT;
440
            // End
271 441
        }
272 442

  
273
        public override void Modeling(Drawing drawing)
443
        public override void Modeling()
274 444
        {
275
            throw new NotImplementedException();
445
            try
446
            {
447
                Placement _placement = new Placement();
448
                if (NAME == "TEXT")
449
                {
450
                    LMSymbol _LmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Rotation: ANGLE);
451
                    LMItemNote _LmItemNote = _placement.PIDDataSource.GetItemNote(_LmSymbol.ModelItemID);
452
                    _LmItemNote.Attributes["Note.Body"].set_Value(TEXT);
453
                    _LmItemNote.Commit();
454
                    SPPID_ITEM_OBJECT = _LmItemNote;
455
                }
456
                else if (NAME == "SIZE" && !string.IsNullOrEmpty(OWNER))
457
                {
458
                    object _obj = SPPIDUtill.FindObjectByUID(OWNER);
459

  
460
                    Array array = new double[] { LOCATION_X, LOCATION_Y };
461

  
462
                    if (typeof(Symbol) == _obj.GetType())
463
                    {
464
                        Symbol _symbol = _obj as Symbol;
465
                        LMSymbol _LmSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol;
466

  
467
                        string fileName = _LmSymbol.get_FileName();
468
                        if (fileName.Contains("Piping"))
469
                            SPPIDMAPPINGNAME = @"\Piping\Labels - Piping Components\Nominal Diameter.sym";
470
                        else if (fileName.Contains("Instrumentation"))
471
                            SPPIDMAPPINGNAME = @"\Instrumentation\Labels - General Instrument\Nominal Diameter.sym";
472

  
473
                        LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref array, Rotation: ANGLE, LabeledItem: _LmSymbol.AsLMRepresentation(), IsLeaderVisible: true);
474
                        _LmLabelPersist.Commit();
475

  
476
                        SPPID_ITEM_OBJECT = _LmLabelPersist;
477
                    }
478
                }
479
            }
480
            catch (Exception)
481
            {
482

  
483
            }
276 484
        }
277 485

  
278 486
        public override void SetAttribute()
DTI_PID/SPPIDAutoModeling/SPPIDUtill.cs
6 6

  
7 7
namespace SPPIDAutoModeling
8 8
{
9
    public class SPPIDUtill
9
    public static class SPPIDUtill
10 10
    {
11 11
        private static readonly double _DWG_X = 0.875;
12 12
        private static readonly double _DWG_Y = 0.617;
......
15 15
        {
16 16
            double calcX = 0;
17 17
            double calcY = 0;
18
            calcX = (dX * _DWG_X) / dDwgY;
18
            calcX = (dX * _DWG_X) / dDwgX;
19 19
            calcX = Math.Truncate(calcX * 1000) / 1000;
20 20
            calcY = _DWG_Y - ((dY * _DWG_Y) / dDwgY);
21 21
            calcY = Math.Truncate(calcY * 1000) / 1000;
22 22
            dX = calcX;
23 23
            dY = calcY;
24 24
        }
25

  
26
        public static bool ConvertPointBystring(string sPoint, ref double dX, ref double dY)
27
        {
28
            try
29
            {
30
                string[] pointArr = sPoint.Split(new char[] { ',' });
31
                if (pointArr.Length == 2)
32
                {
33
                    dX = Convert.ToDouble(pointArr[0]);
34
                    dY = Convert.ToDouble(pointArr[1]);
35
                }
36
            }
37
            catch (Exception)
38
            {
39
                dX = 0;
40
                dY = 0;
41
                return false;
42
            }
43
                
44
            return true;
45
        }
46

  
47
        public static Line.SlopType CalcSlop(Pointd point1, Pointd point2)
48
        {
49
            Line.SlopType _type = Line.SlopType.NONE;
50

  
51
            if (point1.X - point2.X == 0)
52
                _type = Line.SlopType.VERTICAL;
53
            else
54
            {
55
                double angle = Math.Atan(Math.Abs(point2.Y - point1.Y) / Math.Abs(point2.X - point1.X)) * 180 / Math.PI;
56
                if (angle < 20)
57
                    _type = Line.SlopType.HORIZONTAL;
58
                else if (angle > 70)
59
                    _type = Line.SlopType.VERTICAL;
60
                else
61
                    _type = Line.SlopType.SLOPE;
62
            }
63

  
64
            return _type;
65
        }
66

  
67
        public static object FindObjectByUID(string UID)
68
        {
69
            foreach (Symbol item in AutoModeling.DrawingItem.SYMBOLS)
70
            {
71
                if (item.UID == UID)
72
                    return item;
73
            }
74

  
75
            foreach (Line item in AutoModeling.DrawingItem.LINES)
76
            {
77
                if (item.UID == UID)
78
                    return item;
79
            }
80

  
81
            return null;
82
        }
25 83
    }
26 84
}
DTI_PID/SPPIDConverter/Drawing.vb
1101 1101
        '' end
1102 1102
    End Sub
1103 1103

  
1104

  
1105 1104
    Public Overrides Sub Modeling()
1106 1105
        Try
1107 1106
            Dim _Placement As Placement = New Placement
......
1135 1134
            Console.WriteLine(ex.Message)
1136 1135
        End Try
1137 1136
    End Sub
1137

  
1138 1138
    Public Overrides Sub SetAttribute()
1139 1139
        Try
1140 1140
            Dim _obj As Object = FindObjectByUID(OWNER)
DTI_PID/SPPIDConverter/SPPIDConverter.vbproj
56 56
      <SpecificVersion>False</SpecificVersion>
57 57
      <HintPath>.\ComUtil.MessageLog.dll</HintPath>
58 58
    </Reference>
59
    <Reference Include="DevExpress.Data.v18.1, Version=18.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
60
    <Reference Include="DevExpress.Printing.v18.1.Core, Version=18.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
61
    <Reference Include="DevExpress.Utils.v18.1, Version=18.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
62
    <Reference Include="DevExpress.XtraEditors.v18.1, Version=18.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
63
    <Reference Include="DevExpress.XtraGrid.v18.1, Version=18.1.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
64 59
    <Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
65 60
      <HintPath>..\packages\EntityFramework.6.0.0\lib\net45\EntityFramework.dll</HintPath>
66 61
    </Reference>

내보내기 Unified diff