hytos / DTI_PID / APIDConverter / APIDConverterExplorer.cs @ f6601e9c
이력 | 보기 | 이력해설 | 다운로드 (5.1 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel; |
4 |
using System.Drawing; |
5 |
using System.Data; |
6 |
using System.Linq; |
7 |
using System.Text; |
8 |
using System.Threading.Tasks; |
9 |
using System.Windows.Forms; |
10 |
|
11 |
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application; |
12 |
|
13 |
using Autodesk.AutoCAD.ApplicationServices; |
14 |
using Autodesk.AutoCAD.ApplicationServices.Core; |
15 |
using Autodesk.AutoCAD.DatabaseServices; |
16 |
using Autodesk.AutoCAD.EditorInput; |
17 |
|
18 |
using AVEVA.PID.CustomizationUtility.DB; |
19 |
using AVEVA.PID.CustomizationUtility.Model; |
20 |
using AVEVA.PID.CustomizationUtility.Properties; |
21 |
|
22 |
namespace AVEVA.PID.CustomizationUtility |
23 |
{ |
24 |
public partial class APIDConverterExplorer : UserControl |
25 |
{ |
26 |
public APIDConverterExplorer() |
27 |
{ |
28 |
InitializeComponent(); |
29 |
|
30 |
textDrawingX.Text = Settings.Default.DrawingX.ToString(); |
31 |
textDrawingY.Text = Settings.Default.DrawingY.ToString(); |
32 |
} |
33 |
|
34 |
private void btnOpenConverter_Click(object sender, EventArgs e) |
35 |
{ |
36 |
APIDConverter form = new APIDConverter(); |
37 |
if (AcadApp.ShowModalDialog(form) == DialogResult.OK) |
38 |
{ |
39 |
try |
40 |
{ |
41 |
AvevaThread.Run(ThreadType.DuplicationWarning); |
42 |
foreach (var item in form.Documents) |
43 |
{ |
44 |
AutoModeling autoModeling = new AutoModeling(item); |
45 |
autoModeling.CreateDrawing(); |
46 |
} |
47 |
AvevaThread.Stop(ThreadType.DuplicationWarning); |
48 |
MessageBox.Show("End Conversion", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); |
49 |
} |
50 |
catch (Exception ex) |
51 |
{ |
52 |
|
53 |
} |
54 |
finally |
55 |
{ |
56 |
|
57 |
} |
58 |
|
59 |
} |
60 |
} |
61 |
|
62 |
private void btnDrawingSize_Click(object sender, EventArgs e) |
63 |
{ |
64 |
// Get the current document and database, and start a transaction |
65 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
66 |
Database acCurDb = acDoc.Database; |
67 |
Editor acDocEd = acDoc.Editor; |
68 |
|
69 |
// Request for objects to be selected in the drawing area |
70 |
PromptSelectionResult acSSPrompt = acDocEd.GetSelection(); |
71 |
|
72 |
// If the prompt status is OK, objects were selected |
73 |
if (acSSPrompt.Status == PromptStatus.OK) |
74 |
{ |
75 |
ObjectId[] selectedObjectIds = acSSPrompt.Value.GetObjectIds(); |
76 |
// Get the last selected entity |
77 |
|
78 |
if (selectedObjectIds.Length > 0) |
79 |
{ |
80 |
ObjectId objectId = selectedObjectIds[0]; |
81 |
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) |
82 |
{ |
83 |
Entity entity = acTrans.GetObject(objectId, OpenMode.ForRead, true) as Entity; |
84 |
if (entity != null) |
85 |
{ |
86 |
Extents3d extents = entity.GeometricExtents; |
87 |
double width = extents.MaxPoint.X - extents.MinPoint.X; |
88 |
double height = extents.MaxPoint.Y - extents.MinPoint.Y; |
89 |
|
90 |
if (width == 0 || height == 0) |
91 |
{ |
92 |
MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error); |
93 |
return; |
94 |
} |
95 |
|
96 |
Settings.Default.DrawingX = width; |
97 |
Settings.Default.DrawingY = height; |
98 |
Settings.Default.Save(); |
99 |
textDrawingX.Text = Settings.Default.DrawingX.ToString(); |
100 |
textDrawingY.Text = Settings.Default.DrawingY.ToString(); |
101 |
|
102 |
MessageBox.Show("End Drawing Size Setting", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); |
103 |
} |
104 |
else |
105 |
{ |
106 |
MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error); |
107 |
} |
108 |
acTrans.Commit(); |
109 |
} |
110 |
} |
111 |
else |
112 |
{ |
113 |
MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error); |
114 |
} |
115 |
} |
116 |
} |
117 |
|
118 |
private void btnGetAttribute_Click(object sender, EventArgs e) |
119 |
{ |
120 |
Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView(); |
121 |
Autodesk.AutoCAD.Interop.AcadApplication acadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as Autodesk.AutoCAD.Interop.AcadApplication; |
122 |
Autodesk.AutoCAD.Interop.AcadDocument acadDocument = acadApplication.ActiveDocument; |
123 |
acadDocument.Activate(); |
124 |
acadDocument.SendCommand("GIFF "); |
125 |
} |
126 |
} |
127 |
} |