hytos / DTI_PID / APIDConverter / APIDConverterExplorer.cs @ 932933ed
이력 | 보기 | 이력해설 | 다운로드 (4.66 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 |
|
37 |
APIDConverter form = new APIDConverter(); |
38 |
if (AcadApp.ShowModalDialog(form) == DialogResult.OK) |
39 |
{ |
40 |
try |
41 |
{ |
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); |
52 |
} |
53 |
catch (Exception ex) |
54 |
{ |
55 |
|
56 |
} |
57 |
finally |
58 |
{ |
59 |
AccessPropertyForm.Stop(); |
60 |
} |
61 |
|
62 |
} |
63 |
} |
64 |
|
65 |
private void btnDrawingSize_Click(object sender, EventArgs e) |
66 |
{ |
67 |
// Get the current document and database, and start a transaction |
68 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
69 |
Database acCurDb = acDoc.Database; |
70 |
Editor acDocEd = acDoc.Editor; |
71 |
|
72 |
// Request for objects to be selected in the drawing area |
73 |
PromptSelectionResult acSSPrompt = acDocEd.GetSelection(); |
74 |
|
75 |
// If the prompt status is OK, objects were selected |
76 |
if (acSSPrompt.Status == PromptStatus.OK) |
77 |
{ |
78 |
ObjectId[] selectedObjectIds = acSSPrompt.Value.GetObjectIds(); |
79 |
// Get the last selected entity |
80 |
|
81 |
if (selectedObjectIds.Length > 0) |
82 |
{ |
83 |
ObjectId objectId = selectedObjectIds[0]; |
84 |
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction()) |
85 |
{ |
86 |
Entity entity = acTrans.GetObject(objectId, OpenMode.ForRead, true) as Entity; |
87 |
if (entity != null) |
88 |
{ |
89 |
Extents3d extents = entity.GeometricExtents; |
90 |
double width = extents.MaxPoint.X - extents.MinPoint.X; |
91 |
double height = extents.MaxPoint.Y - extents.MinPoint.Y; |
92 |
|
93 |
if (width == 0 || height == 0) |
94 |
{ |
95 |
MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error); |
96 |
return; |
97 |
} |
98 |
|
99 |
Settings.Default.DrawingX = width; |
100 |
Settings.Default.DrawingY = height; |
101 |
Settings.Default.Save(); |
102 |
textDrawingX.Text = Settings.Default.DrawingX.ToString(); |
103 |
textDrawingY.Text = Settings.Default.DrawingY.ToString(); |
104 |
|
105 |
MessageBox.Show("End Drawing Size Setting", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); |
106 |
} |
107 |
else |
108 |
{ |
109 |
MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error); |
110 |
} |
111 |
acTrans.Commit(); |
112 |
} |
113 |
} |
114 |
else |
115 |
{ |
116 |
MessageBox.Show("Please select one rectangle", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Error); |
117 |
} |
118 |
} |
119 |
} |
120 |
} |
121 |
} |