프로젝트

일반

사용자정보

개정판 1c5bd296

ID1c5bd29630f0df82507f4f7e04c75c7aa561b449
상위 14540282
하위 879c9cb7, 9dab7146

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

dev issue #1229 : 도면 생성 후 Modeling 기능

Change-Id: Ia70cbd97060743fbb19338724a129cc3ef3b36ba

차이점 보기:

DTI_PID/APIDConverter/APIDConverterExplorer.cs
20 20
        public APIDConverterExplorer()
21 21
        {
22 22
            InitializeComponent();
23

  
24
            Autodesk.AutoCAD.Interop.AcadApplication acadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as Autodesk.AutoCAD.Interop.AcadApplication;
25
            Autodesk.AutoCAD.Interop._DAcadApplicationEvents_NewDrawingEventHandler handler = new Autodesk.AutoCAD.Interop._DAcadApplicationEvents_NewDrawingEventHandler(CommandEnded);
26
            acadApplication.NewDrawing += handler;
27
        }
28
        public static void CommandEnded()
29
        {
30

  
31 23
        }
32 24

  
33 25
        private void btnOpenConverter_Click(object sender, EventArgs e)
......
38 30
                foreach (var item in form.Documents)
39 31
                {
40 32
                    AutoModeling autoModeling = new AutoModeling(item);
41
                    autoModeling.Run();
33
                    autoModeling.CreateDrawing();
42 34
                }
43 35
            }
44 36
        }
DTI_PID/APIDConverter/AutoModeling.cs
16 16
using Autodesk.AutoCAD.Runtime;
17 17
using Autodesk.AutoCAD.Windows;
18 18

  
19
using AVEVA.PID.Components;
20
using AVEVA.PID.GUI;
21
using AVEVA.PID.Common;
22
using AVEVA.PID.DWGSelector;
23

  
19 24
using AVEVA.PID.CustomizationUtility.DB;
20 25
using AVEVA.PID.CustomizationUtility.Model;
21 26
using AVEVA.PID.CustomizationUtility.Properties;
......
24 29
{
25 30
    public class AutoModeling
26 31
    {
32
        public static AutoModeling Running { get; set; }
27 33
        Model.Document document;
28 34

  
29 35
        public AutoModeling(Model.Document document)
......
31 37
            this.document = document;
32 38
        }
33 39

  
34
        public void Run()
40
        public void CreateDrawing()
35 41
        {
36
            if (APIDUtils.CreateDrawingAndOpen(document.AvevaDrawingNumber, document.AvevaSheetNumber, document.AvevaTemplateName, document.AvevaTemplateID))
42
            string outPath = Project_DB.GetDirectiveValue("DRGPTH");
43
            string tempPath = Path.GetTempPath();
44
            string selectedFullPath = Path.Combine(tempPath, document.AvevaTemplateName + ".DWT");
45

  
46
            DWTSelector.strDrawingNumber = document.AvevaDrawingNumber;
47
            DWTSelector.strSheetNumber = document.AvevaSheetNumber;
48
            DWTSelector.strCadFileName = document.AvevaDrawingNumber + document.AvevaSheetNumber;
49
            DWTSelector.strCadFilePath = outPath;
50

  
51
            try
52
            {
53
                string text = ReadWriteDrawingData.ReadTemplateData(document.AvevaTemplateName, document.AvevaTemplateID, selectedFullPath, false);
54
                Autodesk.AutoCAD.Interop.AcadApplication acadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as Autodesk.AutoCAD.Interop.AcadApplication;
55
                Autodesk.AutoCAD.Interop.AcadDocument acadDocument = acadApplication.Documents.Add(text);
56

  
57
                Commands.addLatestPidvesrionToDictionary();
58
                AVVPropCmd.ActivateAcad();
59

  
60
                if (acadDocument != null)
61
                {
62
                    Running = this;
63
                    acadApplication.ActiveDocument = acadDocument;
64
                    acadDocument.SendCommand("QSAVE ");
65
                    acadDocument.SendCommand("APPIDRun ");
66
                    Running = null;
67
                }
68
            }
69
            catch (System.Exception ex)
37 70
            {
38
                test();
71
                
39 72
            }
73

  
74
            GC.Collect();
75
        }
76
        public void Run()
77
        {
78
            test();
40 79
        }
41 80

  
42 81
        private string ReadDrawingLastLine()
DTI_PID/APIDConverter/PIDCustomization.cs
170 170

  
171 171
            }
172 172
        }
173
        [CommandMethod("APPIDRun")]
174
        public static void APIDRun()
175
        {
176
            if (AutoModeling.Running != null)
177
            {
178
                GUIUtils.SetAutoLabelUnCehck();
179
                AutoModeling.Running.Run();
180
            }
181
        }
173 182
        #endregion
174 183
        #region private methods
175 184
        private string SaveBinaryDrawing()
......
410 419
        [CommandMethod("TestS", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)]
411 420
        public static void TestSelection()
412 421
        {
422
            
413 423
            //APIDUtils.CreateDrawingAndOpen("testA1", "1", "Aveva-Metric", "1");
414 424
            AutoModeling.TEST();
415 425
        }
DTI_PID/APIDConverter/Utils/APIDUtils.cs
111 111

  
112 112
            return list;
113 113
        }
114
        public static bool CreateDrawingAndOpen(string drawingNumber, string sheetNumber, string templateName, string templateId)
115
        {
116
            bool result = true;
117
            string outPath = Project_DB.GetDirectiveValue("DRGPTH");
118
            string tempPath = Path.GetTempPath();
119
            string selectedFullPath = Path.Combine(tempPath, templateName + ".DWT");
120

  
121
            DWTSelector.strDrawingNumber = drawingNumber;
122
            DWTSelector.strSheetNumber = sheetNumber;
123
            DWTSelector.strCadFileName = drawingNumber + sheetNumber;
124
            DWTSelector.strCadFilePath = outPath;
125

  
126
            try
127
            {
128
                string text = ReadWriteDrawingData.ReadTemplateData(templateName, templateId, selectedFullPath, false);
129
                Autodesk.AutoCAD.Interop.AcadApplication acadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as Autodesk.AutoCAD.Interop.AcadApplication;
130
                Autodesk.AutoCAD.Interop.AcadDocument acadDocument = acadApplication.Documents.Add(text);
131

  
132
                Commands.addLatestPidvesrionToDictionary();
133
                AVVPropCmd.ActivateAcad();
134
                acadApplication.ActiveDocument = acadDocument;
135

  
136
                acadDocument.SendCommand("QSAVE ");
137
            }
138
            catch (Exception ex)
139
            {
140
                result = false;
141
            }
142

  
143
            GC.Collect();
144

  
145
            return result;
146
        }
147 114
        #endregion
148 115
    }
149 116
}
DTI_PID/APIDConverter/Utils/GUIUtils.cs
4 4
using System.Text;
5 5
using System.Threading.Tasks;
6 6

  
7
using AVEVA.PID.Utilities;
8

  
7 9
namespace AVEVA.PID.CustomizationUtility
8 10
{
9 11
    public class GUIUtils
......
27 29

  
28 30
            return null;
29 31
        }
30

  
31
        public static void InitGUI()
32
        
33
        public static void SetAutoLabelUnCehck()
32 34
        {
33
            //Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_PIPE_PANEL");
34
            //object objPipeStyle = GUIUtils.FindItem(items, "PIPESTYLE");
35
            //if (objPipeStyle != null)
36
            //    pipeStyleCombo = objPipeStyle as Autodesk.Windows.RibbonCombo;
37
            //object objAutoLabel = GUIUtils.FindItem(items, "Auto Label");
38
            //if (objAutoLabel != null)
39
            //    autoLabelCheckListButton = objAutoLabel as Autodesk.Windows.RibbonChecklistButton;
35
            Autodesk.Windows.RibbonChecklistButton autoLabelCheckListButton = null;
36
            Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_PIPE_PANEL");
37
            object objAutoLabel = GUIUtils.FindItem(items, "Auto Label");
38
            if (objAutoLabel != null)
39
                autoLabelCheckListButton = objAutoLabel as Autodesk.Windows.RibbonChecklistButton;
40
            
41
            if (autoLabelCheckListButton != null)
42
            {
43
                foreach (var item in autoLabelCheckListButton.Items)
44
                {
45
                    if (item.GetType() == typeof(Autodesk.Windows.RibbonButton))
46
                    {
47
                        Autodesk.Windows.RibbonButton ribbonButton = item as Autodesk.Windows.RibbonButton;
48
                        if (ribbonButton.IsChecked)
49
                            ribbonButton.IsChecked = false;
50
                    }
51
                }
52
            }
40 53

  
41
            //items = GUI.RibbonHelper.GetPanelItems("ID_SIGNAL_PANEL");
42
            //object objSignalStyle = GUIUtils.FindItem(items, "SIGNALSTYLE");
43
            //if (objSignalStyle != null)
44
            //    signalStyleCombo = objSignalStyle as Autodesk.Windows.RibbonCombo;
45
        }
46
        private void SetAutoLabelUnCehck()
47
        {
48
            //if (autoLabelCheckListButton != null)
49
            //{
50
            //    foreach (var item in autoLabelCheckListButton.Items)
51
            //    {
52
            //        if (item.GetType() == typeof(Autodesk.Windows.RibbonButton))
53
            //        {
54
            //            Autodesk.Windows.RibbonButton ribbonButton = item as Autodesk.Windows.RibbonButton;
55
            //            if (ribbonButton.IsChecked)
56
            //                ribbonButton.IsChecked = false;
57
            //        }
58
            //    }
59
            //}
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;
61

  
62
            DrawingData drawingData = new DrawingData();
63
            drawingData.AutoLabelPipe = DrawingUtilities.bPipeLabel;
64
            drawingData.AutoLabelEquipment = DrawingUtilities.bEquipLabel;
65
            drawingData.AutoLabelNozzle = DrawingUtilities.bNozzleLabel;
66
            drawingData.AutoLabelInstrument = DrawingUtilities.bInstrLabel;
67
            drawingData.AutoLabelValue = DrawingUtilities.bValveLabel;
68
            drawingData.AutoLabelReducer = DrawingUtilities.bReducerLabel;
69
            drawingData.AutoLabelLinefitting = DrawingUtilities.bLinefittingLabel;
60 70
        }
61 71

  
62 72
        public static void SetPipeStyle(string style)

내보내기 Unified diff

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