프로젝트

일반

사용자정보

개정판 932933ed

ID932933edbd9b3d89a087e75cccc9be05eaa7c4d3
상위 ff4941b2
하위 697d4c61

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

dev issue #1230 : Linenumber modeling

Change-Id: I15a1e7458d6b0f76032dbad0e1d4a48aeba9bf15

차이점 보기:

DTI_PID/APIDConverter/APIDConverterExplorer.cs
33 33

  
34 34
        private void btnOpenConverter_Click(object sender, EventArgs e)
35 35
        {
36
            
36 37
            APIDConverter form = new APIDConverter();
37 38
            if (AcadApp.ShowModalDialog(form) == DialogResult.OK)
38 39
            {
39
                System.Data.DataTable avevaSymbolTable = Project_DB.SelectSymbolTable();
40

  
41
                foreach (var item in form.Documents)
40
                try
42 41
                {
43
                    AutoModeling autoModeling = new AutoModeling(item, avevaSymbolTable);
44
                    autoModeling.CreateDrawing();
42
                    AccessPropertyForm.Run();
43
                    System.Data.DataTable avevaSymbolTable = Project_DB.SelectSymbolTable();
44

  
45
                    foreach (var item in form.Documents)
46
                    {
47
                        AutoModeling autoModeling = new AutoModeling(item, avevaSymbolTable);
48
                        autoModeling.CreateDrawing();
49
                    }
50

  
51
                    MessageBox.Show("End Conversion", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information);
45 52
                }
53
                catch (Exception ex)
54
                {
46 55

  
47
                MessageBox.Show("End Conversion", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information);
56
                }
57
                finally
58
                {
59
                    AccessPropertyForm.Stop();
60
                }
61
                
48 62
            }
49 63
        }
50 64

  
DTI_PID/APIDConverter/AVEVA.PID.CustomizationUtility_ACAD2018_x64.csproj
142 142
    <Reference Include="WindowsBase" />
143 143
  </ItemGroup>
144 144
  <ItemGroup>
145
    <Compile Include="Utils\AccessPropertyForm.cs" />
145 146
    <Compile Include="APIDConverterExplorer.cs">
146 147
      <SubType>UserControl</SubType>
147 148
    </Compile>
148 149
    <Compile Include="APIDConverterExplorer.Designer.cs">
149 150
      <DependentUpon>APIDConverterExplorer.cs</DependentUpon>
150 151
    </Compile>
152
    <Compile Include="AvevaACAD18String.cs" />
151 153
    <Compile Include="DB\Project_DB.cs" />
152 154
    <Compile Include="Form\ProjectForm.cs">
153 155
      <SubType>Form</SubType>
......
162 164
      <DependentUpon>APIDSplashScreen.cs</DependentUpon>
163 165
    </Compile>
164 166
    <Compile Include="Log.cs" />
167
    <Compile Include="Model\PlantItem\Other\AvevaLabelInfo.cs" />
165 168
    <Compile Include="Model\PlantItem\OPC.cs" />
166 169
    <Compile Include="Model\PlantItem\Other\AvevaSymbolInfo.cs" />
167 170
    <Compile Include="Model\PlantItem\Other\AvevaLineInfo.cs" />
DTI_PID/APIDConverter/AutoModeling.cs
100 100
            try
101 101
            {
102 102
                SplashScreenManager.ShowForm(typeof(APIDSplashScreen), true, true);
103
                SplashScreenManager.Default.SendCommand(APIDSplashScreen.SplashScreenCommand.SetAllStepCount, 2);
103
                SplashScreenManager.Default.SendCommand(APIDSplashScreen.SplashScreenCommand.SetAllStepCount, 3);
104 104
                SplashScreenManager.Default.SendCommand(APIDSplashScreen.SplashScreenCommand.SetDocumentName, document.AvevaDrawingNumber + document.AvevaSheetNumber);
105
                SplashScreenManager.Default.SendCommand(APIDSplashScreen.SplashScreenCommand.SetParent, Autodesk.AutoCAD.ApplicationServices.Application.MainWindow.Handle);
106

  
105 107
                SetConvertRule();
106 108

  
107 109
                RunLineModeling();
108 110
                RunOPCModeling();
109 111
                RunSymbolModeling();
112

  
113

  
110 114
            }
111 115
            catch (System.Exception ex)
112 116
            {
......
114 118
            }
115 119
            finally
116 120
            {
121
                SplashScreenManager.Default.SendCommand(APIDSplashScreen.SplashScreenCommand.ClearParent, null);
117 122
                SplashScreenManager.CloseForm(false);
118 123
            }
119 124
        }
......
163 168
            GetConnectedGroupLine(line, groupLine, false);
164 169
            GetGroupLinePoints(groupLine, points);
165 170

  
171
            LineNumber lineNumber = null;
172
            if (line.Aveva.Type == Model.Type.Pipe)
173
            {
174
                foreach (var item in groupLine)
175
                {
176
                    lineNumber = document.LINENUMBERS.Find(x => x.CONNLINE == item.UID);
177
                    if (lineNumber != null)
178
                    {
179
                        GUIUtils.SetAutoLabelCheck(true);
180
                        break;
181
                    }
182
                }
183
            }
184

  
185

  
166 186
            long handle = 0;
167 187
            if (line.Aveva.Type == Model.Type.Pipe)
168
                handle = DrawPipe(line.Aveva.Name, points);
188
                handle = DrawPipe(line.Aveva.Name, points, lineNumber);
169 189
            else if (line.Aveva.Type == Model.Type.Signal)
170 190
                handle = DrawSignal(line.Aveva.Name, points);
171 191

  
192
            if (lineNumber != null)
193
                GUIUtils.SetAutoLabelCheck(false);
194

  
172 195
            foreach (var item in groupLine)
173 196
                item.Aveva.Handle = handle;
174 197
        }
......
200 223
        #endregion
201 224

  
202 225
        #region Drawing Method
203
        private long DrawPipe(string style, List<string> coordinates)
226
        private long DrawPipe(string style, List<string> coordinates, LineNumber lineNumber = null)
204 227
        {
205 228
            List<long> prevHandles = GetAllGroupHandles();
206 229

  
......
213 236
            //coordinate
214 237
            foreach (var item in coordinates)
215 238
                commandParam.Add(item);
216
            //enter
217
            commandParam.Add(null);
218
            //enter
239

  
240
            //enter Parent(null)
219 241
            commandParam.Add(null);
220 242

  
243
            if (lineNumber != null)
244
            {
245
                Point3d point = new Point3d(lineNumber.Aveva.X, lineNumber.Aveva.Y, 0);
246
                commandParam.Add(point);
247
                commandParam.Add(lineNumber.ANGLE);
248

  
249
                commandParam.Add(null);
250
            }
251
            else
252
                commandParam.Add(null);
253

  
221 254
            editor.Command(commandParam.ToArray());
222 255

  
223 256
            List<long> newHandles = GetAllGroupHandles();
......
675 708
            //InitGUI();
676 709
            //DrawSignal("SONIC", new List<string>() { "2,100", "100,100" });
677 710

  
678
            DrawPipe("Main Pipe", new List<string>() { "2,100", "100,100" });
711
            DrawPipe("Main Pipe", new List<string>() { "2,100", "100,100" }, null);
712
            return;
679 713
            Symbol symbol = new Symbol();
680 714
            symbol.Aveva = new AvevaSymbolInfo();
681 715
            symbol.Aveva.Name = "INVB";
DTI_PID/APIDConverter/Form/APIDSplashScreen.cs
81 81
            {
82 82
                currentCount--;
83 83
            }
84

  
85
            //if (!IsTopMost)
86
            //    this.TopMost = true;
87 84
        }
88 85

  
89 86
        [DllImport("user32.dll", SetLastError = true)]
DTI_PID/APIDConverter/Model/PlantItem/Document.cs
606 606
                else
607 607
                    result = false;
608 608
            }
609

  
610 609
            foreach (var item in SYMBOLS)
611 610
            {
612 611
                DataRow[] rows = symbolMappingTable.Select(string.Format("UID = '{0}'", item.DBUID));
......
628 627
                else
629 628
                    result = false;
630 629
            }
631

  
632 630
            foreach (var item in OPCs)
633 631
            {
634 632
                DataRow[] rows = opcMappingTable.Select(string.Format("UID = '{0}'", item.DBUID));
......
676 674
                else
677 675
                    result = false;
678 676
            }
677
            foreach (var item in LINENUMBERS)
678
            {
679
                item.Aveva = new AvevaLabelInfo();
680
                double x = (item.X1 + item.X2) / 2;
681
                double y = SIZE_HEIGHT - (item.Y1 + item.Y2) / 2;
682

  
683
                ConvertAvevaPoint(ref x, ref y);
684

  
685
                item.Aveva.X = x;
686
                item.Aveva.Y = y;
687
                item.Aveva.LabelType = LabelType.LineNumber;
688
            }
679 689

  
680 690
            return result;
681 691
        }
DTI_PID/APIDConverter/Model/PlantItem/LineNumber.cs
69 69
        public double X2 { get; set; }
70 70
        public double Y1 { get; set; }
71 71
        public double Y2 { get; set; }
72

  
73
        public AvevaLabelInfo Aveva { get; set; }
72 74
    }
73 75
}
DTI_PID/APIDConverter/Model/PlantItem/Other/AvevaLabelInfo.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace AVEVA.PID.CustomizationUtility.Model
8
{
9
    public enum LabelType
10
    {
11
        None,
12
        Text,
13
        LineNumber
14
    }
15
    public class AvevaLabelInfo
16
    {
17
        public LabelType LabelType { get; set; }
18
        public double X { get; set; }
19
        public double Y { get; set; }
20
    }
21
}
DTI_PID/APIDConverter/PIDCustomization.cs
175 175
        {
176 176
            if (AutoModeling.Running != null)
177 177
            {
178
                GUIUtils.SetAutoLabelUnCehck();
178
                GUIUtils.SetAutoLabelCheck(false);
179 179
                AutoModeling.Running.Run();
180 180
            }
181 181
        }
......
419 419
        [CommandMethod("TestS", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)]
420 420
        public static void TestSelection()
421 421
        {
422
            GUIUtils.SetAutoLabelUnCehck();
423
            //APIDUtils.CreateDrawingAndOpen("testA1", "1", "Aveva-Metric", "1");
422
            AccessPropertyForm.Run();
423

  
424
            //GUIUtils.SetAutoLabelCheck(false);
425
            ////APIDUtils.CreateDrawingAndOpen("testA1", "1", "Aveva-Metric", "1");
424 426
            AutoModeling.TESTStatic();
427

  
428
            AccessPropertyForm.Stop();
425 429
        }
426 430

  
427 431
        [CommandMethod("PicTest", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)]
DTI_PID/APIDConverter/Utils/AccessPropertyForm.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Runtime.InteropServices;
5
using System.Text;
6
using System.Threading.Tasks;
7
using System.Threading;
8

  
9
namespace AVEVA.PID.CustomizationUtility
10
{
11
    class AccessPropertyForm
12
    {
13
        [DllImport("user32")]
14
        public static extern int FindWindow(string lpClassName, string lpWindowName);
15
        [DllImport("user32.dll")]
16
        public static extern int FindWindowEx(int hWnd1, int hWnd2, string lpsz1, string lpsz2);
17
        [DllImport("user32")]
18
        public static extern int SendMessage(IntPtr hWnd, int uMsg, IntPtr WParam, IntPtr LParam);
19

  
20
        const int BM_CLICK = 0x00F5;
21

  
22
        private static bool run;
23

  
24
        public static void Run()
25
        {
26
            run = true;
27
            Thread thread = new Thread(loop => {
28
                while (run)
29
                {
30
                    CloseForm();
31
                }
32
            });
33
            thread.IsBackground = true;
34
            thread.Start();
35
        }
36

  
37
        public static void Stop()
38
        {
39
            run = false;
40
        }
41

  
42
        public static void CloseForm()
43
        {
44
            try
45
            {
46
                int handle = FindWindow(null, AvevaACAD18String.PipePropertyUI);
47
                if (handle > 0)
48
                {
49
                    int button = FindWindowEx(handle, 0, null, "Ok");
50
                    if (button > 0)
51
                    {
52
                        Thread.Sleep(500);
53
                        SendMessage((IntPtr)button, BM_CLICK, (IntPtr)0, (IntPtr)0);
54
                        Thread.Sleep(2000);
55
                    }
56
                }
57
                Thread.Sleep(1000);
58
            }
59
            catch (Exception ex)
60
            {
61

  
62
            }
63
        }
64
    }
65
}
DTI_PID/APIDConverter/Utils/AvevaACAD18String.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6

  
7
namespace AVEVA.PID.CustomizationUtility
8
{
9
    public static class AvevaACAD18String
10
    {
11
        public const string PipePropertyUI = "AVEVA P&ID 12 Pipe Properties";
12
    }
13
}
DTI_PID/APIDConverter/Utils/GUIUtils.cs
30 30
            return null;
31 31
        }
32 32
        
33
        public static void SetAutoLabelUnCehck()
33
        public static void SetAutoLabelCheck(bool check)
34 34
        {
35 35
            Autodesk.Windows.RibbonChecklistButton autoLabelCheckListButton = null;
36 36
            Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_PIPE_PANEL");
......
46 46
                    {
47 47
                        Autodesk.Windows.RibbonButton ribbonButton = item as Autodesk.Windows.RibbonButton;
48 48
                        if (ribbonButton.IsChecked)
49
                            ribbonButton.IsChecked = false;
49
                            ribbonButton.IsChecked = check;
50 50
                    }
51 51
                }
52 52
            }
53

  
54
            DrawingUtilities.bPipeLabel = false;
55
            DrawingUtilities.bEquipLabel = false;
56
            DrawingUtilities.bNozzleLabel = false;
57
            DrawingUtilities.bInstrLabel = false;
58
            DrawingUtilities.bValveLabel = false;
59
            DrawingUtilities.bReducerLabel = false;
60
            DrawingUtilities.bLinefittingLabel = false;
53
            
54
            DrawingUtilities.bPipeLabel = check;
55
            DrawingUtilities.bEquipLabel = check;
56
            DrawingUtilities.bNozzleLabel = check;
57
            DrawingUtilities.bInstrLabel = check;
58
            DrawingUtilities.bValveLabel = check;
59
            DrawingUtilities.bReducerLabel = check;
60
            DrawingUtilities.bLinefittingLabel = check;
61 61

  
62 62
            DrawingData drawingData = new DrawingData();
63 63
            drawingData.AutoLabelPipe = DrawingUtilities.bPipeLabel;

내보내기 Unified diff

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