개정판 07bf38e1
dev issue #728: Convert vb to C#
DTI_PID/SPPIDAutoModeling/ItemObject.cs | ||
---|---|---|
1 | 1 |
using System; |
2 | 2 |
using System.Collections.Generic; |
3 |
using System.ComponentModel; |
|
3 | 4 |
using System.Linq; |
5 |
using System.Runtime.InteropServices; |
|
4 | 6 |
using System.Text; |
5 | 7 |
using System.Threading.Tasks; |
6 | 8 |
using Llama; |
... | ... | |
34 | 36 |
|
35 | 37 |
public class Group |
36 | 38 |
{ |
37 |
private List<Symbol> _SYMBOLS = new List<Symbol>();
|
|
38 |
private List<Line> _LINES = new List<Line>();
|
|
39 |
private List<object> _Items = new List<object>();
|
|
40 |
private bool _Enable = true;
|
|
39 | 41 |
|
40 |
public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; } |
|
41 |
public List<Line> LINES { get => _LINES; set => _LINES = value; } |
|
42 |
public List<object> Items { get => _Items; set => _Items = value; } |
|
43 |
public bool Enable { get => _Enable; set => _Enable = value; } |
|
44 |
} |
|
45 |
|
|
46 |
public class Association |
|
47 |
{ |
|
48 |
private string _TYPE; |
|
49 |
private string _TYPE_VALUE; |
|
50 |
|
|
51 |
public string TYPE { get => _TYPE; set => _TYPE = value; } |
|
52 |
public string TYPE_VALUE { get => _TYPE_VALUE; set => _TYPE_VALUE = value; } |
|
42 | 53 |
} |
43 | 54 |
|
44 | 55 |
|
... | ... | |
53 | 64 |
private List<Line> _LINES = new List<Line>(); |
54 | 65 |
private List<LineNumber> _LINENUMBERS = new List<LineNumber>(); |
55 | 66 |
private List<Text> _TEXTS = new List<Text>(); |
56 |
private Dictionary<string, List<PointdInfo>> _PipeRunPoint = new Dictionary<string, List<PointdInfo>>();
|
|
57 |
private List<Group> _GROUP = new List<Group>(); |
|
67 |
private Dictionary<string, List<PointInfo>> _PipeRunPoint = new Dictionary<string, List<PointInfo>>();
|
|
68 |
private List<Group> _GROUPS = new List<Group>();
|
|
58 | 69 |
|
59 | 70 |
private double _WIDTH; |
60 | 71 |
private double _HEIGHT; |
... | ... | |
70 | 81 |
} |
71 | 82 |
} |
72 | 83 |
public string UNIT { get => _UNIT; set => _UNIT = value; } |
73 |
public Dictionary<string, List<PointdInfo>> PipeRunPoint { get => _PipeRunPoint; set => _PipeRunPoint = value; }
|
|
84 |
public Dictionary<string, List<PointInfo>> PipeRunPoint { get => _PipeRunPoint; set => _PipeRunPoint = value; } |
|
74 | 85 |
public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; } |
75 | 86 |
public List<Line> LINES { get => _LINES; set => _LINES = value; } |
76 | 87 |
public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; } |
77 | 88 |
public List<Text> TEXTS { get => _TEXTS; set => _TEXTS = value; } |
78 | 89 |
public double WIDTH { get => _WIDTH; set => _WIDTH = value; } |
79 | 90 |
public double HEIGHT { get => _HEIGHT; set => _HEIGHT = value; } |
80 |
public List<Group> GROUP { get => _GROUP; set => _GROUP = value; }
|
|
91 |
public List<Group> GROUPS { get => _GROUPS; set => _GROUPS = value; }
|
|
81 | 92 |
#endregion |
82 | 93 |
} |
83 |
public class PointdInfo |
|
94 |
|
|
95 |
public class PointInfo |
|
84 | 96 |
{ |
97 |
public PointInfo(double x, double y) |
|
98 |
{ |
|
99 |
this.x = x; |
|
100 |
this.y = y; |
|
101 |
} |
|
102 |
|
|
85 | 103 |
public enum PointType |
86 | 104 |
{ |
87 | 105 |
None = 0, |
... | ... | |
89 | 107 |
Branch = 2, |
90 | 108 |
} |
91 | 109 |
#region Property |
92 |
private Pointd _Pointd; |
|
110 |
private double x; |
|
111 |
private double y; |
|
93 | 112 |
private PointType _Type; |
113 |
private string _ConnectedItem; |
|
94 | 114 |
private string _SP_ID; |
115 |
private SPPID_ITEM _ConnectedItemObject; |
|
95 | 116 |
|
96 |
public Pointd Pointd { get => _Pointd; set => _Pointd = value; } |
|
117 |
public double X { get { return x; } set { x = value; } } |
|
118 |
public double Y { get { return y; } set { y = value; } } |
|
97 | 119 |
public PointType Type { get => _Type; set => _Type = value; } |
120 |
public string ConnectedItem { get => _ConnectedItem; set => _ConnectedItem = value; } |
|
121 |
public SPPID_ITEM ConnectedItemObject { get => _ConnectedItemObject; set => _ConnectedItemObject = value; } |
|
98 | 122 |
public string SP_ID { get => _SP_ID; set => _SP_ID = value; } |
99 | 123 |
#endregion |
100 | 124 |
} |
101 |
public struct Pointd |
|
102 |
{ |
|
103 |
public Pointd(double x, double y) |
|
104 |
{ |
|
105 |
X = x; |
|
106 |
Y = y; |
|
107 |
} |
|
108 |
public double X; |
|
109 |
public double Y; |
|
110 |
} |
|
111 | 125 |
|
112 | 126 |
|
113 | 127 |
public abstract class SPPID_ITEM |
... | ... | |
118 | 132 |
private string _NAME; |
119 | 133 |
private SPPID_ITEM_TYPE _SPPID_TYPE ; |
120 | 134 |
private string _SPPIDMAPPINGNAME; |
121 |
private bool _GROUPING = true;
|
|
135 |
private bool _GROUPING; |
|
122 | 136 |
private string _AREA; |
123 |
private List<Attribute> _ATTRIBUTES = new List<Attribute>();
|
|
137 |
private List<ItemAttribute> _ATTRIBUTES = new List<ItemAttribute>();
|
|
124 | 138 |
private object _SPPID_ITEM_OBJECT; |
125 | 139 |
|
126 | 140 |
public string UID { get => _UID; set => _UID = value; } |
... | ... | |
131 | 145 |
public string AREA { get => _AREA; set => _AREA = value; } |
132 | 146 |
public object SPPID_ITEM_OBJECT { get => _SPPID_ITEM_OBJECT; set => _SPPID_ITEM_OBJECT = value; } |
133 | 147 |
public SPPID_ITEM_TYPE SPPID_TYPE { get => _SPPID_TYPE; set => _SPPID_TYPE = value; } |
134 |
public List<Attribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; } |
|
148 |
public List<ItemAttribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; }
|
|
135 | 149 |
#endregion |
136 | 150 |
|
137 |
public abstract void Modeling();
|
|
151 |
public abstract bool Modeling();
|
|
138 | 152 |
public abstract void AfterSetting(); |
139 | 153 |
public abstract void SetAttribute(); |
140 | 154 |
} |
... | ... | |
143 | 157 |
{ |
144 | 158 |
#region Property |
145 | 159 |
private string _ORIGINALPOINT; |
160 |
private List<Association> _ASSOCIATIONS = new List<Association>(); |
|
146 | 161 |
private List<Connector> _CONNECTORS = new List<Connector>(); |
147 | 162 |
private string _CONNECTIONPOINT; |
148 | 163 |
private string _LOCATION; |
... | ... | |
173 | 188 |
public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; } |
174 | 189 |
public string CONNECTIONPOINT { get => _CONNECTIONPOINT; set => _CONNECTIONPOINT = value; } |
175 | 190 |
public List<SymbolChild> CHILD_LIST { get => _CHILD_LIST; set => _CHILD_LIST = value; } |
191 |
public List<Association> ASSOCIATIONS { get => _ASSOCIATIONS; set => _ASSOCIATIONS = value; } |
|
176 | 192 |
#endregion |
177 | 193 |
public override void AfterSetting() |
178 | 194 |
{ |
179 | 195 |
// SPPIDMAPPINGNAME Setting |
180 |
SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME);
|
|
196 |
SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(PARENT);
|
|
181 | 197 |
// End |
182 | 198 |
|
183 | 199 |
// Angle Setting |
... | ... | |
203 | 219 |
// Child Setting |
204 | 220 |
if (!string.IsNullOrEmpty(CHILD) && CHILD != "None") |
205 | 221 |
{ |
206 |
string[] childArray = CHILD.Split(new char[] { ',' });
|
|
207 |
for (int i = 0; i < childArray.Length; i++)
|
|
222 |
string[] array = CHILD.Split(new char[] { ',' });
|
|
223 |
for (int i = 0; i < array.Length; i++)
|
|
208 | 224 |
{ |
209 | 225 |
SymbolChild child = new SymbolChild() |
210 | 226 |
{ |
211 |
Arrow = childArray[0],
|
|
212 |
Name = childArray[1],
|
|
213 |
Index = i |
|
227 |
Arrow = array[0],
|
|
228 |
Name = array[1],
|
|
229 |
Index = i + 1,
|
|
214 | 230 |
}; |
215 | 231 |
child.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(child.Name); |
216 | 232 |
CHILD_LIST.Add(child); |
... | ... | |
218 | 234 |
} |
219 | 235 |
// End |
220 | 236 |
|
237 |
// ConnectionPoint Setting |
|
238 |
if (!string.IsNullOrEmpty(CONNECTIONPOINT) && CONNECTIONPOINT != "None") |
|
239 |
{ |
|
240 |
string[] array = CONNECTIONPOINT.Split(new char[] { '/' }); |
|
241 |
for (int i = 0; i < array.Length; i++) |
|
242 |
{ |
|
243 |
string[] arrConn = array[i].Split(new char[] { ',' }); |
|
244 |
CONNECTORS[i].INDEX = Convert.ToInt32(arrConn[3]); |
|
245 |
} |
|
246 |
} |
|
247 |
// End |
|
248 |
|
|
221 | 249 |
// Input Drawing |
222 | 250 |
AutoModeling.DrawingItem.SYMBOLS.Add(this); |
223 | 251 |
// End |
224 | 252 |
} |
225 | 253 |
|
226 |
public override void Modeling()
|
|
254 |
public override bool Modeling()
|
|
227 | 255 |
{ |
228 | 256 |
try |
229 | 257 |
{ |
... | ... | |
280 | 308 |
_childLmSymbol.Commit(); |
281 | 309 |
symoblChild.SPPID_ITEM_OBJECT = _childLmSymbol; |
282 | 310 |
} |
283 |
catch (Exception) |
|
311 |
catch (Exception ex)
|
|
284 | 312 |
{ |
313 |
Console.WriteLine(ex.StackTrace); |
|
314 |
} |
|
315 |
} |
|
316 |
// End |
|
285 | 317 |
|
318 |
// Association Modeling |
|
319 |
try |
|
320 |
{ |
|
321 |
foreach (Association item in ASSOCIATIONS) |
|
322 |
{ |
|
323 |
object _obj = SPPIDUtill.FindObjectByUID(item.TYPE_VALUE); |
|
324 |
if (_obj != null && typeof(Text) == _obj.GetType()) |
|
325 |
{ |
|
326 |
Text text = _obj as Text; |
|
327 |
if (text.NAME == "SIZE") |
|
328 |
{ |
|
329 |
text.OWNER = UID; |
|
330 |
text.Modeling(); |
|
331 |
text.SetAttribute(); |
|
332 |
} |
|
333 |
} |
|
286 | 334 |
} |
287 | 335 |
} |
336 |
catch (Exception ex) |
|
337 |
{ |
|
338 |
Console.WriteLine(ex.StackTrace); |
|
339 |
} |
|
288 | 340 |
// End |
289 | 341 |
} |
290 | 342 |
} |
291 |
catch (Exception) |
|
343 |
catch (Exception ex)
|
|
292 | 344 |
{ |
293 |
|
|
345 |
Console.WriteLine(ex.StackTrace); |
|
346 |
return false; |
|
294 | 347 |
} |
348 |
return true; |
|
295 | 349 |
} |
296 | 350 |
|
297 | 351 |
public override void SetAttribute() |
... | ... | |
302 | 356 |
|
303 | 357 |
public class Line : SPPID_ITEM |
304 | 358 |
{ |
305 |
public enum SlopType |
|
359 |
public enum SlopeType
|
|
306 | 360 |
{ |
307 | 361 |
NONE = 0, |
308 | 362 |
VERTICAL = 1, |
... | ... | |
313 | 367 |
private string _STARTPOINT; |
314 | 368 |
private string _ENDPOINT; |
315 | 369 |
private List<Connector> _CONNECTORS = new List<Connector>(); |
316 |
private string _LMCONNECTOR_MODELID; |
|
317 |
private SlopType _SLOPTYPE; |
|
370 |
private SlopeType _SLOPTYPE; |
|
318 | 371 |
private double _START_X; |
319 | 372 |
private double _START_Y; |
320 | 373 |
private double _END_X; |
... | ... | |
322 | 375 |
|
323 | 376 |
public string STARTPOINT { get => _STARTPOINT; set => _STARTPOINT = value; } |
324 | 377 |
public string ENDPOINT { get => _ENDPOINT; set => _ENDPOINT = value; } |
325 |
public string LMCONNECTOR_MODELID { get => _LMCONNECTOR_MODELID; set => _LMCONNECTOR_MODELID = value; } |
|
326 | 378 |
public double START_X { get => _START_X; set => _START_X = value; } |
327 | 379 |
public double START_Y { get => _START_Y; set => _START_Y = value; } |
328 | 380 |
public double END_X { get => _END_X; set => _END_X = value; } |
329 | 381 |
public double END_Y { get => _END_Y; set => _END_Y = value; } |
330 | 382 |
public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; } |
331 |
public SlopType SLOPTYPE { get => _SLOPTYPE; set => _SLOPTYPE = value; } |
|
383 |
public SlopeType SLOPTYPE { get => _SLOPTYPE; set => _SLOPTYPE = value; }
|
|
332 | 384 |
#endregion |
333 | 385 |
public override void AfterSetting() |
334 | 386 |
{ |
335 | 387 |
// SPPIDMAPPINGNAME Setting |
336 |
SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME);
|
|
388 |
SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(TYPE);
|
|
337 | 389 |
// End |
338 | 390 |
|
339 | 391 |
// Point Setting |
... | ... | |
344 | 396 |
// End |
345 | 397 |
|
346 | 398 |
// Slop Setting |
347 |
_SLOPTYPE = SPPIDUtill.CalcSlop(new Pointd(_START_X, _START_Y), new Pointd(_END_X, _END_Y));
|
|
399 |
SLOPTYPE = SPPIDUtill.CalcSlop(new PointInfo(_START_X, _START_Y), new PointInfo(_END_X, _END_Y));
|
|
348 | 400 |
// End |
349 | 401 |
|
350 | 402 |
// SPPID Type Setting |
... | ... | |
356 | 408 |
// End |
357 | 409 |
} |
358 | 410 |
|
359 |
public override void Modeling()
|
|
411 |
public override bool Modeling()
|
|
360 | 412 |
{ |
361 | 413 |
throw new MissingMethodException(); |
362 | 414 |
} |
... | ... | |
381 | 433 |
private double _LOCATION_Y; |
382 | 434 |
private string _TEXT; |
383 | 435 |
private string _CONNECTLINE; |
384 |
private Line _TARGETLINE; |
|
385 | 436 |
private LineNumberType _LINENUMBERTYPE; |
386 | 437 |
|
387 | 438 |
public double ANGLE { get => _ANGLE; set => _ANGLE = value; } |
... | ... | |
390 | 441 |
public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; } |
391 | 442 |
public string TEXT { get => _TEXT; set => _TEXT = value; } |
392 | 443 |
public string CONNECTLINE { get => _CONNECTLINE; set => _CONNECTLINE = value; } |
393 |
public Line TARGETLINE { get => _TARGETLINE; set => _TARGETLINE = value; } |
|
394 | 444 |
public LineNumberType LINENUMBERTYPE { get => _LINENUMBERTYPE; set => _LINENUMBERTYPE = value; } |
395 | 445 |
#endregion |
396 | 446 |
|
... | ... | |
425 | 475 |
// End |
426 | 476 |
} |
427 | 477 |
|
428 |
public override void Modeling()
|
|
478 |
public override bool Modeling()
|
|
429 | 479 |
{ |
430 | 480 |
try |
431 | 481 |
{ |
432 |
if (TARGETLINE != null && !string.IsNullOrEmpty(TARGETLINE.LMCONNECTOR_MODELID)) |
|
482 |
Line targetLine = SPPIDUtill.FindObjectByUID(CONNECTLINE) as Line; |
|
483 |
if (targetLine != null && !string.IsNullOrEmpty(targetLine.SPPID_ITEM_OBJECT.ToString())) |
|
433 | 484 |
{ |
434 | 485 |
Placement _placement = new Placement(); |
435 |
Array points = new double[] { LOCATION_X, LOCATION_Y }; |
|
436 |
LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(TARGETLINE.LMCONNECTOR_MODELID);
|
|
486 |
Array points = new double[] { 0, LOCATION_X, LOCATION_Y };
|
|
487 |
LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(targetLine.SPPID_ITEM_OBJECT.ToString());
|
|
437 | 488 |
if (_pipeRun != null) |
438 | 489 |
{ |
439 | 490 |
foreach (LMRepresentation rep in _pipeRun.Representations) |
... | ... | |
449 | 500 |
} |
450 | 501 |
} |
451 | 502 |
} |
452 |
catch (Exception) |
|
503 |
catch (Exception ex)
|
|
453 | 504 |
{ |
454 |
|
|
505 |
Console.WriteLine(ex.StackTrace); |
|
506 |
return false; |
|
455 | 507 |
} |
508 |
return true; |
|
456 | 509 |
} |
457 | 510 |
|
458 | 511 |
public override void SetAttribute() |
459 | 512 |
{ |
460 |
throw new NotImplementedException(); |
|
513 |
try |
|
514 |
{ |
|
515 |
Line targetLine = SPPIDUtill.FindObjectByUID(CONNECTLINE) as Line; |
|
516 |
if (targetLine != null) |
|
517 |
{ |
|
518 |
Placement _placement = new Placement(); |
|
519 |
LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(targetLine.SPPID_ITEM_OBJECT.ToString()); |
|
520 |
|
|
521 |
foreach (ItemAttribute attr in ATTRIBUTES) |
|
522 |
{ |
|
523 |
if (string.IsNullOrEmpty(attr.VALUE)) |
|
524 |
continue; |
|
525 |
|
|
526 |
LMAAttribute lMAAttribute = _pipeRun.Attributes[attr.Attribute]; |
|
527 |
if (lMAAttribute != null) |
|
528 |
_pipeRun.Attributes[attr.Attribute].set_Value(attr.VALUE); |
|
529 |
} |
|
530 |
_pipeRun.Commit(); |
|
531 |
} |
|
532 |
} |
|
533 |
catch (Exception ex) |
|
534 |
{ |
|
535 |
Console.WriteLine(ex.StackTrace); |
|
536 |
} |
|
461 | 537 |
} |
462 | 538 |
} |
463 | 539 |
|
... | ... | |
468 | 544 |
private string _LOCATION; |
469 | 545 |
private double _LOCATION_X; |
470 | 546 |
private double _LOCATION_Y; |
471 |
private string _TEXT;
|
|
547 |
private string _VALUE;
|
|
472 | 548 |
private string _OWNER; |
473 | 549 |
|
474 | 550 |
public double ANGLE { get => _ANGLE; set => _ANGLE = value; } |
475 | 551 |
public string LOCATION { get => _LOCATION; set => _LOCATION = value; } |
476 | 552 |
public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; } |
477 | 553 |
public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; } |
478 |
public string TEXT { get => _TEXT; set => _TEXT = value; }
|
|
554 |
public string VALUE { get => _VALUE; set => _VALUE = value; }
|
|
479 | 555 |
public string OWNER { get => _OWNER; set => _OWNER = value; } |
480 | 556 |
#endregion |
481 | 557 |
public override void AfterSetting() |
... | ... | |
509 | 585 |
// End |
510 | 586 |
} |
511 | 587 |
|
512 |
public override void Modeling()
|
|
588 |
public override bool Modeling()
|
|
513 | 589 |
{ |
514 | 590 |
try |
515 | 591 |
{ |
516 |
Placement _placement = new Placement(); |
|
517 |
if (NAME == "TEXT" || NAME == "NOTE") |
|
592 |
if (SPPID_ITEM_OBJECT == null) |
|
518 | 593 |
{ |
519 |
LMSymbol _LmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Rotation: ANGLE); |
|
520 |
LMItemNote _LmItemNote = _placement.PIDDataSource.GetItemNote(_LmSymbol.ModelItemID); |
|
521 |
_LmItemNote.Attributes["Note.Body"].set_Value(TEXT); |
|
522 |
_LmItemNote.Commit(); |
|
523 |
SPPID_ITEM_OBJECT = _LmItemNote; |
|
524 |
} |
|
525 |
else if (NAME == "SIZE" && !string.IsNullOrEmpty(OWNER)) |
|
526 |
{ |
|
527 |
object _obj = SPPIDUtill.FindObjectByUID(OWNER); |
|
528 |
|
|
529 |
Array array = new double[] { LOCATION_X, LOCATION_Y }; |
|
530 |
|
|
531 |
if (typeof(Symbol) == _obj.GetType()) |
|
594 |
Placement _placement = new Placement(); |
|
595 |
if (NAME == "TEXT" || NAME == "NOTE") |
|
532 | 596 |
{ |
533 |
Symbol _symbol = _obj as Symbol; |
|
534 |
LMSymbol _LmSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol; |
|
597 |
LMSymbol _LmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Rotation: ANGLE); |
|
598 |
LMItemNote _LmItemNote = _placement.PIDDataSource.GetItemNote(_LmSymbol.ModelItemID); |
|
599 |
_LmItemNote.Attributes["Note.Body"].set_Value(VALUE); |
|
600 |
_LmItemNote.Commit(); |
|
601 |
SPPID_ITEM_OBJECT = _LmItemNote; |
|
602 |
} |
|
603 |
else if (NAME == "SIZE" && !string.IsNullOrEmpty(OWNER)) |
|
604 |
{ |
|
605 |
object _obj = SPPIDUtill.FindObjectByUID(OWNER); |
|
606 |
if (_obj != null && typeof(Symbol) == _obj.GetType()) |
|
607 |
{ |
|
608 |
Array array = new double[] { 0, LOCATION_X, LOCATION_Y }; |
|
609 |
Symbol _symbol = _obj as Symbol; |
|
610 |
LMSymbol _LmSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol; |
|
535 | 611 |
|
536 |
string fileName = _LmSymbol.get_FileName(); |
|
537 |
if (fileName.Contains("Piping")) |
|
538 |
SPPIDMAPPINGNAME = @"\Piping\Labels - Piping Components\Nominal Diameter.sym"; |
|
539 |
else if (fileName.Contains("Instrumentation")) |
|
540 |
SPPIDMAPPINGNAME = @"\Instrumentation\Labels - General Instrument\Nominal Diameter.sym"; |
|
612 |
if (_LmSymbol != null) |
|
613 |
{ |
|
614 |
string fileName = _LmSymbol.get_FileName(); |
|
615 |
if (fileName.Contains("Piping")) |
|
616 |
SPPIDMAPPINGNAME = @"\Piping\Labels - Piping Components\Nominal Diameter.sym"; |
|
617 |
else if (fileName.Contains("Instrumentation")) |
|
618 |
SPPIDMAPPINGNAME = @"\Instrumentation\Labels - General Instrument\Nominal Diameter.sym"; |
|
541 | 619 |
|
542 |
LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref array, Rotation: ANGLE, LabeledItem: _LmSymbol.AsLMRepresentation(), IsLeaderVisible: true); |
|
543 |
_LmLabelPersist.Commit(); |
|
620 |
LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref array, Rotation: ANGLE, LabeledItem: _LmSymbol.AsLMRepresentation(), IsLeaderVisible: true);
|
|
621 |
_LmLabelPersist.Commit();
|
|
544 | 622 |
|
545 |
SPPID_ITEM_OBJECT = _LmLabelPersist; |
|
623 |
SPPID_ITEM_OBJECT = _LmLabelPersist; |
|
624 |
} |
|
625 |
} |
|
546 | 626 |
} |
547 | 627 |
} |
548 | 628 |
} |
549 |
catch (Exception) |
|
629 |
catch (Exception ex)
|
|
550 | 630 |
{ |
551 |
|
|
631 |
Console.WriteLine(ex.StackTrace); |
|
632 |
return false; |
|
552 | 633 |
} |
634 |
|
|
635 |
return true; |
|
553 | 636 |
} |
554 | 637 |
|
555 | 638 |
public override void SetAttribute() |
556 | 639 |
{ |
557 |
throw new NotImplementedException(); |
|
640 |
try |
|
641 |
{ |
|
642 |
Placement _placement = new Placement(); |
|
643 |
if (NAME == "SIZE") |
|
644 |
{ |
|
645 |
object _obj = SPPIDUtill.FindObjectByUID(OWNER); |
|
646 |
if (_obj != null && typeof(Symbol) == _obj.GetType()) |
|
647 |
{ |
|
648 |
Symbol _symbol = _obj as Symbol; |
|
649 |
LMSymbol _LmSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol; |
|
650 |
|
|
651 |
if (_LmSymbol != null) |
|
652 |
{ |
|
653 |
string fileName = _LmSymbol.get_FileName(); |
|
654 |
if (fileName.Contains("Piping")) |
|
655 |
{ |
|
656 |
LMPipingComp _LmPipingComp = _placement.PIDDataSource.GetPipingComp(_LmSymbol.ModelItemID); |
|
657 |
if (_LmPipingComp != null && DBNull.Value.Equals(_LmPipingComp.Attributes["NominalDiameter"].get_Value())) |
|
658 |
{ |
|
659 |
_LmPipingComp.Attributes["NominalDiameter"].set_Value(VALUE); |
|
660 |
_LmPipingComp.Commit(); |
|
661 |
} |
|
662 |
} |
|
663 |
else if (fileName.Contains("Instrumentation")) |
|
664 |
{ |
|
665 |
LMInstrument _LmInstrument = _placement.PIDDataSource.GetInstrument(_LmSymbol.ModelItemID); |
|
666 |
if (_LmInstrument != null && DBNull.Value.Equals(_LmInstrument.Attributes["NominalDiameter"].get_Value())) |
|
667 |
{ |
|
668 |
_LmInstrument.Attributes["NominalDiameter"].set_Value(VALUE); |
|
669 |
_LmInstrument.Commit(); |
|
670 |
} |
|
671 |
} |
|
672 |
} |
|
673 |
} |
|
674 |
} |
|
675 |
} |
|
676 |
catch (Exception ex) |
|
677 |
{ |
|
678 |
Console.WriteLine(ex.StackTrace); |
|
679 |
} |
|
680 |
|
|
681 |
|
|
682 |
|
|
683 |
//throw new NotImplementedException(); |
|
558 | 684 |
} |
559 | 685 |
} |
560 | 686 |
|
561 | 687 |
|
562 |
public class Attribute |
|
688 |
public class ItemAttribute
|
|
563 | 689 |
{ |
564 | 690 |
#region Property |
565 | 691 |
private string _UID; |
566 |
private string _NAME; |
|
692 |
private string _Length; |
|
693 |
private string _Expression; |
|
694 |
private string _DisplayAttribute; |
|
695 |
private string _AttributeType; |
|
696 |
private string _Attribute; |
|
697 |
private string _AttrAt; |
|
698 |
|
|
567 | 699 |
private string _VALUE; |
568 | 700 |
|
569 | 701 |
public string UID { get => _UID; set => _UID = value; } |
570 |
public string NAME { get => _NAME; set => _NAME = value; } |
|
571 | 702 |
public string VALUE { get => _VALUE; set => _VALUE = value; } |
703 |
public string Length { get => _Length; set => _Length = value; } |
|
704 |
public string Expression { get => _Expression; set => _Expression = value; } |
|
705 |
public string DisplayAttribute { get => _DisplayAttribute; set => _DisplayAttribute = value; } |
|
706 |
public string AttributeType { get => _AttributeType; set => _AttributeType = value; } |
|
707 |
public string Attribute { get => _Attribute; set => _Attribute = value; } |
|
708 |
public string AttrAt { get => _AttrAt; set => _AttrAt = value; } |
|
572 | 709 |
#endregion |
573 | 710 |
} |
574 | 711 |
|
... | ... | |
578 | 715 |
private string _CONNECTEDITEM; |
579 | 716 |
private string _CONNECTPOINT; |
580 | 717 |
private string _SCENECONNECTPOINT; |
581 |
private string _INDEX;
|
|
718 |
private int _INDEX;
|
|
582 | 719 |
|
583 | 720 |
public string CONNECTEDITEM { get => _CONNECTEDITEM; set => _CONNECTEDITEM = value; } |
584 | 721 |
public string CONNECTPOINT { get => _CONNECTPOINT; set => _CONNECTPOINT = value; } |
585 | 722 |
public string SCENECONNECTPOINT { get => _SCENECONNECTPOINT; set => _SCENECONNECTPOINT = value; } |
586 |
public string INDEX { get => _INDEX; set => _INDEX = value; }
|
|
723 |
public int INDEX { get => _INDEX; set => _INDEX = value; }
|
|
587 | 724 |
#endregion |
588 | 725 |
} |
589 | 726 |
} |
내보내기 Unified diff