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
|
using System.Threading;
|
11
|
using System.IO;
|
12
|
using Microsoft.VisualBasic;
|
13
|
using Ingr.RAD2D;
|
14
|
using Converter.BaseModel;
|
15
|
using Converter.SPPID.Properties;
|
16
|
using Converter.SPPID.DB;
|
17
|
using Converter.SPPID.Util;
|
18
|
using Converter.SPPID.Form;
|
19
|
using Converter.SPPID.Model;
|
20
|
using Plaice;
|
21
|
using Llama;
|
22
|
using DevExpress.XtraSplashScreen;
|
23
|
using Newtonsoft.Json;
|
24
|
using System.Runtime.InteropServices;
|
25
|
using System.Reflection;
|
26
|
using Converter.SPPID.OPC;
|
27
|
|
28
|
namespace Converter.SPPID.Wrapper
|
29
|
{
|
30
|
public partial class ConverterDocking : UserControl
|
31
|
{
|
32
|
Ingr.RAD2D.Application application;
|
33
|
internal static bool addEvent = false;
|
34
|
public ConverterDocking()
|
35
|
{
|
36
|
InitializeComponent();
|
37
|
spinEditSymmetry.Properties.Mask.EditMask = "f0";
|
38
|
dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application");
|
39
|
WrapperApplication wApp = new WrapperApplication(dApplication.Application);
|
40
|
application = wApp.RADApplication;
|
41
|
|
42
|
ReleaseCOMObjects(dApplication);
|
43
|
dApplication = null;
|
44
|
try
|
45
|
{
|
46
|
Project_Info _ProjectInfo = Project_Info.GetInstance();
|
47
|
_ProjectInfo.DefaultPath = Settings.Default.ProjectPath;
|
48
|
_ProjectInfo.DBType = (ID2DB_Type)Settings.Default.ProjectDBType;
|
49
|
_ProjectInfo.ServerIP = Settings.Default.ProjectServerIP;
|
50
|
_ProjectInfo.Port = Settings.Default.ProjectPort;
|
51
|
_ProjectInfo.DBUser = Settings.Default.ProjectDBUser;
|
52
|
_ProjectInfo.DBPassword = Settings.Default.ProjectDBPassword;
|
53
|
if (Project_DB.ConnTestAndCreateTable())
|
54
|
{
|
55
|
_ProjectInfo.Enable = true;
|
56
|
layoutControlGroup3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
57
|
|
58
|
DataTable dt = Project_DB.SelectSetting();
|
59
|
foreach (DataRow item in dt.Rows)
|
60
|
{
|
61
|
string settingType = item["SettingType"].ToString();
|
62
|
if (settingType == "ETCSetting")
|
63
|
SPPIDUtil.ConvertToETCSetting(item["JsonString"].ToString());
|
64
|
else if (settingType == "GridSetting")
|
65
|
SPPIDUtil.ConvertToGridSetting(item["JsonString"].ToString());
|
66
|
}
|
67
|
}
|
68
|
else
|
69
|
{
|
70
|
layoutControlGroup3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
71
|
}
|
72
|
|
73
|
if (!addEvent)
|
74
|
{
|
75
|
application.EventObject.BeforeApplicationExit += ApplicationEvents_ApplicationExit;
|
76
|
addEvent = true;
|
77
|
}
|
78
|
}
|
79
|
catch (Exception ex)
|
80
|
{
|
81
|
StringBuilder sb = new StringBuilder();
|
82
|
sb.AppendLine(ex.Message);
|
83
|
sb.AppendLine(ex.StackTrace);
|
84
|
MessageBox.Show(sb.ToString());
|
85
|
}
|
86
|
}
|
87
|
private void ApplicationEvents_ApplicationExit(out bool cancel)
|
88
|
{
|
89
|
cancel = false;
|
90
|
}
|
91
|
/// <summary>
|
92
|
/// 선택한 도면들을 읽어서 SPPID로 변환한다.
|
93
|
/// </summary>
|
94
|
/// <param name="sender"></param>
|
95
|
/// <param name="e"></param>
|
96
|
private void btnConverter_Click(object sender, EventArgs e)
|
97
|
{
|
98
|
ConverterForm converterForm = new ConverterForm();
|
99
|
if (converterForm.ShowDialog() == DialogResult.OK)
|
100
|
{
|
101
|
//Ingr.RAD2D.Document doc = application.Documents.Add();
|
102
|
|
103
|
try
|
104
|
{
|
105
|
CloseOPCForm.Run();
|
106
|
|
107
|
for (int i = 0; i < converterForm.Documents.Count; i++)
|
108
|
{
|
109
|
SPPID_Document document = converterForm.Documents[i];
|
110
|
if (document.SetSPPIDMapping() && document.Enable)
|
111
|
{
|
112
|
using (AutoModeling modeling = new AutoModeling(document, converterForm.checkEditCloseDocument.Checked))
|
113
|
{
|
114
|
modeling.DocumentLabelText = string.Format("Drawing Name : {0} ({1}/{2})", document.DrawingName, i + 1, converterForm.Documents.Count);
|
115
|
modeling.Run();
|
116
|
}
|
117
|
}
|
118
|
}
|
119
|
}
|
120
|
catch (Exception ex)
|
121
|
{
|
122
|
MessageBox.Show(ex.Message + "\r\n" + ex.StackTrace);
|
123
|
}
|
124
|
finally
|
125
|
{
|
126
|
CloseOPCForm.Stop();
|
127
|
|
128
|
//doc.SaveOnClose = false;
|
129
|
//doc.Close(false);
|
130
|
|
131
|
//dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application");
|
132
|
//dApplication.Drawings[1].CloseDrawing(false);
|
133
|
//ReleaseCOMObjects(dApplication);
|
134
|
//dApplication = null;
|
135
|
}
|
136
|
|
137
|
MessageBox.Show(Msg.EndConvert, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
138
|
}
|
139
|
}
|
140
|
|
141
|
private void btnLinkOPC_Click(object sender, EventArgs e)
|
142
|
{
|
143
|
DataTable tOPCInfo = Project_DB.SelectOPCInfo();
|
144
|
DataTable tOPCRelations = Project_DB.SelectOPCRelations();
|
145
|
DataTable tDrawingInfo = Project_DB.SelectDrawingInfo();
|
146
|
dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application");
|
147
|
|
148
|
foreach (DataRow row in tOPCInfo.Rows)
|
149
|
{
|
150
|
if (!Convert.ToBoolean(row["PAIRED"]))
|
151
|
{
|
152
|
string drawingUID = row["ID2_DRAWING_UID"].ToString();
|
153
|
string OPCUID = row["ID2_OPC_UID"].ToString();
|
154
|
DataRow[] rows = tOPCRelations.Select(string.Format("(From_Drawings_UID = '{0}' AND From_OPC_UID = '{1}') OR (To_Drawings_UID = '{0}' AND To_OPC_UID = '{1}')", drawingUID, OPCUID));
|
155
|
|
156
|
if (rows.Length == 2)
|
157
|
{
|
158
|
string fromDrawingsUID1 = rows[0]["From_Drawings_UID"].ToString();
|
159
|
string fromDrawingsUID2 = rows[1]["From_Drawings_UID"].ToString();
|
160
|
string fromOPCUID1 = rows[0]["From_OPC_UID"].ToString();
|
161
|
string fromOPCUID2 = rows[1]["From_OPC_UID"].ToString();
|
162
|
string toDrawingsUID1 = rows[0]["To_Drawings_UID"].ToString();
|
163
|
string toDrawingsUID2 = rows[1]["To_Drawings_UID"].ToString();
|
164
|
string toOPCUID1 = rows[0]["To_OPC_UID"].ToString();
|
165
|
string toOPCUID2 = rows[1]["To_OPC_UID"].ToString();
|
166
|
|
167
|
DataRow[] fromDrawing = tDrawingInfo.Select(string.Format("ID2_DRAWING_UID = '{0}'", fromDrawingsUID1));
|
168
|
DataRow[] toDrawing = tDrawingInfo.Select(string.Format("ID2_DRAWING_UID = '{0}'", toDrawingsUID1));
|
169
|
DataRow[] fromOPCInfoRows = tOPCInfo.Select(string.Format("ID2_OPC_UID = '{0}'", fromOPCUID1));
|
170
|
DataRow[] toOPCInfoRows = tOPCInfo.Select(string.Format("ID2_OPC_UID = '{0}'", toOPCUID1));
|
171
|
|
172
|
if (fromOPCUID1 == toOPCUID2 && fromOPCUID2 == toOPCUID1 && fromDrawing.Length == 1 && toDrawing.Length == 1 && fromOPCInfoRows.Length == 1 && toOPCInfoRows.Length == 1)
|
173
|
{
|
174
|
DataRow fromOPCInfoRow = fromOPCInfoRows[0];
|
175
|
DataRow toOPCInfoRow = toOPCInfoRows[0];
|
176
|
string fromOPCModelId = fromOPCInfoRow["SPPID_OPC_MODELITEM_ID"].ToString();
|
177
|
string toOPCModelId = toOPCInfoRow["SPPID_OPC_MODELITEM_ID"].ToString();
|
178
|
string toDrawingName = toDrawing[0]["DRAWINGNAME"].ToString();
|
179
|
List<string[]> toOPCAttributes = JsonConvert.DeserializeObject<List<string[]>>(toOPCInfoRow["ATTRIBUTES"].ToString());
|
180
|
AutoModeling_OPC opc = new AutoModeling_OPC(dApplication, application, fromOPCModelId, toOPCModelId, toDrawingName, toOPCAttributes);
|
181
|
if (opc.Run())
|
182
|
{
|
183
|
fromOPCInfoRow["PAIRED"] = true;
|
184
|
toOPCInfoRow["PAIRED"] = true;
|
185
|
|
186
|
Project_DB.InsertOPCInfo(fromOPCInfoRow["ID2_OPC_UID"].ToString(), fromOPCInfoRow["SPPID_OPC_MODELITEM_ID"].ToString(), fromOPCInfoRow["ID2_DRAWING_UID"].ToString(), true);
|
187
|
Project_DB.InsertOPCInfo(toOPCInfoRow["ID2_OPC_UID"].ToString(), toOPCInfoRow["SPPID_OPC_MODELITEM_ID"].ToString(), toOPCInfoRow["ID2_DRAWING_UID"].ToString(), true);
|
188
|
}
|
189
|
}
|
190
|
}
|
191
|
}
|
192
|
}
|
193
|
|
194
|
tOPCInfo.Dispose();
|
195
|
tOPCRelations.Dispose();
|
196
|
tDrawingInfo.Dispose();
|
197
|
ReleaseCOMObjects(dApplication);
|
198
|
dApplication = null;
|
199
|
|
200
|
MessageBox.Show(Msg.EndConvert, Msg.Information, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
201
|
}
|
202
|
|
203
|
public void ReleaseCOMObjects(params object[] objVars)
|
204
|
{
|
205
|
int intNewRefCount = 0;
|
206
|
foreach (object obj in objVars)
|
207
|
{
|
208
|
if (!Information.IsNothing(obj) && System.Runtime.InteropServices.Marshal.IsComObject(obj))
|
209
|
intNewRefCount = intNewRefCount + System.Runtime.InteropServices.Marshal.FinalReleaseComObject(obj);
|
210
|
}
|
211
|
}
|
212
|
|
213
|
|
214
|
|
215
|
#region SPPID Utils
|
216
|
|
217
|
#region Symmetry
|
218
|
private void btnSymmetry_Click(object sender, EventArgs e)
|
219
|
{
|
220
|
if (application.ActiveSelectSet.Count == 1 && application.ActiveSelectSet[0].GetType() == typeof(Symbol2d))
|
221
|
{
|
222
|
int symCount = (int)spinEditSymmetry.Value;
|
223
|
Symbol2d symbol = application.ActiveSelectSet[0] as Symbol2d;
|
224
|
double x, y;
|
225
|
symbol.GetOrigin(out x, out y);
|
226
|
string rep = GetRepresentationId(symbol);
|
227
|
List<string> verticalRepID = new List<string>();
|
228
|
List<string> horizontalRepID = new List<string>();
|
229
|
|
230
|
if ((symbol.LinearName.Contains("Piping") ||
|
231
|
symbol.LinearName.Contains("Instrument")) &&
|
232
|
!string.IsNullOrEmpty(rep))
|
233
|
{
|
234
|
Placement placement = new Placement();
|
235
|
LMADataSource dataSource = placement.PIDDataSource;
|
236
|
List<List<string>> datas = SetSymbol(dataSource, rep, x, y, symCount);
|
237
|
Dictionary<SymmetryArrow, List<string>> resultDatas = new Dictionary<SymmetryArrow, List<string>>();
|
238
|
if (datas.Count >= 2 && datas.Find(loop => loop.Count != symCount) == null)
|
239
|
{
|
240
|
SymmetryArrow arrow = SymmetryArrow.None;
|
241
|
foreach (var data in datas)
|
242
|
{
|
243
|
LMSymbol firstSymbol = dataSource.GetSymbol(data[0]);
|
244
|
double fX = firstSymbol.get_XCoordinate();
|
245
|
double fY = firstSymbol.get_YCoordinate();
|
246
|
|
247
|
SlopeType type = SPPIDUtil.CalcSlope(x, y, fX, fY, 1);
|
248
|
if (type == SlopeType.HORIZONTAL)
|
249
|
{
|
250
|
if (fX < x)
|
251
|
{
|
252
|
arrow |= SymmetryArrow.Left;
|
253
|
resultDatas.Add(SymmetryArrow.Left, data);
|
254
|
}
|
255
|
else
|
256
|
{
|
257
|
arrow |= SymmetryArrow.Right;
|
258
|
resultDatas.Add(SymmetryArrow.Right, data);
|
259
|
}
|
260
|
|
261
|
}
|
262
|
else if (type == SlopeType.VERTICAL)
|
263
|
{
|
264
|
if (fY < y)
|
265
|
{
|
266
|
arrow |= SymmetryArrow.Down;
|
267
|
resultDatas.Add(SymmetryArrow.Down, data);
|
268
|
}
|
269
|
else
|
270
|
{
|
271
|
arrow |= SymmetryArrow.Up;
|
272
|
resultDatas.Add(SymmetryArrow.Up, data);
|
273
|
}
|
274
|
}
|
275
|
|
276
|
ReleaseCOMObjects(firstSymbol);
|
277
|
}
|
278
|
|
279
|
SymmetryForm form = new SymmetryForm(arrow);
|
280
|
if (form.ShowDialog() == DialogResult.OK)
|
281
|
{
|
282
|
MoveByResult(dataSource, resultDatas, x, y, form.Result, rep);
|
283
|
}
|
284
|
}
|
285
|
else
|
286
|
MessageBox.Show("Check Symmetry Rules", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
287
|
ReleaseCOMObjects(dataSource);
|
288
|
ReleaseCOMObjects(placement);
|
289
|
}
|
290
|
}
|
291
|
|
292
|
return;
|
293
|
|
294
|
List<Symbol2d> symbols = new List<Symbol2d>();
|
295
|
foreach (var item in application.ActiveSelectSet)
|
296
|
{
|
297
|
Type type = item.GetType();
|
298
|
if (type == typeof(Symbol2d))
|
299
|
{
|
300
|
Symbol2d symbol = item as Symbol2d;
|
301
|
if (symbol.LinearName.Contains("Piping") ||
|
302
|
symbol.LinearName.Contains("Instrument"))
|
303
|
symbols.Add(symbol);
|
304
|
}
|
305
|
//if (item.GetType() == typeof(Symbol2d) || item.GetType() == typeof(Point2d))
|
306
|
// items.Add(item);
|
307
|
}
|
308
|
|
309
|
List<Symbol2d> verticalSymbols = new List<Symbol2d>();
|
310
|
List<Symbol2d> horizontalSymbols = new List<Symbol2d>();
|
311
|
Symbol2d mainSymbol = null;
|
312
|
for (int i = 0; i < symbols.Count - 1; i++)
|
313
|
{
|
314
|
Symbol2d symbol1 = symbols[i];
|
315
|
for (int j = 1; j < symbols.Count; j++)
|
316
|
{
|
317
|
Symbol2d symbol2 = symbols[j];
|
318
|
|
319
|
if (symbol1 != symbol2)
|
320
|
{
|
321
|
double x1, y1, x2, y2;
|
322
|
symbol1.GetOrigin(out x1, out y1);
|
323
|
symbol2.GetOrigin(out x2, out y2);
|
324
|
SlopeType slopeType = SPPIDUtil.CalcSlope(x1, y1, x2, y2, 1);
|
325
|
if (slopeType == SlopeType.HORIZONTAL)
|
326
|
{
|
327
|
if (!horizontalSymbols.Contains(symbol1))
|
328
|
horizontalSymbols.Add(symbol1);
|
329
|
if (!horizontalSymbols.Contains(symbol2))
|
330
|
horizontalSymbols.Add(symbol2);
|
331
|
|
332
|
if (verticalSymbols.Contains(symbol1))
|
333
|
mainSymbol = symbol1;
|
334
|
if (verticalSymbols.Contains(symbol2))
|
335
|
mainSymbol = symbol2;
|
336
|
}
|
337
|
else if (slopeType == SlopeType.VERTICAL)
|
338
|
{
|
339
|
if (!verticalSymbols.Contains(symbol1))
|
340
|
verticalSymbols.Add(symbol1);
|
341
|
if (!verticalSymbols.Contains(symbol2))
|
342
|
verticalSymbols.Add(symbol2);
|
343
|
|
344
|
if (horizontalSymbols.Contains(symbol1))
|
345
|
mainSymbol = symbol1;
|
346
|
if (horizontalSymbols.Contains(symbol2))
|
347
|
mainSymbol = symbol2;
|
348
|
}
|
349
|
}
|
350
|
}
|
351
|
}
|
352
|
|
353
|
application.ActiveSelectSet.RemoveAll();
|
354
|
foreach (var item in verticalSymbols)
|
355
|
application.ActiveSelectSet.Add(item);
|
356
|
foreach (var item in horizontalSymbols)
|
357
|
application.ActiveSelectSet.Add(item);
|
358
|
|
359
|
|
360
|
if (MessageBox.Show("Continue?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
|
361
|
{
|
362
|
application.ActiveSelectSet.RemoveAll();
|
363
|
|
364
|
}
|
365
|
}
|
366
|
private void MoveByResult(LMADataSource dataSource,Dictionary<SymmetryArrow, List<string>> resultDatas, double x, double y, SymmetryArrow arrow, string centerRepID)
|
367
|
{
|
368
|
List<string> datas = resultDatas[arrow];
|
369
|
foreach (var item in resultDatas)
|
370
|
{
|
371
|
if (item.Key != arrow)
|
372
|
{
|
373
|
for (int i = 0; i < item.Value.Count; i++)
|
374
|
{
|
375
|
Symbol2d moveSymbol2d = GetSymbol2DByRepID(dataSource, item.Value[i]);
|
376
|
Symbol2d symbol2d = GetSymbol2DByRepID(dataSource, datas[i]);
|
377
|
|
378
|
double x1, y1, x2, y2;
|
379
|
symbol2d.GetOrigin(out x1, out y1);
|
380
|
moveSymbol2d.GetOrigin(out x2, out y2);
|
381
|
double distance = SPPIDUtil.CalcPointToPointdDistance(x, y, x1, y1);
|
382
|
|
383
|
string symbol1RepID;
|
384
|
string symbol2RepID;
|
385
|
List<Point2d> point2ds;
|
386
|
if (i == 0)
|
387
|
{
|
388
|
symbol1RepID = centerRepID;
|
389
|
symbol2RepID = item.Value[i];
|
390
|
}
|
391
|
else
|
392
|
{
|
393
|
symbol1RepID = item.Value[i - 1];
|
394
|
symbol2RepID = item.Value[i];
|
395
|
}
|
396
|
point2ds = FindAllPoint2d(dataSource, symbol1RepID, symbol2RepID);
|
397
|
double moveX = 0;
|
398
|
double moveY = 0;
|
399
|
|
400
|
if (item.Key == SymmetryArrow.Left)
|
401
|
moveX = x - distance - x2;
|
402
|
else if (item.Key == SymmetryArrow.Right)
|
403
|
moveX = x + distance - x2;
|
404
|
else if (item.Key == SymmetryArrow.Down)
|
405
|
moveY = y - distance - y2;
|
406
|
else if (item.Key == SymmetryArrow.Up)
|
407
|
moveY = y + distance - y2;
|
408
|
|
409
|
moveSymbol2d.Move(0, 0, moveX, moveY);
|
410
|
MovePoint2d(dataSource, item.Value[i], arrow, moveX, moveY);
|
411
|
foreach (var point in point2ds)
|
412
|
{
|
413
|
LMSymbol branch = dataSource.GetSymbol(GetRepresentationId(point));
|
414
|
LMSymbol connSymbol = GetFirstSymbolBySlope(dataSource, branch, symbol1RepID, symbol2RepID);
|
415
|
point.Move(0, 0, moveX, moveY);
|
416
|
if (connSymbol != null)
|
417
|
{
|
418
|
Symbol2d connSymbol2d = GetSymbol2DByRepID(dataSource, connSymbol.AsLMRepresentation().Id);
|
419
|
connSymbol2d.Move(0, 0, moveX, moveY);
|
420
|
ReleaseCOMObjects(connSymbol);
|
421
|
}
|
422
|
ReleaseCOMObjects(branch);
|
423
|
}
|
424
|
|
425
|
}
|
426
|
}
|
427
|
}
|
428
|
}
|
429
|
private LMSymbol GetFirstSymbolBySlope(LMADataSource dataSource, LMSymbol branch, string symbol1RepID, string symbol2RepID)
|
430
|
{
|
431
|
LMSymbol result = null;
|
432
|
foreach (LMConnector connector in branch.Connect1Connectors)
|
433
|
{
|
434
|
if (connector.ConnectItem1SymbolObject != null &&
|
435
|
connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active" &&
|
436
|
connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch")
|
437
|
{
|
438
|
string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
|
439
|
if (repID != symbol1RepID && repID != symbol2RepID)
|
440
|
result = connector.ConnectItem1SymbolObject;
|
441
|
}
|
442
|
|
443
|
if (connector.ConnectItem2SymbolObject != null &&
|
444
|
connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active" &&
|
445
|
connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch")
|
446
|
{
|
447
|
string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
|
448
|
if (repID != symbol1RepID && repID != symbol2RepID)
|
449
|
result = connector.ConnectItem2SymbolObject;
|
450
|
}
|
451
|
}
|
452
|
|
453
|
foreach (LMConnector connector in branch.Connect2Connectors)
|
454
|
{
|
455
|
if (connector.ConnectItem1SymbolObject != null &&
|
456
|
connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active" &&
|
457
|
connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch")
|
458
|
{
|
459
|
string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
|
460
|
if (repID != symbol1RepID && repID != symbol2RepID)
|
461
|
result = connector.ConnectItem1SymbolObject;
|
462
|
}
|
463
|
|
464
|
if (connector.ConnectItem2SymbolObject != null &&
|
465
|
connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active" &&
|
466
|
connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch")
|
467
|
{
|
468
|
string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
|
469
|
if (repID != symbol1RepID && repID != symbol2RepID)
|
470
|
result = connector.ConnectItem2SymbolObject;
|
471
|
}
|
472
|
}
|
473
|
|
474
|
|
475
|
return result;
|
476
|
}
|
477
|
private string GetRepresentationId(Symbol2d symbol)
|
478
|
{
|
479
|
foreach (var attributes in symbol.AttributeSets)
|
480
|
{
|
481
|
foreach (var attribute in attributes)
|
482
|
{
|
483
|
string name = attribute.Name;
|
484
|
object value = attribute.GetValue();
|
485
|
if (name == "DrawingID")
|
486
|
{
|
487
|
return value.ToString();
|
488
|
}
|
489
|
}
|
490
|
}
|
491
|
return null;
|
492
|
}
|
493
|
private string GetRepresentationId(Point2d point2d)
|
494
|
{
|
495
|
foreach (var attributes in point2d.AttributeSets)
|
496
|
{
|
497
|
foreach (var attribute in attributes)
|
498
|
{
|
499
|
string name = attribute.Name;
|
500
|
object value = attribute.GetValue();
|
501
|
if (name == "DrawingID")
|
502
|
{
|
503
|
return value.ToString();
|
504
|
}
|
505
|
}
|
506
|
}
|
507
|
return null;
|
508
|
}
|
509
|
private List<List<string>> SetSymbol(LMADataSource dataSource, string rep, double x, double y, int count)
|
510
|
{
|
511
|
LMSymbol _LMSymbol = dataSource.GetSymbol(rep);
|
512
|
List<List<string>> result = new List<List<string>>();
|
513
|
List<string> oldIDs = new List<string>() { rep };
|
514
|
foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
|
515
|
{
|
516
|
if (connector.get_ItemStatus() != "Active")
|
517
|
continue;
|
518
|
|
519
|
string repID = connector.AsLMRepresentation().Id;
|
520
|
string status = connector.get_ItemStatus();
|
521
|
if (status == "Active" && !oldIDs.Contains(repID))
|
522
|
{
|
523
|
List<string> symbols = new List<string>();
|
524
|
oldIDs.Add(repID);
|
525
|
loop(dataSource, oldIDs, symbols, connector, x, y, count);
|
526
|
result.Add(symbols);
|
527
|
}
|
528
|
}
|
529
|
|
530
|
foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
|
531
|
{
|
532
|
if (connector.get_ItemStatus() != "Active")
|
533
|
continue;
|
534
|
|
535
|
string repID = connector.AsLMRepresentation().Id;
|
536
|
string status = connector.get_ItemStatus();
|
537
|
if (status == "Active" && !oldIDs.Contains(repID))
|
538
|
{
|
539
|
List<string> symbols = new List<string>();
|
540
|
oldIDs.Add(repID);
|
541
|
loop(dataSource, oldIDs, symbols, connector, x, y, count);
|
542
|
result.Add(symbols);
|
543
|
}
|
544
|
}
|
545
|
|
546
|
ReleaseCOMObjects(_LMSymbol);
|
547
|
return result;
|
548
|
}
|
549
|
private void loop(LMADataSource dataSource, List<string> oldIDs, List<string> symbols, LMConnector connector, double x, double y, int count)
|
550
|
{
|
551
|
if (symbols.Count >= count)
|
552
|
return;
|
553
|
|
554
|
if (connector.ConnectItem1SymbolObject != null && !oldIDs.Contains(connector.ConnectItem1SymbolObject.AsLMRepresentation().Id))
|
555
|
{
|
556
|
string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
|
557
|
oldIDs.Add(repID);
|
558
|
if (connector.ConnectItem1SymbolObject.get_RepresentationType() != "Branch" && connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active")
|
559
|
{
|
560
|
double sX = connector.ConnectItem1SymbolObject.get_XCoordinate(), sY = connector.ConnectItem1SymbolObject.get_YCoordinate(); ;
|
561
|
SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, sX, sY, 1);
|
562
|
if (slopeType == SlopeType.HORIZONTAL || slopeType == SlopeType.VERTICAL)
|
563
|
symbols.Add(repID);
|
564
|
}
|
565
|
|
566
|
loop(dataSource, oldIDs, symbols, connector.ConnectItem1SymbolObject, x, y, count);
|
567
|
}
|
568
|
|
569
|
if (symbols.Count >= count)
|
570
|
return;
|
571
|
|
572
|
if (connector.ConnectItem2SymbolObject != null && !oldIDs.Contains(connector.ConnectItem2SymbolObject.AsLMRepresentation().Id))
|
573
|
{
|
574
|
string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
|
575
|
oldIDs.Add(repID);
|
576
|
if (connector.ConnectItem2SymbolObject.get_RepresentationType() != "Branch" && connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active")
|
577
|
{
|
578
|
double sX = connector.ConnectItem2SymbolObject.get_XCoordinate(), sY = connector.ConnectItem2SymbolObject.get_YCoordinate(); ;
|
579
|
SlopeType slopeType = SPPIDUtil.CalcSlope(x, y, sX, sY, 1);
|
580
|
if (slopeType == SlopeType.HORIZONTAL || slopeType == SlopeType.VERTICAL)
|
581
|
symbols.Add(repID);
|
582
|
}
|
583
|
|
584
|
loop(dataSource, oldIDs, symbols, connector.ConnectItem2SymbolObject, x, y, count);
|
585
|
}
|
586
|
}
|
587
|
private void loop(LMADataSource dataSource, List<string> oldIDs, List<string> symbols, LMSymbol _LMSymbol, double x, double y, int count)
|
588
|
{
|
589
|
if (symbols.Count >= count)
|
590
|
return;
|
591
|
|
592
|
foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
|
593
|
{
|
594
|
if (connector.get_ItemStatus() != "Active")
|
595
|
continue;
|
596
|
|
597
|
string repID = connector.AsLMRepresentation().Id;
|
598
|
string status = connector.get_ItemStatus();
|
599
|
if (status == "Active" && !oldIDs.Contains(repID))
|
600
|
{
|
601
|
oldIDs.Add(repID);
|
602
|
loop(dataSource, oldIDs, symbols, connector, x, y, count);
|
603
|
}
|
604
|
}
|
605
|
|
606
|
foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
|
607
|
{
|
608
|
if (connector.get_ItemStatus() != "Active")
|
609
|
continue;
|
610
|
|
611
|
string repID = connector.AsLMRepresentation().Id;
|
612
|
string status = connector.get_ItemStatus();
|
613
|
if (status == "Active" && !oldIDs.Contains(repID))
|
614
|
{
|
615
|
oldIDs.Add(repID);
|
616
|
loop(dataSource, oldIDs, symbols, connector, x, y, count);
|
617
|
}
|
618
|
}
|
619
|
}
|
620
|
private Symbol2d GetSymbol2DByRepID(LMADataSource dataSource, string repID)
|
621
|
{
|
622
|
LMSymbol _LMSymbol = dataSource.GetSymbol(repID);
|
623
|
Symbol2d symbol2D = application.ActiveDocument.ActiveSheet.DrawingObjects[_LMSymbol.get_GraphicOID().ToString()];
|
624
|
ReleaseCOMObjects(_LMSymbol);
|
625
|
return symbol2D;
|
626
|
}
|
627
|
private void MovePoint2d(LMADataSource datasource, string repID, SymmetryArrow arrow, double moveX, double moveY)
|
628
|
{
|
629
|
LMSymbol _LMSymbol = datasource.GetSymbol(repID);
|
630
|
foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
|
631
|
{
|
632
|
if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()))
|
633
|
{
|
634
|
if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
|
635
|
{
|
636
|
Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()];
|
637
|
point.X += moveX;
|
638
|
point.Y += moveY;
|
639
|
}
|
640
|
else if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
|
641
|
{
|
642
|
Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()];
|
643
|
point.X += moveX;
|
644
|
point.Y += moveY;
|
645
|
}
|
646
|
}
|
647
|
}
|
648
|
foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
|
649
|
{
|
650
|
if (connector.get_ItemStatus() == "Active" && Convert.ToBoolean(connector.get_IsZeroLength()))
|
651
|
{
|
652
|
if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
|
653
|
{
|
654
|
Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()];
|
655
|
point.X += moveX;
|
656
|
point.Y += moveY;
|
657
|
}
|
658
|
else if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
|
659
|
{
|
660
|
Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()];
|
661
|
point.X += moveX;
|
662
|
point.Y += moveY;
|
663
|
}
|
664
|
}
|
665
|
}
|
666
|
ReleaseCOMObjects(_LMSymbol);
|
667
|
}
|
668
|
private List<Point2d> FindAllPoint2d(LMADataSource dataSource, string repID, string nextRepID)
|
669
|
{
|
670
|
LMSymbol _LMSymbol = dataSource.GetSymbol(repID);
|
671
|
List<string> endIDs = new List<string>() { repID };
|
672
|
List<string> graphicOIDs = new List<string>();
|
673
|
List<Point2d> result = new List<Point2d>();
|
674
|
FindPointsLoop(dataSource, _LMSymbol, endIDs, nextRepID, graphicOIDs);
|
675
|
ReleaseCOMObjects(_LMSymbol);
|
676
|
foreach (var item in graphicOIDs)
|
677
|
{
|
678
|
Point2d point = application.ActiveDocument.ActiveSheet.DrawingObjects[item] as Point2d;
|
679
|
result.Add(point);
|
680
|
}
|
681
|
|
682
|
return result;
|
683
|
}
|
684
|
private bool FindPointsLoop(LMADataSource dataSource, LMSymbol _LMSymbol, List<string> endIDs, string targetRepID, List<string> graphicOIDs)
|
685
|
{
|
686
|
foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
|
687
|
{
|
688
|
if (connector.get_ItemStatus() != "Active")
|
689
|
continue;
|
690
|
|
691
|
if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active")
|
692
|
{
|
693
|
string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
|
694
|
if (!endIDs.Contains(repID))
|
695
|
{
|
696
|
endIDs.Add(repID);
|
697
|
if (connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
|
698
|
{
|
699
|
if (FindPointsLoop(dataSource, connector.ConnectItem1SymbolObject, endIDs, targetRepID, graphicOIDs))
|
700
|
{
|
701
|
if (!Convert.ToBoolean(connector.get_IsZeroLength()))
|
702
|
graphicOIDs.Add(connector.ConnectItem1SymbolObject.get_GraphicOID().ToString());
|
703
|
return true;
|
704
|
}
|
705
|
}
|
706
|
else if (targetRepID == repID)
|
707
|
{
|
708
|
return true;
|
709
|
}
|
710
|
}
|
711
|
}
|
712
|
if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active")
|
713
|
{
|
714
|
string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
|
715
|
if (!endIDs.Contains(repID))
|
716
|
{
|
717
|
endIDs.Add(repID);
|
718
|
if (connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
|
719
|
{
|
720
|
if (FindPointsLoop(dataSource, connector.ConnectItem2SymbolObject, endIDs, targetRepID, graphicOIDs))
|
721
|
{
|
722
|
if (!Convert.ToBoolean(connector.get_IsZeroLength()))
|
723
|
graphicOIDs.Add(connector.ConnectItem2SymbolObject.get_GraphicOID().ToString());
|
724
|
return true;
|
725
|
}
|
726
|
}
|
727
|
else if (targetRepID == repID)
|
728
|
{
|
729
|
return true;
|
730
|
}
|
731
|
}
|
732
|
}
|
733
|
}
|
734
|
foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
|
735
|
{
|
736
|
if (connector.get_ItemStatus() != "Active")
|
737
|
continue;
|
738
|
|
739
|
if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active")
|
740
|
{
|
741
|
string repID = connector.ConnectItem1SymbolObject.AsLMRepresentation().Id;
|
742
|
if (!endIDs.Contains(repID))
|
743
|
{
|
744
|
endIDs.Add(repID);
|
745
|
if (connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch")
|
746
|
{
|
747
|
if (FindPointsLoop(dataSource, connector.ConnectItem1SymbolObject, endIDs, targetRepID, graphicOIDs))
|
748
|
{
|
749
|
if (!Convert.ToBoolean(connector.get_IsZeroLength()))
|
750
|
graphicOIDs.Add(connector.ConnectItem1SymbolObject.get_GraphicOID().ToString());
|
751
|
return true;
|
752
|
}
|
753
|
}
|
754
|
else if (targetRepID == repID)
|
755
|
{
|
756
|
return true;
|
757
|
}
|
758
|
}
|
759
|
}
|
760
|
if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active")
|
761
|
{
|
762
|
string repID = connector.ConnectItem2SymbolObject.AsLMRepresentation().Id;
|
763
|
if (!endIDs.Contains(repID))
|
764
|
{
|
765
|
endIDs.Add(repID);
|
766
|
if (connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch")
|
767
|
{
|
768
|
if (FindPointsLoop(dataSource, connector.ConnectItem2SymbolObject, endIDs, targetRepID, graphicOIDs))
|
769
|
{
|
770
|
if (!Convert.ToBoolean(connector.get_IsZeroLength()))
|
771
|
graphicOIDs.Add(connector.ConnectItem2SymbolObject.get_GraphicOID().ToString());
|
772
|
return true;
|
773
|
}
|
774
|
}
|
775
|
else if (targetRepID == repID)
|
776
|
{
|
777
|
return true;
|
778
|
}
|
779
|
}
|
780
|
}
|
781
|
}
|
782
|
|
783
|
return false;
|
784
|
}
|
785
|
#endregion
|
786
|
|
787
|
#region SpecBreak
|
788
|
private void btnSpecBreakRelocation_Click(object sender, EventArgs e)
|
789
|
{
|
790
|
dynamic dApplication = Interaction.GetObject("", "PIDAutomation.Application");
|
791
|
WrapperApplication wApp = new WrapperApplication(dApplication.Application);
|
792
|
application = wApp.RADApplication;
|
793
|
|
794
|
int count = application.ActiveSelectSet.Count;
|
795
|
int dependencyCount = 0;
|
796
|
foreach (var item in application.ActiveSelectSet)
|
797
|
if (item.GetType() == typeof(DependencyObject))
|
798
|
dependencyCount++;
|
799
|
|
800
|
if (count > 0 && application.ActiveSelectSet[0].GetType() == typeof(DependencyObject))
|
801
|
{
|
802
|
MessageBox.Show("First selected item is DependencyObject!\r\nPlease move symbol", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
803
|
return;
|
804
|
}
|
805
|
|
806
|
if ((count == 3 || count == 4) && application.ActiveSelectSet[0].GetType() == typeof(Symbol2d) &&
|
807
|
(dependencyCount == 2 || dependencyCount == 3))
|
808
|
{
|
809
|
Symbol2d symbol = application.ActiveSelectSet[0] as Symbol2d;
|
810
|
|
811
|
if (!symbol.DefinitionName.Contains(@"Design\Annotation\Graphics\"))
|
812
|
{
|
813
|
MessageBox.Show("Select SpecBreak!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
814
|
return;
|
815
|
}
|
816
|
|
817
|
DependencyObject dependency1 = application.ActiveSelectSet[1] as DependencyObject;
|
818
|
DependencyObject dependency2 = application.ActiveSelectSet[2] as DependencyObject;
|
819
|
DependencyObject dependency3 = null;
|
820
|
if (count == 4)
|
821
|
dependency3 = application.ActiveSelectSet[3] as DependencyObject;
|
822
|
|
823
|
application.ActiveSelectSet.RemoveAll();
|
824
|
double angle = symbol.Angle;
|
825
|
if (symbol.GetTransform().HasReflection)
|
826
|
angle += Math.PI;
|
827
|
|
828
|
double degree = double.NaN;
|
829
|
if (angle > -0.1 && angle < 0.1)
|
830
|
degree = 0;
|
831
|
else if (angle > 1.56 && angle < 1.58)
|
832
|
degree = 90;
|
833
|
else if (angle > 3.13 && angle < 3.15)
|
834
|
degree = 180;
|
835
|
else if (angle > 4.7 && angle < 4.72)
|
836
|
degree = 270;
|
837
|
else if (angle > 6.27 && angle < 6.29)
|
838
|
degree = 0;
|
839
|
else if (angle > -1.58 && angle < -1.56)
|
840
|
degree = 270;
|
841
|
else if (angle > -3.15 && angle < -3.13)
|
842
|
degree = 180;
|
843
|
else
|
844
|
throw new Exception("Check Angle");
|
845
|
|
846
|
|
847
|
double originX, originY;
|
848
|
symbol.GetOrigin(out originX, out originY);
|
849
|
|
850
|
double crossX = 0;
|
851
|
double crossY = 0;
|
852
|
double topX = 0;
|
853
|
double topY = 0;
|
854
|
foreach (var item in symbol.DrawingObjects)
|
855
|
{
|
856
|
Line2d line2d = item as Line2d;
|
857
|
if (line2d != null)
|
858
|
{
|
859
|
double x1, y1, x2, y2;
|
860
|
line2d.GetStartPoint(out x1, out y1);
|
861
|
line2d.GetEndPoint(out x2, out y2);
|
862
|
SlopeType slopeType = SPPIDUtil.CalcSlope(x1, y1, x2, y2, 0.1);
|
863
|
|
864
|
if (slopeType == SlopeType.HORIZONTAL)
|
865
|
{
|
866
|
if (crossY == 0)
|
867
|
crossY = y1;
|
868
|
else
|
869
|
crossY = (crossY + y1) / 2;
|
870
|
|
871
|
switch (degree)
|
872
|
{
|
873
|
case 90:
|
874
|
if (topX == 0)
|
875
|
topX = Math.Min(x1, x2);
|
876
|
else
|
877
|
topX = Math.Min(topX, Math.Min(x1, x2));
|
878
|
break;
|
879
|
case 270:
|
880
|
if (topX == 0)
|
881
|
topX = Math.Max(x1, x2);
|
882
|
else
|
883
|
topX = Math.Max(topX, Math.Max(x1, x2));
|
884
|
break;
|
885
|
default:
|
886
|
break;
|
887
|
}
|
888
|
}
|
889
|
else if (slopeType == SlopeType.VERTICAL)
|
890
|
{
|
891
|
if (crossX == 0)
|
892
|
crossX = x1;
|
893
|
else
|
894
|
crossX = (crossX + x1) / 2;
|
895
|
|
896
|
switch (degree)
|
897
|
{
|
898
|
case 0:
|
899
|
if (topY == 0)
|
900
|
topY = Math.Max(y1, y2);
|
901
|
else
|
902
|
topY = Math.Max(topY, Math.Max(y1, y2));
|
903
|
break;
|
904
|
case 180:
|
905
|
if (topY == 0)
|
906
|
topY = Math.Min(y1, y2);
|
907
|
else
|
908
|
topY = Math.Min(topY, Math.Min(y1, y2));
|
909
|
break;
|
910
|
default:
|
911
|
break;
|
912
|
}
|
913
|
}
|
914
|
}
|
915
|
}
|
916
|
switch (degree)
|
917
|
{
|
918
|
case 0:
|
919
|
crossX = originX;
|
920
|
topX = crossX;
|
921
|
break;
|
922
|
case 90:
|
923
|
crossY = originY;
|
924
|
topY = crossY;
|
925
|
break;
|
926
|
case 180:
|
927
|
crossX = originX;
|
928
|
topX = crossX;
|
929
|
break;
|
930
|
case 270:
|
931
|
crossY = originY;
|
932
|
topY = crossY;
|
933
|
break;
|
934
|
default:
|
935
|
break;
|
936
|
}
|
937
|
|
938
|
SpecBreakRelocation(degree, originX, originY, crossX, crossY, topX, topY, dependency1, dependency2, dependency3);
|
939
|
}
|
940
|
else
|
941
|
{
|
942
|
MessageBox.Show("Check Rule!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
943
|
}
|
944
|
}
|
945
|
private void SpecBreakRelocation(double degree, double originX, double originY, double crossX, double crossY, double topX, double topY, DependencyObject dependency1, DependencyObject dependency2, DependencyObject dependency3)
|
946
|
{
|
947
|
double d1X1, d1Y1, d1X2, d1Y2, d2X1, d2Y1, d2X2, d2Y2, d3X1 = 0, d3Y1 = 0, d3X2 = 0, d3Y2 = 0;
|
948
|
|
949
|
FindRangeWithOutLineString2d(dependency1, out d1X1, out d1Y1, out d1X2, out d1Y2);
|
950
|
FindRangeWithOutLineString2d(dependency2, out d2X1, out d2Y1, out d2X2, out d2Y2);
|
951
|
if (dependency3 != null)
|
952
|
FindRangeWithOutLineString2dAndTextBox(dependency3, out d3X1, out d3Y1, out d3X2, out d3Y2);
|
953
|
|
954
|
GridSetting gridSetting = GridSetting.GetInstance();
|
955
|
double move = gridSetting.Length / 2;
|
956
|
switch (degree)
|
957
|
{
|
958
|
case 0:
|
959
|
MoveDependency(dependency1, d1X2, d1Y2, crossX - move, crossY);
|
960
|
MoveDependency(dependency2, d2X1, d2Y2, crossX + move, crossY);
|
961
|
if (dependency3 != null)
|
962
|
MoveDependency(dependency3, (d3X1 + d3X2) / 2, d3Y1, topX, topY);
|
963
|
break;
|
964
|
case 90:
|
965
|
MoveDependency(dependency1, d1X1, d1Y2, crossX + move, crossY);
|
966
|
MoveDependency(dependency2, d2X1, d2Y1, crossX + move, crossY);
|
967
|
if (dependency3 != null)
|
968
|
MoveDependency(dependency3, d3X1, (d3Y1 + d3Y2) / 2, originX, originY);
|
969
|
break;
|
970
|
case 180:
|
971
|
MoveDependency(dependency1, d1X2, d1Y1, crossX - move, crossY);
|
972
|
MoveDependency(dependency2, d2X1, d2Y1, crossX + move, crossY);
|
973
|
if (dependency3 != null)
|
974
|
MoveDependency(dependency3, (d3X1 + d3X2) / 2, d3Y2, topX, topY);
|
975
|
break;
|
976
|
case 270:
|
977
|
MoveDependency(dependency1, d1X2, d1Y2, crossX - move, crossY);
|
978
|
MoveDependency(dependency2, d2X2, d2Y1, crossX - move, crossY);
|
979
|
if (dependency3 != null)
|
980
|
MoveDependency(dependency3, d3X2, (d3Y1 + d3Y2) / 2, originX, originY);
|
981
|
break;
|
982
|
default:
|
983
|
break;
|
984
|
}
|
985
|
}
|
986
|
private void MoveDependency(DependencyObject dependency, double xFrom, double yFrom, double xTo, double yTo)
|
987
|
{
|
988
|
application.ActiveSelectSet.Add(dependency);
|
989
|
|
990
|
Transform transform = dependency.GetTransform();
|
991
|
transform.DefineByMove2d(xTo - xFrom, yTo - yFrom);
|
992
|
application.ActiveSelectSet.Transform(transform, false);
|
993
|
|
994
|
application.ActiveSelectSet.RemoveAll();
|
995
|
}
|
996
|
private string GetDrawingItemType(DependencyObject dependency)
|
997
|
{
|
998
|
string result = string.Empty;
|
999
|
|
1000
|
foreach (var attributes in dependency.AttributeSets)
|
1001
|
{
|
1002
|
foreach (var attribute in attributes)
|
1003
|
{
|
1004
|
if (attribute.Name == "DrawingItemType")
|
1005
|
return attribute.GetValue().ToString();
|
1006
|
}
|
1007
|
}
|
1008
|
|
1009
|
return result;
|
1010
|
}
|
1011
|
private void FindRangeWithOutLineString2d(DependencyObject dependency, out double x1, out double y1, out double x2, out double y2)
|
1012
|
{
|
1013
|
x1 = double.MaxValue;
|
1014
|
y1 = double.MaxValue;
|
1015
|
x2 = double.MinValue;
|
1016
|
y2 = double.MinValue;
|
1017
|
foreach (DrawingObjectBase item in dependency.DrawingObjects)
|
1018
|
{
|
1019
|
if (item.GetType() != typeof(LineString2d))
|
1020
|
{
|
1021
|
double minX, minY, maxX, maxY;
|
1022
|
item.Range(out minX, out minY, out maxX, out maxY);
|
1023
|
if (x1 > minX)
|
1024
|
x1 = minX;
|
1025
|
if (y1 > minY)
|
1026
|
y1 = minY;
|
1027
|
if (x2 < maxX)
|
1028
|
x2 = maxX;
|
1029
|
if (y2 < maxY)
|
1030
|
y2 = maxY;
|
1031
|
}
|
1032
|
}
|
1033
|
|
1034
|
}
|
1035
|
private void FindRangeWithOutLineString2dAndTextBox(DependencyObject dependency, out double x1, out double y1, out double x2, out double y2)
|
1036
|
{
|
1037
|
x1 = double.MaxValue;
|
1038
|
y1 = double.MaxValue;
|
1039
|
x2 = double.MinValue;
|
1040
|
y2 = double.MinValue;
|
1041
|
foreach (DrawingObjectBase item in dependency.DrawingObjects)
|
1042
|
{
|
1043
|
if (item.GetType() != typeof(LineString2d) && item.GetType() != typeof(Ingr.RAD2D.TextBox))
|
1044
|
{
|
1045
|
double minX, minY, maxX, maxY;
|
1046
|
item.Range(out minX, out minY, out maxX, out maxY);
|
1047
|
if (x1 > minX)
|
1048
|
x1 = minX;
|
1049
|
if (y1 > minY)
|
1050
|
y1 = minY;
|
1051
|
if (x2 < maxX)
|
1052
|
x2 = maxX;
|
1053
|
if (y2 < maxY)
|
1054
|
y2 = maxY;
|
1055
|
}
|
1056
|
}
|
1057
|
|
1058
|
}
|
1059
|
#endregion
|
1060
|
|
1061
|
#region Hot Key
|
1062
|
private void toggleSwitchSnapGrid_Toggled(object sender, EventArgs e)
|
1063
|
{
|
1064
|
if (toggleSwitchSnapGrid.IsOn)
|
1065
|
{
|
1066
|
RegisterHotKey(this.Handle, 0, (int)KeyModifier.Shift, Keys.A.GetHashCode());
|
1067
|
}
|
1068
|
else
|
1069
|
{
|
1070
|
UnregisterHotKey(this.Handle, 0);
|
1071
|
}
|
1072
|
}
|
1073
|
private void toggleSwitchMoveSymbol_Toggled(object sender, EventArgs e)
|
1074
|
{
|
1075
|
if (toggleSwitchMoveSymbol.IsOn)
|
1076
|
{
|
1077
|
RegisterHotKey(this.Handle, 1, (int)KeyModifier.Shift, Keys.Left.GetHashCode());
|
1078
|
RegisterHotKey(this.Handle, 2, (int)KeyModifier.Shift, Keys.Up.GetHashCode());
|
1079
|
RegisterHotKey(this.Handle, 3, (int)KeyModifier.Shift, Keys.Right.GetHashCode());
|
1080
|
RegisterHotKey(this.Handle, 4, (int)KeyModifier.Shift, Keys.Down.GetHashCode());
|
1081
|
}
|
1082
|
else
|
1083
|
{
|
1084
|
UnregisterHotKey(this.Handle, 1);
|
1085
|
UnregisterHotKey(this.Handle, 2);
|
1086
|
UnregisterHotKey(this.Handle, 3);
|
1087
|
UnregisterHotKey(this.Handle, 4);
|
1088
|
}
|
1089
|
}
|
1090
|
public void ClearHotKey()
|
1091
|
{
|
1092
|
if (toggleSwitchMoveSymbol.IsOn)
|
1093
|
{
|
1094
|
UnregisterHotKey(this.Handle, 1);
|
1095
|
UnregisterHotKey(this.Handle, 2);
|
1096
|
UnregisterHotKey(this.Handle, 3);
|
1097
|
UnregisterHotKey(this.Handle, 4);
|
1098
|
}
|
1099
|
if (toggleSwitchSnapGrid.IsOn)
|
1100
|
{
|
1101
|
UnregisterHotKey(this.Handle, 0);
|
1102
|
}
|
1103
|
}
|
1104
|
[System.Runtime.InteropServices.DllImport("user32.dll")]
|
1105
|
private static extern bool RegisterHotKey(IntPtr hWnd, int id, int fsModifiers, int vk);
|
1106
|
[System.Runtime.InteropServices.DllImport("user32.dll")]
|
1107
|
private static extern bool UnregisterHotKey(IntPtr hWnd, int id);
|
1108
|
enum KeyModifier
|
1109
|
{
|
1110
|
None = 0,
|
1111
|
Alt = 1,
|
1112
|
Control = 2,
|
1113
|
Shift = 4,
|
1114
|
WinKey = 8
|
1115
|
}
|
1116
|
protected override void WndProc(ref Message m)
|
1117
|
{
|
1118
|
base.WndProc(ref m);
|
1119
|
if (m.Msg == 0x0312)
|
1120
|
{
|
1121
|
Keys key = (Keys)(((int)m.LParam >> 16) & 0xFFFF);
|
1122
|
KeyModifier modifier = (KeyModifier)((int)m.LParam & 0xFFFF);
|
1123
|
int id = m.WParam.ToInt32();
|
1124
|
switch (id)
|
1125
|
{
|
1126
|
case 0:
|
1127
|
application.RunCommand(CommandConstants.igcmdGridSnap);
|
1128
|
break;
|
1129
|
case 1:
|
1130
|
MoveSymbol(Arrow.Left);
|
1131
|
break;
|
1132
|
case 2:
|
1133
|
MoveSymbol(Arrow.Up);
|
1134
|
break;
|
1135
|
case 3:
|
1136
|
MoveSymbol(Arrow.Right);
|
1137
|
break;
|
1138
|
case 4:
|
1139
|
MoveSymbol(Arrow.Down);
|
1140
|
break;
|
1141
|
default:
|
1142
|
break;
|
1143
|
}
|
1144
|
|
1145
|
}
|
1146
|
|
1147
|
}
|
1148
|
#endregion
|
1149
|
|
1150
|
#region Move Symbol
|
1151
|
enum Arrow
|
1152
|
{
|
1153
|
Left,
|
1154
|
Up,
|
1155
|
Right,
|
1156
|
Down
|
1157
|
}
|
1158
|
private void MoveSymbol(Arrow arrow)
|
1159
|
{
|
1160
|
if (application.ActiveSelectSet.Count > 0)
|
1161
|
{
|
1162
|
Placement placement = new Placement();
|
1163
|
LMADataSource dataSource = placement.PIDDataSource;
|
1164
|
System.Collections.ObjectModel.Collection<DrawingObjectBase> originalDrawingObjectBases = new System.Collections.ObjectModel.Collection<DrawingObjectBase>();
|
1165
|
foreach (var item in application.ActiveSelectSet)
|
1166
|
originalDrawingObjectBases.Add(item);
|
1167
|
System.Collections.ObjectModel.Collection<DrawingObjectBase> drawingObjectBases = new System.Collections.ObjectModel.Collection<DrawingObjectBase>();
|
1168
|
Transform transform = null;
|
1169
|
foreach (DrawingObjectBase drawingObject in application.ActiveSelectSet)
|
1170
|
{
|
1171
|
if (drawingObject.GetType() == typeof(Symbol2d))
|
1172
|
{
|
1173
|
Symbol2d symbol2D = drawingObject as Symbol2d;
|
1174
|
if (transform == null)
|
1175
|
transform = symbol2D.GetTransform();
|
1176
|
drawingObjectBases.Add(symbol2D);
|
1177
|
LMSymbol _LMSymbol = dataSource.GetSymbol(GetRepresentationId(symbol2D));
|
1178
|
if (_LMSymbol != null)
|
1179
|
{
|
1180
|
foreach (LMConnector connector in _LMSymbol.Connect1Connectors)
|
1181
|
{
|
1182
|
if (connector.get_ItemStatus() == "Active")
|
1183
|
{
|
1184
|
#region Zero Length And Branch
|
1185
|
if (Convert.ToBoolean(connector.get_IsZeroLength()))
|
1186
|
{
|
1187
|
if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolID != _LMSymbol.Id)
|
1188
|
{
|
1189
|
Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()] as Point2d;
|
1190
|
if (point2D != null && !drawingObjectBases.Contains(point2D))
|
1191
|
drawingObjectBases.Add(point2D);
|
1192
|
}
|
1193
|
else if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolID != _LMSymbol.Id)
|
1194
|
{
|
1195
|
Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()] as Point2d;
|
1196
|
if (point2D != null && !drawingObjectBases.Contains(point2D))
|
1197
|
drawingObjectBases.Add(point2D);
|
1198
|
}
|
1199
|
}
|
1200
|
#endregion
|
1201
|
#region Not Zero Length And Branch And Vertical,Horizontal
|
1202
|
else
|
1203
|
{
|
1204
|
if (connector.ConnectItem1SymbolObject != null &&
|
1205
|
connector.ConnectItem1SymbolID != _LMSymbol.Id &&
|
1206
|
connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active" &&
|
1207
|
connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch" &&
|
1208
|
IsMovePoint2D(connector.ConnectItem1SymbolObject, connector, arrow))
|
1209
|
{
|
1210
|
Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()] as Point2d;
|
1211
|
if (point2D != null && !drawingObjectBases.Contains(point2D))
|
1212
|
drawingObjectBases.Add(point2D);
|
1213
|
}
|
1214
|
|
1215
|
else if (connector.ConnectItem2SymbolObject != null &&
|
1216
|
connector.ConnectItem2SymbolID != _LMSymbol.Id &&
|
1217
|
connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active" &&
|
1218
|
connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch" &&
|
1219
|
IsMovePoint2D(connector.ConnectItem2SymbolObject, connector, arrow))
|
1220
|
{
|
1221
|
Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()] as Point2d;
|
1222
|
if (point2D != null && !drawingObjectBases.Contains(point2D))
|
1223
|
drawingObjectBases.Add(point2D);
|
1224
|
}
|
1225
|
|
1226
|
}
|
1227
|
#endregion
|
1228
|
}
|
1229
|
}
|
1230
|
foreach (LMConnector connector in _LMSymbol.Connect2Connectors)
|
1231
|
{
|
1232
|
if (connector.get_ItemStatus() == "Active")
|
1233
|
{
|
1234
|
#region Zero Length And Branch
|
1235
|
if (Convert.ToBoolean(connector.get_IsZeroLength()))
|
1236
|
{
|
1237
|
if (connector.ConnectItem1SymbolObject != null && connector.ConnectItem1SymbolID != _LMSymbol.Id)
|
1238
|
{
|
1239
|
Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()] as Point2d;
|
1240
|
if (point2D != null && !drawingObjectBases.Contains(point2D))
|
1241
|
drawingObjectBases.Add(point2D);
|
1242
|
}
|
1243
|
else if (connector.ConnectItem2SymbolObject != null && connector.ConnectItem2SymbolID != _LMSymbol.Id)
|
1244
|
{
|
1245
|
Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()] as Point2d;
|
1246
|
if (point2D != null && !drawingObjectBases.Contains(point2D))
|
1247
|
drawingObjectBases.Add(point2D);
|
1248
|
}
|
1249
|
}
|
1250
|
#endregion
|
1251
|
#region Not Zero Length And Branch And Vertical,Horizontal
|
1252
|
else
|
1253
|
{
|
1254
|
if (connector.ConnectItem1SymbolObject != null &&
|
1255
|
connector.ConnectItem1SymbolID != _LMSymbol.Id &&
|
1256
|
connector.ConnectItem1SymbolObject.get_ItemStatus() == "Active" &&
|
1257
|
connector.ConnectItem1SymbolObject.get_RepresentationType() == "Branch" &&
|
1258
|
IsMovePoint2D(connector.ConnectItem1SymbolObject, connector, arrow))
|
1259
|
{
|
1260
|
Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem1SymbolObject.get_GraphicOID().ToString()] as Point2d;
|
1261
|
if (point2D != null && !drawingObjectBases.Contains(point2D))
|
1262
|
drawingObjectBases.Add(point2D);
|
1263
|
}
|
1264
|
|
1265
|
else if (connector.ConnectItem2SymbolObject != null &&
|
1266
|
connector.ConnectItem2SymbolID != _LMSymbol.Id &&
|
1267
|
connector.ConnectItem2SymbolObject.get_ItemStatus() == "Active" &&
|
1268
|
connector.ConnectItem2SymbolObject.get_RepresentationType() == "Branch" &&
|
1269
|
IsMovePoint2D(connector.ConnectItem2SymbolObject, connector, arrow))
|
1270
|
{
|
1271
|
Point2d point2D = application.ActiveDocument.ActiveSheet.DrawingObjects[connector.ConnectItem2SymbolObject.get_GraphicOID().ToString()] as Point2d;
|
1272
|
if (point2D != null && !drawingObjectBases.Contains(point2D))
|
1273
|
drawingObjectBases.Add(point2D);
|
1274
|
}
|
1275
|
|
1276
|
}
|
1277
|
#endregion
|
1278
|
}
|
1279
|
}
|
1280
|
}
|
1281
|
ReleaseCOMObjects(_LMSymbol);
|
1282
|
}
|
1283
|
else if (drawingObject.GetType() == typeof(Point2d))
|
1284
|
{
|
1285
|
Point2d point2D = drawingObject as Point2d;
|
1286
|
if (!drawingObjectBases.Contains(point2D))
|
1287
|
drawingObjectBases.Add(point2D);
|
1288
|
}
|
1289
|
}
|
1290
|
|
1291
|
application.ActiveSelectSet.RemoveAll();
|
1292
|
if (drawingObjectBases.Count > 0 && transform != null)
|
1293
|
{
|
1294
|
application.ActiveSelectSet.AddObjects(drawingObjectBases);
|
1295
|
SetTransform(transform, arrow);
|
1296
|
application.ActiveSelectSet.Transform(transform, false);
|
1297
|
|
1298
|
application.ActiveSelectSet.RemoveAll();
|
1299
|
application.ActiveSelectSet.AddObjects(originalDrawingObjectBases);
|
1300
|
}
|
1301
|
|
1302
|
//foreach (DrawingObjectBaseEx item in drawingObjectBases)
|
1303
|
// MoveSymbol(item, arrow);
|
1304
|
|
1305
|
ReleaseCOMObjects(dataSource);
|
1306
|
ReleaseCOMObjects(placement);
|
1307
|
}
|
1308
|
}
|
1309
|
private bool IsMovePoint2D(LMSymbol branchSymbol, LMConnector targetConnector, Arrow arrow)
|
1310
|
{
|
1311
|
bool result = false;
|
1312
|
|
1313
|
DependencyObject dependency = application.ActiveDocument.ActiveSheet.DrawingObjects[targetConnector.get_GraphicOID().ToString()] as DependencyObject;
|
1314
|
SlopeType mainSlope = GetLineSlopeType(dependency);
|
1315
|
|
1316
|
if (mainSlope == SlopeType.HORIZONTAL || mainSlope == SlopeType.VERTICAL)
|
1317
|
{
|
1318
|
List<SlopeType> types = new List<SlopeType>();
|
1319
|
|
1320
|
foreach (LMConnector connector in branchSymbol.Connect1Connectors)
|
1321
|
{
|
1322
|
if (connector.get_ItemStatus() == "Active" &&
|
1323
|
connector.Id != targetConnector.Id &&
|
1324
|
!Convert.ToBoolean(connector.get_IsZeroLength()))
|
1325
|
types.Add(GetLineSlopeType(application.ActiveDocument.ActiveSheet.DrawingObjects[connector.get_GraphicOID().ToString()] as DependencyObject));
|
1326
|
}
|
1327
|
|
1328
|
foreach (LMConnector connector in branchSymbol.Connect2Connectors)
|
1329
|
{
|
1330
|
if (connector.get_ItemStatus() == "Active" &&
|
1331
|
connector.Id != targetConnector.Id &&
|
1332
|
!Convert.ToBoolean(connector.get_IsZeroLength()))
|
1333
|
types.Add(GetLineSlopeType(application.ActiveDocument.ActiveSheet.DrawingObjects[connector.get_GraphicOID().ToString()] as DependencyObject));
|
1334
|
}
|
1335
|
|
1336
|
foreach (var type in types)
|
1337
|
{
|
1338
|
if (type == mainSlope)
|
1339
|
{
|
1340
|
if (type == SlopeType.HORIZONTAL && (arrow == Arrow.Up || arrow == Arrow.Down))
|
1341
|
result = true;
|
1342
|
else if (type == SlopeType.VERTICAL && (arrow == Arrow.Left || arrow == Arrow.Right))
|
1343
|
result = true;
|
1344
|
else
|
1345
|
{
|
1346
|
result = false;
|
1347
|
break;
|
1348
|
}
|
1349
|
}
|
1350
|
else
|
1351
|
result = true;
|
1352
|
}
|
1353
|
|
1354
|
if (result)
|
1355
|
{
|
1356
|
if ((arrow == Arrow.Down || arrow == Arrow.Up) && mainSlope == SlopeType.VERTICAL)
|
1357
|
result = false;
|
1358
|
else if ((arrow == Arrow.Left || arrow == Arrow.Right) && mainSlope == SlopeType.HORIZONTAL)
|
1359
|
result = false;
|
1360
|
}
|
1361
|
}
|
1362
|
|
1363
|
return result;
|
1364
|
}
|
1365
|
private SlopeType GetLineSlopeType(DependencyObject dependency)
|
1366
|
{
|
1367
|
if (dependency != null && dependency.DrawingObjects.Count == 1 && dependency.DrawingObjects[0].GetType() == typeof(LineString2d))
|
1368
|
{
|
1369
|
LineString2d line = dependency.DrawingObjects[0] as LineString2d;
|
1370
|
double x1 = 0, y1 = 0, x2 = double.MaxValue, y2 = double.MaxValue;
|
1371
|
for (int i = 0; i < line.KeyPointCount; i++)
|
1372
|
{
|
1373
|
double x, y, z;
|
1374
|
KeyPointType keyPointType;
|
1375
|
HandleType handleType;
|
1376
|
line.GetKeyPoint(i, out x, out y, out z, out keyPointType, out handleType);
|
1377
|
if (keyPointType == KeyPointType.igKeyPointStart)
|
1378
|
{
|
1379
|
x1 = x;
|
1380
|
y1 = y;
|
1381
|
}
|
1382
|
else if (keyPointType == KeyPointType.igKeyPointEnd)
|
1383
|
{
|
1384
|
x2 = x;
|
1385
|
y2 = y;
|
1386
|
}
|
1387
|
}
|
1388
|
return SPPIDUtil.CalcSlope(x1, y1, x2, y2, 0.5);
|
1389
|
}
|
1390
|
|
1391
|
return SlopeType.None;
|
1392
|
}
|
1393
|
private void MoveSymbol(DrawingObjectBaseEx drawingObjectBase, Arrow arrow)
|
1394
|
{
|
1395
|
if (drawingObjectBase == null)
|
1396
|
return;
|
1397
|
|
1398
|
GridSetting gridSetting = GridSetting.GetInstance();
|
1399
|
switch (arrow)
|
1400
|
{
|
1401
|
case Arrow.Left:
|
1402
|
drawingObjectBase.Move(0, 0, -gridSetting.Length, 0);
|
1403
|
break;
|
1404
|
case Arrow.Up:
|
1405
|
drawingObjectBase.Move(0, 0, 0, gridSetting.Length);
|
1406
|
break;
|
1407
|
case Arrow.Right:
|
1408
|
drawingObjectBase.Move(0, 0, gridSetting.Length, 0);
|
1409
|
break;
|
1410
|
case Arrow.Down:
|
1411
|
drawingObjectBase.Move(0, 0, 0, -gridSetting.Length);
|
1412
|
break;
|
1413
|
default:
|
1414
|
break;
|
1415
|
}
|
1416
|
}
|
1417
|
private void SetTransform(Transform transform, Arrow arrow)
|
1418
|
{
|
1419
|
if (transform == null)
|
1420
|
return;
|
1421
|
|
1422
|
GridSetting gridSetting = GridSetting.GetInstance();
|
1423
|
switch (arrow)
|
1424
|
{
|
1425
|
case Arrow.Left:
|
1426
|
transform.DefineByMove2d(-gridSetting.Length, 0);
|
1427
|
break;
|
1428
|
case Arrow.Up:
|
1429
|
transform.DefineByMove2d(0, gridSetting.Length);
|
1430
|
break;
|
1431
|
case Arrow.Right:
|
1432
|
transform.DefineByMove2d(gridSetting.Length, 0);
|
1433
|
break;
|
1434
|
case Arrow.Down:
|
1435
|
transform.DefineByMove2d(0, -gridSetting.Length);
|
1436
|
break;
|
1437
|
default:
|
1438
|
break;
|
1439
|
}
|
1440
|
}
|
1441
|
#endregion
|
1442
|
|
1443
|
#endregion
|
1444
|
|
1445
|
#region TEST
|
1446
|
|
1447
|
private void simpleButton1_Click(object sender, EventArgs e)
|
1448
|
{
|
1449
|
SPPIDUtil.test();
|
1450
|
//Placement placement = new Placement();
|
1451
|
//LMADataSource dataSource = placement.PIDDataSource;
|
1452
|
//string a = "0A509911F33441A2AF088BFBA78B770D";
|
1453
|
//LMLabelPersist label = dataSource.GetLabelPersist(a);
|
1454
|
//label.set_XCoordinate(0.4);
|
1455
|
|
1456
|
|
1457
|
|
1458
|
|
1459
|
//LMOptionSettings
|
1460
|
|
1461
|
|
1462
|
//LMAFilter filter = new LMAFilter();
|
1463
|
//LMACriterion criterion = new LMACriterion();
|
1464
|
//filter.ItemType = "Relationship";
|
1465
|
//criterion.SourceAttributeName = "SP_DRAWINGID";
|
1466
|
//criterion.Operator = "=";
|
1467
|
//criterion.set_ValueAttribute(drawingID);
|
1468
|
//filter.get_Criteria().Add(criterion);
|
1469
|
|
1470
|
//LMRelationships relationships = new LMRelationships();
|
1471
|
//relationships.Collect(dataSource, Filter: filter);
|
1472
|
|
1473
|
}
|
1474
|
|
1475
|
private void AutoJoinPipeRun()
|
1476
|
{
|
1477
|
dynamic application = Interaction.GetObject("", "PIDAutomation.Application");
|
1478
|
WrapperApplication wApp = new WrapperApplication(application.Application);
|
1479
|
Ingr.RAD2D.Application radApp = wApp.RADApplication;
|
1480
|
|
1481
|
string modelItemId = null;
|
1482
|
List<double[]> vertices = new List<double[]>();
|
1483
|
if (radApp.ActiveSelectSet.Count == 0)
|
1484
|
{
|
1485
|
return;
|
1486
|
}
|
1487
|
dynamic OID = radApp.ActiveSelectSet[0].Key();
|
1488
|
DependencyObject drawingObject = radApp.ActiveDocument.ActiveSheet.DrawingObjects[OID];
|
1489
|
foreach (var attributes in drawingObject.AttributeSets)
|
1490
|
{
|
1491
|
foreach (var attribute in attributes)
|
1492
|
{
|
1493
|
if (attribute.Name == "ModelID")
|
1494
|
modelItemId = attribute.GetValue().ToString();
|
1495
|
}
|
1496
|
}
|
1497
|
radApp.ActiveSelectSet.RemoveAll();
|
1498
|
|
1499
|
}
|
1500
|
#endregion
|
1501
|
|
1502
|
|
1503
|
[DllImport("user32.dll")]
|
1504
|
public static extern int FindWindow(string lpClassName, string lpWindowName);
|
1505
|
|
1506
|
[DllImport("user32.dll", SetLastError = true)]
|
1507
|
static extern int GetWindowThreadProcessId(IntPtr hWnd, out int processId);
|
1508
|
|
1509
|
private void ConverterDocking_Load(object sender, EventArgs e)
|
1510
|
{
|
1511
|
#if DEBUG
|
1512
|
this.layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
|
1513
|
#else
|
1514
|
this.layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
|
1515
|
#endif
|
1516
|
|
1517
|
}
|
1518
|
}
|
1519
|
}
|