개정판 c94252bf
dev issue #1230 : add DuplicationWarningMessageBox logic
Change-Id: I2a6fac2aa15735bda66f48a04593893cbc6bf3fd
DTI_PID/APIDConverter/APIDConverterExplorer.cs | ||
---|---|---|
39 | 39 |
{ |
40 | 40 |
try |
41 | 41 |
{ |
42 |
AvevaThread.Run(ThreadType.DuplicationWarning); |
|
42 | 43 |
foreach (var item in form.Documents) |
43 | 44 |
{ |
44 | 45 |
AutoModeling autoModeling = new AutoModeling(item); |
45 | 46 |
autoModeling.CreateDrawing(); |
46 | 47 |
} |
47 |
|
|
48 |
AvevaThread.Stop(ThreadType.DuplicationWarning); |
|
48 | 49 |
MessageBox.Show("End Conversion", "APID Converter", MessageBoxButtons.OK, MessageBoxIcon.Information); |
49 | 50 |
} |
50 | 51 |
catch (Exception ex) |
DTI_PID/APIDConverter/AutoModeling.cs | ||
---|---|---|
236 | 236 |
if (lineNumber != null) |
237 | 237 |
{ |
238 | 238 |
GUIUtils.SetAutoLabelCheck(true); |
239 |
AvevaThread.Run(ThreadType.OkBtnClick, null);
|
|
239 |
AvevaThread.Run(ThreadType.LineNumberModeling, null);
|
|
240 | 240 |
break; |
241 | 241 |
} |
242 | 242 |
} |
243 | 243 |
} |
244 | 244 |
|
245 |
|
|
246 | 245 |
long handle = 0; |
247 | 246 |
if (line.Aveva.Type == Model.Type.Pipe) |
248 | 247 |
handle = DrawPipe(line.Aveva.Name, points, lineNumber); |
... | ... | |
252 | 251 |
if (lineNumber != null) |
253 | 252 |
{ |
254 | 253 |
GUIUtils.SetAutoLabelCheck(false); |
255 |
AvevaThread.Stop(ThreadType.OkBtnClick);
|
|
254 |
AvevaThread.Stop(ThreadType.LineNumberModeling);
|
|
256 | 255 |
} |
257 | 256 |
|
258 | 257 |
foreach (var item in groupLine) |
... | ... | |
350 | 349 |
private void SetLineNumberAttribute(Model.LineNumber lineNumber) |
351 | 350 |
{ |
352 | 351 |
Model.Line line = APIDUtils.FindObjectByUID(document, lineNumber.CONNLINE) as Model.Line; |
353 |
if (line != null) |
|
352 |
if (line != null && line.Aveva.Handle != 0)
|
|
354 | 353 |
{ |
354 |
List<Tuple<string, string>> datas = new List<Tuple<string, string>>(); |
|
355 | 355 |
foreach (Model.Attribute attribute in lineNumber.ATTRIBUTES) |
356 | 356 |
{ |
357 | 357 |
AttributeInfo info = avevaInfo.AttributeInfo.Find(x => x.UID == attribute.UID); |
358 |
if (info != null) |
|
359 |
{ |
|
360 |
if (info.APID_ATTRIBUTE_TYPE == AvevaAttributeType.PipeAttribute) |
|
361 |
{ |
|
362 |
|
|
363 |
} |
|
364 |
} |
|
358 |
if (info != null && !string.IsNullOrEmpty(info.APID_ATTRIBUTE)) |
|
359 |
datas.Add(new Tuple<string, string>(info.APID_ATTRIBUTE, attribute.VALUE)); |
|
360 |
} |
|
361 |
if (datas.Count > 0) |
|
362 |
{ |
|
363 |
datas.Add(new Tuple<string, string>("AddLabel", "No")); |
|
364 |
ObjectId objectId = GetFirstPolyLineObjectId(line.Aveva.Handle); |
|
365 |
if (!objectId.IsNull) |
|
366 |
SetAttributeByAvevaForm(objectId.Handle.Value, datas); |
|
365 | 367 |
} |
366 | 368 |
} |
367 | 369 |
} |
... | ... | |
369 | 371 |
{ |
370 | 372 |
if (symbol.Aveva.Handle != 0) |
371 | 373 |
{ |
372 |
List<Tuple<string, string>> udaDatas = new List<Tuple<string, string>>();
|
|
374 |
List<Tuple<string, string>> datas = new List<Tuple<string, string>>();
|
|
373 | 375 |
foreach (var attribute in symbol.ATTRIBUTES) |
374 | 376 |
{ |
375 | 377 |
AttributeInfo info = avevaInfo.AttributeInfo.Find(x => x.UID == attribute.UID); |
376 |
if (info != null) |
|
377 |
{ |
|
378 |
if (info.APID_ATTRIBUTE_TYPE == AvevaAttributeType.UDA) |
|
379 |
udaDatas.Add(new Tuple<string, string>(info.APID_ATTRIBUTE, attribute.VALUE)); |
|
380 |
} |
|
378 |
if (info != null && !string.IsNullOrEmpty(info.APID_ATTRIBUTE)) |
|
379 |
datas.Add(new Tuple<string, string>(info.APID_ATTRIBUTE, attribute.VALUE)); |
|
380 |
} |
|
381 |
if (datas.Count > 0) |
|
382 |
{ |
|
383 |
ObjectId objectId = GetObjectIdByHandle(symbol.Aveva.Handle); |
|
384 |
if (!objectId.IsNull) |
|
385 |
SetAttributeByAvevaForm(objectId.Handle.Value, datas); |
|
381 | 386 |
} |
382 |
if (udaDatas.Count > 0) |
|
383 |
SetSymbolUDAAttribute(GetObjectIdByHandle(symbol.Aveva.Handle), udaDatas); |
|
384 | 387 |
} |
385 | 388 |
} |
386 | 389 |
#endregion |
... | ... | |
631 | 634 |
} |
632 | 635 |
return handles; |
633 | 636 |
} |
634 |
private ObjectId GetFirstPolyLine(long groupHandle) |
|
637 |
private ObjectId GetFirstPolyLineObjectId(long groupHandle)
|
|
635 | 638 |
{ |
636 | 639 |
ObjectId result = ObjectId.Null; |
637 | 640 |
|
... | ... | |
714 | 717 |
acTrans.Commit(); |
715 | 718 |
} |
716 | 719 |
} |
717 |
private void SetSymbolUDAAttribute(ObjectId objectId, List<Tuple<string, string>> datas) |
|
718 |
{ |
|
719 |
AcadApplication acadApplication = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication as Autodesk.AutoCAD.Interop.AcadApplication; |
|
720 |
AcadBlockReference acadBlockReference = acadApplication.ActiveDocument.ObjectIdToObject((long)objectId.OldIdPtr); |
|
721 |
if (acadBlockReference.HasAttributes) |
|
722 |
{ |
|
723 |
object objectValue = RuntimeHelpers.GetObjectValue(acadBlockReference.GetAttributes()); |
|
724 |
int arg_5B_0 = Microsoft.VisualBasic.Information.LBound((Array)objectValue, 1); |
|
725 |
int num = Microsoft.VisualBasic.Information.UBound((Array)objectValue, 1); |
|
726 |
for (int i = arg_5B_0; i <= num; i++) |
|
727 |
{ |
|
728 |
string text = string.Empty; |
|
729 |
text = Conversions.ToString(NewLateBinding.LateGet(NewLateBinding.LateIndexGet(objectValue, new object[] |
|
730 |
{ |
|
731 |
i |
|
732 |
}, null), null, "tagString", new object[0], null, null, null)); |
|
733 |
|
|
734 |
Tuple<string, string> attribute = datas.Find(x => x.Item1 == text); |
|
735 |
if (attribute != null) |
|
736 |
{ |
|
737 |
NewLateBinding.LateSetComplex(NewLateBinding.LateIndexGet(objectValue, new object[] |
|
738 |
{ |
|
739 |
i |
|
740 |
}, null), null, "textString", new object[] |
|
741 |
{ |
|
742 |
attribute.Item2.Split("|".ToCharArray())[0] |
|
743 |
}, null, null, false, true); |
|
744 |
} |
|
745 |
} |
|
746 |
} |
|
747 |
} |
|
748 |
|
|
749 | 720 |
#endregion |
750 | 721 |
|
751 | 722 |
#region For Aveva |
... | ... | |
976 | 947 |
} |
977 | 948 |
public static void TESTStatic(long handle) |
978 | 949 |
{ |
979 |
|
|
950 |
AutoModeling auto = new AutoModeling(null); |
|
951 |
auto.SetAttributeByAvevaForm(handle, new List<Tuple<string, string>>() { new Tuple<string, string>("Size", "100") }); |
|
980 | 952 |
} |
981 | 953 |
#endregion |
982 | 954 |
} |
DTI_PID/APIDConverter/PIDCustomization.cs | ||
---|---|---|
419 | 419 |
[CommandMethod("TestS", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)] |
420 | 420 |
public static void TestSelection() |
421 | 421 |
{ |
422 |
AvevaThread.Run(ThreadType.AddProperty | ThreadType.OkBtnClick, null);
|
|
422 |
AvevaThread.Run(ThreadType.AddProperty | ThreadType.LineNumberModeling, null);
|
|
423 | 423 |
AvevaThread.Run(ThreadType.AddProperty, null); |
424 | 424 |
AvevaThread.Run(ThreadType.AddProperty | ThreadType.None, null); |
425 | 425 |
AvevaThread.Run(ThreadType.AddProperty | ThreadType.AddProperty, null); |
... | ... | |
428 | 428 |
[CommandMethod("PicTest", Autodesk.AutoCAD.Runtime.CommandFlags.UsePickSet)] |
429 | 429 |
public static void PicTest() |
430 | 430 |
{ |
431 |
|
|
432 |
} |
|
431 |
// Get the current document and database, and start a transaction |
|
432 |
Autodesk.AutoCAD.ApplicationServices.Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument; |
|
433 |
Database acCurDb = acDoc.Database; |
|
434 |
Editor acDocEd = acDoc.Editor; |
|
435 |
|
|
436 |
// Request for objects to be selected in the drawing area |
|
437 |
PromptSelectionResult acSSPrompt = acDocEd.GetSelection(); |
|
433 | 438 |
|
434 | 439 |
|
440 |
// If the prompt status is OK, objects were selected |
|
441 |
if (acSSPrompt.Status == PromptStatus.OK) |
|
442 |
{ |
|
443 |
ObjectId[] selectedObjectIds = acSSPrompt.Value.GetObjectIds(); |
|
444 |
// Get the last selected entity |
|
445 |
|
|
446 |
if (selectedObjectIds.Length > 0) |
|
447 |
{ |
|
448 |
ObjectId objIdBlock = selectedObjectIds[0]; |
|
449 |
AutoModeling.TESTStatic(objIdBlock.Handle.Value); |
|
450 |
} |
|
451 |
} |
|
452 |
} |
|
435 | 453 |
#endregion |
436 | 454 |
} |
437 | 455 |
} |
DTI_PID/APIDConverter/Utils/AvevaACAD18String.cs | ||
---|---|---|
9 | 9 |
public static class AvevaACAD18String |
10 | 10 |
{ |
11 | 11 |
public const string PipePropertyUI = "AVEVA P&ID 12 Pipe Properties"; |
12 |
public const string DuplicationWarningMessageBox = "Duplication Warning"; |
|
12 | 13 |
} |
13 | 14 |
} |
DTI_PID/APIDConverter/Utils/AvevaThread.cs | ||
---|---|---|
40 | 40 |
public enum ThreadType |
41 | 41 |
{ |
42 | 42 |
None = 0, |
43 |
OkBtnClick = 1,
|
|
43 |
LineNumberModeling = 1,
|
|
44 | 44 |
AddProperty = 2, |
45 |
DuplicationWarning = 4 |
|
45 | 46 |
} |
46 | 47 |
|
47 | 48 |
class AvevaThread |
... | ... | |
69 | 70 |
{ |
70 | 71 |
if ((type & (type - 1)) == 0) |
71 | 72 |
{ |
72 |
if (type.HasFlag(ThreadType.OkBtnClick) && !Running.HasFlag(ThreadType.OkBtnClick))
|
|
73 |
if (type.HasFlag(ThreadType.LineNumberModeling) && !Running.HasFlag(ThreadType.LineNumberModeling))
|
|
73 | 74 |
{ |
74 |
Thread thread = new Thread(OkBtnClick);
|
|
75 |
Thread thread = new Thread(LineNumberModeling);
|
|
75 | 76 |
thread.IsBackground = true; |
76 | 77 |
thread.Start(); |
77 |
Running |= ThreadType.OkBtnClick;
|
|
78 |
Running |= ThreadType.LineNumberModeling;
|
|
78 | 79 |
} |
79 | 80 |
else if (type.HasFlag(ThreadType.AddProperty) && !Running.HasFlag(ThreadType.AddProperty)) |
80 | 81 |
{ |
... | ... | |
83 | 84 |
thread.Start(); |
84 | 85 |
Running |= ThreadType.AddProperty; |
85 | 86 |
} |
87 |
else if (type.HasFlag(ThreadType.DuplicationWarning) && !Running.HasFlag(ThreadType.DuplicationWarning)) |
|
88 |
{ |
|
89 |
Thread thread = new Thread(DuplicationWarningMessageBox); |
|
90 |
thread.IsBackground = true; |
|
91 |
thread.Start(); |
|
92 |
Running |= ThreadType.DuplicationWarning; |
|
93 |
} |
|
86 | 94 |
} |
87 | 95 |
} |
88 | 96 |
|
... | ... | |
91 | 99 |
Running &= ~type; |
92 | 100 |
} |
93 | 101 |
|
94 |
public static void OkBtnClick()
|
|
102 |
public static void LineNumberModeling()
|
|
95 | 103 |
{ |
96 | 104 |
try |
97 | 105 |
{ |
98 |
while (Running.HasFlag(ThreadType.OkBtnClick))
|
|
106 |
while (Running.HasFlag(ThreadType.LineNumberModeling))
|
|
99 | 107 |
{ |
100 | 108 |
int handle = FindWindow(null, AvevaACAD18String.PipePropertyUI); |
101 | 109 |
if (handle > 0) |
102 | 110 |
{ |
111 |
Thread.Sleep(1000); |
|
112 |
|
|
113 |
System.Windows.Forms.Control control = System.Windows.Forms.Control.FromHandle((IntPtr)handle); |
|
114 |
if (control != null && control.GetType() == typeof(ComponentPropertiesUI)) |
|
115 |
{ |
|
116 |
ComponentPropertiesUI UI = control as ComponentPropertiesUI; |
|
117 |
Infragistics.Win.UltraWinGrid.UltraGridRow row = UI.GetGridRow("AddLabel"); |
|
118 |
if (row != null) |
|
119 |
row.Cells["Value"].Value = "Yes"; |
|
120 |
} |
|
121 |
|
|
103 | 122 |
int button = FindWindowEx(handle, 0, null, "Ok"); |
104 | 123 |
if (button > 0) |
105 | 124 |
{ |
106 |
Thread.Sleep(2000);
|
|
125 |
Thread.Sleep(500);
|
|
107 | 126 |
SendMessage((IntPtr)button, BM_CLICK, (IntPtr)0, (IntPtr)0); |
108 | 127 |
Thread.Sleep(500); |
109 |
Running &= ~ThreadType.OkBtnClick;
|
|
128 |
Running &= ~ThreadType.LineNumberModeling;
|
|
110 | 129 |
} |
111 | 130 |
} |
112 | 131 |
Thread.Sleep(1000); |
... | ... | |
117 | 136 |
|
118 | 137 |
} |
119 | 138 |
} |
120 |
|
|
121 | 139 |
public static void AddProperty(List<Tuple<string, string>> datas) |
122 | 140 |
{ |
123 | 141 |
try |
... | ... | |
127 | 145 |
int handle = FindWindow(null, AvevaACAD18String.PipePropertyUI); |
128 | 146 |
if (handle > 0) |
129 | 147 |
{ |
148 |
Thread.Sleep(1000); |
|
149 |
|
|
130 | 150 |
System.Windows.Forms.Control control = System.Windows.Forms.Control.FromHandle((IntPtr)handle); |
131 | 151 |
if (control != null && control.GetType() == typeof(ComponentPropertiesUI)) |
132 | 152 |
{ |
133 | 153 |
ComponentPropertiesUI UI = control as ComponentPropertiesUI; |
134 | 154 |
foreach (var tuple in datas) |
135 |
UI.GetGridRow(tuple.Item1).Cells["Value"].Value = tuple.Item2; |
|
155 |
{ |
|
156 |
Infragistics.Win.UltraWinGrid.UltraGridRow row = UI.GetGridRow(tuple.Item1); |
|
157 |
if (row != null) |
|
158 |
row.Cells["Value"].Value = tuple.Item2; |
|
159 |
} |
|
136 | 160 |
|
137 | 161 |
int button = FindWindowEx(handle, 0, null, "Ok"); |
138 | 162 |
if (button > 0) |
... | ... | |
153 | 177 |
|
154 | 178 |
} |
155 | 179 |
} |
180 |
public static void DuplicationWarningMessageBox() |
|
181 |
{ |
|
182 |
try |
|
183 |
{ |
|
184 |
while (Running.HasFlag(ThreadType.DuplicationWarning)) |
|
185 |
{ |
|
186 |
int handle = FindWindow(null, AvevaACAD18String.DuplicationWarningMessageBox); |
|
187 |
if (handle > 0) |
|
188 |
{ |
|
189 |
int button = FindWindowEx(handle, 0, null, "Ok"); |
|
190 |
if (button > 0) |
|
191 |
{ |
|
192 |
Thread.Sleep(500); |
|
193 |
SendMessage((IntPtr)button, BM_CLICK, (IntPtr)0, (IntPtr)0); |
|
194 |
Thread.Sleep(500); |
|
195 |
} |
|
196 |
} |
|
197 |
Thread.Sleep(1000); |
|
198 |
} |
|
199 |
} |
|
200 |
catch (System.Exception ex) |
|
201 |
{ |
|
202 |
|
|
203 |
} |
|
204 |
} |
|
156 | 205 |
|
157 | 206 |
public static void Test() |
158 | 207 |
{ |
내보내기 Unified diff