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