프로젝트

일반

사용자정보

개정판 59184d1b

ID59184d1be798059588b0546d45e2f7e1d3e55d05
상위 46756c13
하위 04c6def2

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

dev issue #1240 : add create drawing Method

Change-Id: I6a163a8f0eeb1133176c4aadc7cb4b7402994294

차이점 보기:

DTI_PID/APIDConverter/APIDConverterExplorer.cs
27 27
            APIDConverter form = new APIDConverter();
28 28
            if (AcadApp.ShowModalDialog(form) == DialogResult.OK)
29 29
            {
30

  
30
                
31 31
            }
32 32
        }
33 33
    }
DTI_PID/APIDConverter/AVEVA.PID.CustomizationUtility_ACAD2018_x64.csproj
68 68
      <HintPath>C:\Program Files\Autodesk\AutoCAD 2018\Autodesk.AutoCAD.Interop.Common.dll</HintPath>
69 69
      <EmbedInteropTypes>True</EmbedInteropTypes>
70 70
    </Reference>
71
    <Reference Include="AVEVA.PID.Common, Version=12.2.1.2, Culture=neutral, processorArchitecture=MSIL">
72
      <SpecificVersion>False</SpecificVersion>
73
      <HintPath>C:\Program Files\AVEVA\P&amp;ID 12.2.SP1\Install\Exe\AVEVA.PID.Common.dll</HintPath>
74
    </Reference>
75
    <Reference Include="AVEVA.PID.Components, Version=12.2.1.2, Culture=neutral, processorArchitecture=AMD64">
76
      <SpecificVersion>False</SpecificVersion>
77
      <HintPath>C:\Program Files\AVEVA\P&amp;ID 12.2.SP1\Install\Exe\AVEVA.PID.Components.dll</HintPath>
78
    </Reference>
79
    <Reference Include="AVEVA.PID.DWGSelector, Version=12.2.1.2, Culture=neutral, processorArchitecture=AMD64">
80
      <SpecificVersion>False</SpecificVersion>
81
      <HintPath>C:\Program Files\AVEVA\P&amp;ID 12.2.SP1\Install\Exe\AVEVA.PID.DWGSelector.dll</HintPath>
82
    </Reference>
71 83
    <Reference Include="AVEVA.PID.GUI, Version=12.2.1.2, Culture=neutral, processorArchitecture=AMD64">
72 84
      <SpecificVersion>False</SpecificVersion>
73 85
      <HintPath>C:\Program Files\AVEVA\P&amp;ID 12.2.SP1\Install\Exe\AVEVA.PID.GUI.dll</HintPath>
DTI_PID/APIDConverter/DB/Project_DB.cs
611 611
            return strConn;
612 612
        }
613 613

  
614
        public static string GetDirectiveValue(string name)
615
        {
616
            string result = null;
617

  
618
            using (SqlConnection connection = new SqlConnection())
619
            {
620
                connection.ConnectionString = GetAvevaConnectionString_Admin();
621
                connection.Open();
622
                using (SqlCommand cmd = connection.CreateCommand())
623
                {
624
                    cmd.CommandText = string.Format("select DirectiveValue from ProjectDirectives where DirectiveName = '{0}'", name);
625
                    using (SqlDataReader dr = cmd.ExecuteReader())
626
                    {
627
                        if (dr.Read())
628
                            result = dr.GetString(0);
629
                    }
630
                }
631
                connection.Close();
632
            }
633

  
634
            return result;
635
        }
636

  
637
        public static DataTable GetDrawingTemplate()
638
        {
639
            DataTable dt = new DataTable();
640

  
641
            using (SqlConnection connection = new SqlConnection())
642
            {
643
                connection.ConnectionString = GetAvevaConnectionString_Reports();
644
                connection.Open();
645
                using (SqlCommand cmd = connection.CreateCommand())
646
                {
647
                    cmd.CommandText = "select ID, Name,IsDWG,DateCreation,MachineName,FutureUse1,FutureUse2 from DrawingTemplates where IsDWG=0";
648
                    using (SqlDataReader dr = cmd.ExecuteReader())
649
                        dt.Load(dr);
650
                }
651
                connection.Close();
652
            }
653

  
654
            return dt;
655
        }
656

  
614 657
        public static DataTable SelectStandardSymbolTable()
615 658
        {
616 659
            DataTable dt = new DataTable();
DTI_PID/APIDConverter/PIDCustomization.cs
410 410
        [CommandMethod("TestS", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)]
411 411
        public static void TestSelection()
412 412
        {
413
            // Get the current document and database, and start a transaction
414
            Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
415
            Database acCurDb = acDoc.Database;
416
            Editor acDocEd = acDoc.Editor;
417

  
418
            // Request for objects to be selected in the drawing area
419
            PromptSelectionResult acSSPrompt = acDocEd.GetSelection();
420

  
421
            // If the prompt status is OK, objects were selected
422
            if (acSSPrompt.Status == PromptStatus.OK)
423
            {
424
                ObjectId[] selectedObjectIds = acSSPrompt.Value.GetObjectIds();
425
                // Get the last selected entity
426

  
427
                if (selectedObjectIds.Length > 0)
428
                {
429
                    ObjectId objIdBlock = selectedObjectIds[0];
430
                    using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
431
                    {
432
                        DBObject objDB = acTrans.GetObject(objIdBlock, OpenMode.ForRead, true);
433
                        if (objDB != null)
434
                        {
435
                            // check if the selected entity is of Type BlockReference
436
                            if (objDB.GetType() == typeof(BlockReference))
437
                            {
438
                                BlockReference block = objDB as BlockReference;
439

  
440
                                // open an entity in write mode so that we can modify its color
441
                                //Entity objDb = (Entity)acTrans.GetObject(objIdBlock, OpenMode.ForWrite);
442
                                //if (objDb != null)
443
                                //{
444
                                //    objDb.ColorIndex = 0;// white color
445
                                //}
446
                            }
447
                        }
448
                        acTrans.Commit();
449
                    }
450
                }
451
            }
413
            APIDUtils.CreateDrawingAndOpen("testA1", "1", "Aveva-Metric", "1");
452 414
        }
453 415

  
454 416

  
DTI_PID/APIDConverter/Utils/APIDUtils.cs
3 3
using System.Linq;
4 4
using System.Text;
5 5
using System.Threading.Tasks;
6
using System.IO;
7
using System.Reflection;
8

  
9
using AVEVA.PID.Components;
10
using AVEVA.PID.GUI;
11
using AVEVA.PID.Common;
12
using AVEVA.PID.DWGSelector;
6 13

  
7 14
using AVEVA.PID.CustomizationUtility.DB;
8 15
using AVEVA.PID.CustomizationUtility.Model;
......
82 89

  
83 90
            return list;
84 91
        }
92

  
93
        public static bool CreateDrawingAndOpen(string drawingNumber, string sheetNumber, string templateName, string templateId)
94
        {
95
            bool result = true;
96
            string outPath = Project_DB.GetDirectiveValue("DRGPTH");
97
            string tempPath = Path.GetTempPath();
98
            string selectedFullPath = Path.Combine(tempPath, templateName + ".DWT");
99

  
100
            DWTSelector.strDrawingNumber = drawingNumber;
101
            DWTSelector.strSheetNumber = sheetNumber;
102
            DWTSelector.strCadFileName = drawingNumber + sheetNumber;
103
            DWTSelector.strCadFilePath = outPath;
104

  
105
            try
106
            {
107
                string text = ReadWriteDrawingData.ReadTemplateData(templateName, templateId, selectedFullPath, false);
108
                Autodesk.AutoCAD.Interop.AcadApplication acadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as Autodesk.AutoCAD.Interop.AcadApplication;
109
                Autodesk.AutoCAD.Interop.AcadDocument acadDocument = acadApplication.Documents.Add(text);
110

  
111
                Commands.addLatestPidvesrionToDictionary();
112
                AVVPropCmd.ActivateAcad();
113
                acadApplication.ActiveDocument = acadDocument;
114
                acadDocument.Save();
115
            }
116
            catch (Exception ex)
117
            {
118
                result = false;
119
            }
120

  
121
            GC.Collect();
122

  
123
            return result;
124
        }
85 125
    }
86 126
}

내보내기 Unified diff

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