개정판 14540282
dev issue #1230 : command, utill, custom fix
Change-Id: I73b680168848166eeeb682782840a39e118f0d0b
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 |
|
|
23 | 31 |
} |
24 | 32 |
|
25 | 33 |
private void btnOpenConverter_Click(object sender, EventArgs e) |
... | ... | |
27 | 35 |
APIDConverter form = new APIDConverter(); |
28 | 36 |
if (AcadApp.ShowModalDialog(form) == DialogResult.OK) |
29 | 37 |
{ |
30 |
|
|
38 |
foreach (var item in form.Documents) |
|
39 |
{ |
|
40 |
AutoModeling autoModeling = new AutoModeling(item); |
|
41 |
autoModeling.Run(); |
|
42 |
} |
|
31 | 43 |
} |
32 | 44 |
} |
33 | 45 |
} |
DTI_PID/APIDConverter/AutoModeling.cs | ||
---|---|---|
16 | 16 |
using Autodesk.AutoCAD.Runtime; |
17 | 17 |
using Autodesk.AutoCAD.Windows; |
18 | 18 |
|
19 |
using AVEVA.PID.CustomizationUtility.DB; |
|
20 |
using AVEVA.PID.CustomizationUtility.Model; |
|
21 |
using AVEVA.PID.CustomizationUtility.Properties; |
|
19 | 22 |
|
20 | 23 |
namespace AVEVA.PID.CustomizationUtility |
21 | 24 |
{ |
22 | 25 |
public class AutoModeling |
23 | 26 |
{ |
24 |
Autodesk.Windows.RibbonCombo pipeStyleCombo = null; |
|
25 |
Autodesk.Windows.RibbonCombo signalStyleCombo = null; |
|
26 |
Autodesk.Windows.RibbonChecklistButton autoLabelCheckListButton = null; |
|
27 |
Model.Document document; |
|
27 | 28 |
|
28 |
private void InitGUI()
|
|
29 |
public AutoModeling(Model.Document document)
|
|
29 | 30 |
{ |
30 |
Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_PIPE_PANEL"); |
|
31 |
object objPipeStyle = GUIUtils.FindItem(items, "PIPESTYLE"); |
|
32 |
if (objPipeStyle != null) |
|
33 |
pipeStyleCombo = objPipeStyle as Autodesk.Windows.RibbonCombo; |
|
34 |
object objAutoLabel = GUIUtils.FindItem(items, "Auto Label"); |
|
35 |
if (objAutoLabel != null) |
|
36 |
autoLabelCheckListButton = objAutoLabel as Autodesk.Windows.RibbonChecklistButton; |
|
37 |
|
|
38 |
items = GUI.RibbonHelper.GetPanelItems("ID_SIGNAL_PANEL"); |
|
39 |
object objSignalStyle = GUIUtils.FindItem(items, "SIGNALSTYLE"); |
|
40 |
if (objSignalStyle != null) |
|
41 |
signalStyleCombo = objSignalStyle as Autodesk.Windows.RibbonCombo; |
|
42 |
} |
|
43 |
private void SetAutoLabelUnCehck() |
|
44 |
{ |
|
45 |
if (autoLabelCheckListButton != null) |
|
46 |
{ |
|
47 |
foreach (var item in autoLabelCheckListButton.Items) |
|
48 |
{ |
|
49 |
if (item.GetType() == typeof(Autodesk.Windows.RibbonButton)) |
|
50 |
{ |
|
51 |
Autodesk.Windows.RibbonButton ribbonButton = item as Autodesk.Windows.RibbonButton; |
|
52 |
if (ribbonButton.IsChecked) |
|
53 |
ribbonButton.IsChecked = false; |
|
54 |
} |
|
55 |
} |
|
56 |
} |
|
57 |
} |
|
58 |
|
|
59 |
private void SetPipeStyle(string style) |
|
60 |
{ |
|
61 |
if (pipeStyleCombo.Current != null) |
|
62 |
{ |
|
63 |
Autodesk.Windows.RibbonButton button = pipeStyleCombo.Current as Autodesk.Windows.RibbonButton; |
|
64 |
if (button.AutomationName != style) |
|
65 |
{ |
|
66 |
foreach (var item in pipeStyleCombo.Items) |
|
67 |
{ |
|
68 |
Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton; |
|
69 |
if (loop.AutomationName == style) |
|
70 |
{ |
|
71 |
pipeStyleCombo.Current = loop; |
|
72 |
break; |
|
73 |
} |
|
74 |
} |
|
75 |
} |
|
76 |
} |
|
31 |
this.document = document; |
|
77 | 32 |
} |
78 | 33 |
|
79 |
private void SetSignalStyle(string style)
|
|
34 |
public void Run()
|
|
80 | 35 |
{ |
81 |
if (signalStyleCombo.Current != null)
|
|
36 |
if (APIDUtils.CreateDrawingAndOpen(document.AvevaDrawingNumber, document.AvevaSheetNumber, document.AvevaTemplateName, document.AvevaTemplateID))
|
|
82 | 37 |
{ |
83 |
Autodesk.Windows.RibbonButton button = signalStyleCombo.Current as Autodesk.Windows.RibbonButton; |
|
84 |
if (button.AutomationName != style) |
|
85 |
{ |
|
86 |
foreach (var item in signalStyleCombo.Items) |
|
87 |
{ |
|
88 |
Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton; |
|
89 |
if (loop.AutomationName == style) |
|
90 |
{ |
|
91 |
signalStyleCombo.Current = loop; |
|
92 |
break; |
|
93 |
} |
|
94 |
} |
|
95 |
} |
|
38 |
test(); |
|
96 | 39 |
} |
97 | 40 |
} |
98 | 41 |
|
... | ... | |
135 | 78 |
#region Drawing Method |
136 | 79 |
private string DrawPipe(string style, List<string> coordinates) |
137 | 80 |
{ |
138 |
SetPipeStyle(style); |
|
81 |
GUIUtils.SetPipeStyle(style);
|
|
139 | 82 |
|
140 | 83 |
string prevHandle = ReadDrawingLastLine(); |
141 | 84 |
|
142 |
Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
|
85 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
|
|
143 | 86 |
Editor editor = acDoc.Editor; |
144 | 87 |
List<object> commandParam = new List<object>(); |
145 | 88 |
//command name |
... | ... | |
162 | 105 |
} |
163 | 106 |
private void DrawPipe(string style, List<string> coordinates, ObjectId objectId) |
164 | 107 |
{ |
165 |
SetPipeStyle(style); |
|
108 |
GUIUtils.SetPipeStyle(style);
|
|
166 | 109 |
|
167 |
Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
|
110 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
|
|
168 | 111 |
Editor editor = acDoc.Editor; |
169 | 112 |
List<object> commandParam = new List<object>(); |
170 | 113 |
//command name |
... | ... | |
209 | 152 |
#region Test Source |
210 | 153 |
public void test() |
211 | 154 |
{ |
212 |
InitGUI(); |
|
155 |
//InitGUI();
|
|
213 | 156 |
|
214 | 157 |
DrawPipe("Main Pipe", new List<string>() { "2,100", "100,100" }); |
215 | 158 |
|
... | ... | |
220 | 163 |
|
221 | 164 |
public static void TEST() |
222 | 165 |
{ |
223 |
AutoModeling auto = new AutoModeling(); |
|
166 |
AutoModeling auto = new AutoModeling(null);
|
|
224 | 167 |
auto.test(); |
225 | 168 |
} |
226 | 169 |
#endregion |
DTI_PID/APIDConverter/PIDCustomization.cs | ||
---|---|---|
410 | 410 |
[CommandMethod("TestS", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)] |
411 | 411 |
public static void TestSelection() |
412 | 412 |
{ |
413 |
APIDUtils.CreateDrawingAndOpen("testA1", "1", "Aveva-Metric", "1"); |
|
413 |
//APIDUtils.CreateDrawingAndOpen("testA1", "1", "Aveva-Metric", "1"); |
|
414 |
AutoModeling.TEST(); |
|
414 | 415 |
} |
415 | 416 |
|
416 | 417 |
|
DTI_PID/APIDConverter/Utils/APIDUtils.cs | ||
---|---|---|
5 | 5 |
using System.Threading.Tasks; |
6 | 6 |
using System.IO; |
7 | 7 |
using System.Reflection; |
8 |
using Autodesk.AutoCAD.EditorInput; |
|
8 | 9 |
|
9 | 10 |
using AVEVA.PID.Components; |
10 | 11 |
using AVEVA.PID.GUI; |
... | ... | |
131 | 132 |
Commands.addLatestPidvesrionToDictionary(); |
132 | 133 |
AVVPropCmd.ActivateAcad(); |
133 | 134 |
acadApplication.ActiveDocument = acadDocument; |
134 |
acadDocument.Save(); |
|
135 |
|
|
136 |
acadDocument.SendCommand("QSAVE "); |
|
135 | 137 |
} |
136 | 138 |
catch (Exception ex) |
137 | 139 |
{ |
DTI_PID/APIDConverter/Utils/GUIUtils.cs | ||
---|---|---|
27 | 27 |
|
28 | 28 |
return null; |
29 | 29 |
} |
30 |
|
|
31 |
public static void InitGUI() |
|
32 |
{ |
|
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; |
|
40 |
|
|
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 |
//} |
|
60 |
} |
|
61 |
|
|
62 |
public static void SetPipeStyle(string style) |
|
63 |
{ |
|
64 |
Autodesk.Windows.RibbonCombo pipeStyleCombo = null; |
|
65 |
Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_PIPE_PANEL"); |
|
66 |
object objPipeStyle = GUIUtils.FindItem(items, "PIPESTYLE"); |
|
67 |
if (objPipeStyle != null) |
|
68 |
pipeStyleCombo = objPipeStyle as Autodesk.Windows.RibbonCombo; |
|
69 |
|
|
70 |
if (pipeStyleCombo.Current != null) |
|
71 |
{ |
|
72 |
Autodesk.Windows.RibbonButton button = pipeStyleCombo.Current as Autodesk.Windows.RibbonButton; |
|
73 |
if (button.AutomationName != style) |
|
74 |
{ |
|
75 |
foreach (var item in pipeStyleCombo.Items) |
|
76 |
{ |
|
77 |
Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton; |
|
78 |
if (loop.AutomationName == style) |
|
79 |
{ |
|
80 |
pipeStyleCombo.Current = loop; |
|
81 |
break; |
|
82 |
} |
|
83 |
} |
|
84 |
} |
|
85 |
} |
|
86 |
} |
|
87 |
|
|
88 |
public static void SetSignalStyle(string style) |
|
89 |
{ |
|
90 |
Autodesk.Windows.RibbonCombo signalStyleCombo = null; |
|
91 |
Autodesk.Windows.RibbonItemCollection items = GUI.RibbonHelper.GetPanelItems("ID_SIGNAL_PANEL"); |
|
92 |
object objSignalStyle = GUIUtils.FindItem(items, "SIGNALSTYLE"); |
|
93 |
if (objSignalStyle != null) |
|
94 |
signalStyleCombo = objSignalStyle as Autodesk.Windows.RibbonCombo; |
|
95 |
if (signalStyleCombo.Current != null) |
|
96 |
{ |
|
97 |
Autodesk.Windows.RibbonButton button = signalStyleCombo.Current as Autodesk.Windows.RibbonButton; |
|
98 |
if (button.AutomationName != style) |
|
99 |
{ |
|
100 |
foreach (var item in signalStyleCombo.Items) |
|
101 |
{ |
|
102 |
Autodesk.Windows.RibbonButton loop = item as Autodesk.Windows.RibbonButton; |
|
103 |
if (loop.AutomationName == style) |
|
104 |
{ |
|
105 |
signalStyleCombo.Current = loop; |
|
106 |
break; |
|
107 |
} |
|
108 |
} |
|
109 |
} |
|
110 |
} |
|
111 |
} |
|
112 |
|
|
113 |
|
|
30 | 114 |
} |
31 | 115 |
} |
내보내기 Unified diff