hytos / DTI_PID / SPPIDAutoModeling / ItemObject.cs @ 21be5063
이력 | 보기 | 이력해설 | 다운로드 (22.3 KB)
1 | cdf18b83 | gaqhf | using System; |
---|---|---|---|
2 | using System.Collections.Generic; |
||
3 | using System.Linq; |
||
4 | using System.Text; |
||
5 | using System.Threading.Tasks; |
||
6 | using Llama; |
||
7 | using Plaice; |
||
8 | |||
9 | namespace SPPIDAutoModeling |
||
10 | { |
||
11 | public enum SPPID_ITEM_TYPE |
||
12 | { |
||
13 | SYMBOL = 1, |
||
14 | LINE = 2, |
||
15 | LABEL = 3, |
||
16 | TEXT = 4, |
||
17 | } |
||
18 | |||
19 | 21be5063 | gaqhf | public class SymbolChild |
20 | { |
||
21 | private string _Arrow; |
||
22 | private string _Name; |
||
23 | private int _Index; |
||
24 | private string _SPPIDMAPPINGNAME; |
||
25 | private object _SPPID_ITEM_OBJECT; |
||
26 | |||
27 | public string Arrow { get => _Arrow; set => _Arrow = value; } |
||
28 | public string Name { get => _Name; set => _Name = value; } |
||
29 | public int Index { get => _Index; set => _Index = value; } |
||
30 | public string SPPIDMAPPINGNAME { get => _SPPIDMAPPINGNAME; set => _SPPIDMAPPINGNAME = value; } |
||
31 | public object SPPID_ITEM_OBJECT { get => _SPPID_ITEM_OBJECT; set => _SPPID_ITEM_OBJECT = value; } |
||
32 | } |
||
33 | |||
34 | |||
35 | 8056c558 | gaqhf | public class Group |
36 | { |
||
37 | private List<Symbol> _SYMBOLS = new List<Symbol>(); |
||
38 | private List<Line> _LINES = new List<Line>(); |
||
39 | |||
40 | public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; } |
||
41 | public List<Line> LINES { get => _LINES; set => _LINES = value; } |
||
42 | } |
||
43 | cdf18b83 | gaqhf | |
44 | 21be5063 | gaqhf | |
45 | |||
46 | cdf18b83 | gaqhf | public class Drawing |
47 | { |
||
48 | #region Property |
||
49 | private string _DWGNAME; |
||
50 | private string _SIZE; |
||
51 | private string _UNIT; |
||
52 | 8056c558 | gaqhf | private List<Symbol> _SYMBOLS = new List<Symbol>(); |
53 | private List<Line> _LINES = new List<Line>(); |
||
54 | private List<LineNumber> _LINENUMBERS = new List<LineNumber>(); |
||
55 | private List<Text> _TEXTS = new List<Text>(); |
||
56 | cdf18b83 | gaqhf | private Dictionary<string, List<PointdInfo>> _PipeRunPoint = new Dictionary<string, List<PointdInfo>>(); |
57 | 8056c558 | gaqhf | private List<Group> _GROUP = new List<Group>(); |
58 | |||
59 | private double _WIDTH; |
||
60 | private double _HEIGHT; |
||
61 | cdf18b83 | gaqhf | |
62 | public string DWGNAME { get => _DWGNAME; set => _DWGNAME = value; } |
||
63 | 8056c558 | gaqhf | public string SIZE |
64 | { |
||
65 | get { return _SIZE; } |
||
66 | set |
||
67 | { |
||
68 | _SIZE = value; |
||
69 | SPPIDUtill.ConvertPointBystring(_SIZE, ref _WIDTH, ref _HEIGHT); |
||
70 | } |
||
71 | } |
||
72 | cdf18b83 | gaqhf | public string UNIT { get => _UNIT; set => _UNIT = value; } |
73 | public Dictionary<string, List<PointdInfo>> PipeRunPoint { get => _PipeRunPoint; set => _PipeRunPoint = value; } |
||
74 | public List<Symbol> SYMBOLS { get => _SYMBOLS; set => _SYMBOLS = value; } |
||
75 | public List<Line> LINES { get => _LINES; set => _LINES = value; } |
||
76 | public List<LineNumber> LINENUMBERS { get => _LINENUMBERS; set => _LINENUMBERS = value; } |
||
77 | public List<Text> TEXTS { get => _TEXTS; set => _TEXTS = value; } |
||
78 | 8056c558 | gaqhf | public double WIDTH { get => _WIDTH; set => _WIDTH = value; } |
79 | public double HEIGHT { get => _HEIGHT; set => _HEIGHT = value; } |
||
80 | public List<Group> GROUP { get => _GROUP; set => _GROUP = value; } |
||
81 | cdf18b83 | gaqhf | #endregion |
82 | } |
||
83 | public class PointdInfo |
||
84 | { |
||
85 | public enum PointType |
||
86 | { |
||
87 | 8056c558 | gaqhf | None = 0, |
88 | Run = 1, |
||
89 | Branch = 2, |
||
90 | cdf18b83 | gaqhf | } |
91 | #region Property |
||
92 | private Pointd _Pointd; |
||
93 | private PointType _Type; |
||
94 | private string _SP_ID; |
||
95 | |||
96 | public Pointd Pointd { get => _Pointd; set => _Pointd = value; } |
||
97 | public PointType Type { get => _Type; set => _Type = value; } |
||
98 | public string SP_ID { get => _SP_ID; set => _SP_ID = value; } |
||
99 | #endregion |
||
100 | } |
||
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 | |||
112 | |||
113 | public abstract class SPPID_ITEM |
||
114 | { |
||
115 | #region Property |
||
116 | private string _UID; |
||
117 | private string _TYPE; |
||
118 | private string _NAME; |
||
119 | private SPPID_ITEM_TYPE _SPPID_TYPE ; |
||
120 | private string _SPPIDMAPPINGNAME; |
||
121 | private bool _GROUPING = true; |
||
122 | private string _AREA; |
||
123 | private List<Attribute> _ATTRIBUTES = new List<Attribute>(); |
||
124 | private object _SPPID_ITEM_OBJECT; |
||
125 | |||
126 | public string UID { get => _UID; set => _UID = value; } |
||
127 | public string TYPE { get => _TYPE; set => _TYPE = value; } |
||
128 | public string NAME { get => _NAME; set => _NAME = value; } |
||
129 | public string SPPIDMAPPINGNAME { get => _SPPIDMAPPINGNAME; set => _SPPIDMAPPINGNAME = value; } |
||
130 | public bool GROUPING { get => _GROUPING; set => _GROUPING = value; } |
||
131 | public string AREA { get => _AREA; set => _AREA = value; } |
||
132 | public object SPPID_ITEM_OBJECT { get => _SPPID_ITEM_OBJECT; set => _SPPID_ITEM_OBJECT = value; } |
||
133 | public SPPID_ITEM_TYPE SPPID_TYPE { get => _SPPID_TYPE; set => _SPPID_TYPE = value; } |
||
134 | public List<Attribute> ATTRIBUTES { get => _ATTRIBUTES; set => _ATTRIBUTES = value; } |
||
135 | #endregion |
||
136 | 8056c558 | gaqhf | |
137 | public abstract void Modeling(); |
||
138 | cdf18b83 | gaqhf | public abstract void AfterSetting(); |
139 | public abstract void SetAttribute(); |
||
140 | } |
||
141 | |||
142 | public class Symbol : SPPID_ITEM |
||
143 | { |
||
144 | #region Property |
||
145 | private string _ORIGINALPOINT; |
||
146 | 8056c558 | gaqhf | private List<Connector> _CONNECTORS = new List<Connector>(); |
147 | 21be5063 | gaqhf | private string _CONNECTIONPOINT; |
148 | cdf18b83 | gaqhf | private string _LOCATION; |
149 | private string _SIZE; |
||
150 | private double _ANGLE; |
||
151 | private string _PARENT; |
||
152 | 21be5063 | gaqhf | private string _CHILD; |
153 | private List<SymbolChild> _CHILD_LIST = new List<SymbolChild>(); |
||
154 | cdf18b83 | gaqhf | private string _HASINSTRUMENTLABEL; |
155 | private string _CURRENTPOINTMODEINDEX; |
||
156 | private bool _DRAWCHECKED; |
||
157 | private double _LOCATION_X; |
||
158 | private double _LOCATION_Y; |
||
159 | private int _MIRROR = 0; |
||
160 | |||
161 | public string ORIGINALPOINT { get => _ORIGINALPOINT; set => _ORIGINALPOINT = value; } |
||
162 | public string LOCATION { get => _LOCATION; set => _LOCATION = value; } |
||
163 | public string SIZE { get => _SIZE; set => _SIZE = value; } |
||
164 | public double ANGLE { get => _ANGLE; set => _ANGLE = value; } |
||
165 | public string PARENT { get => _PARENT; set => _PARENT = value; } |
||
166 | 21be5063 | gaqhf | public string CHILD { get => _CHILD; set => _CHILD = value; } |
167 | cdf18b83 | gaqhf | public string HASINSTRUMENTLABEL { get => _HASINSTRUMENTLABEL; set => _HASINSTRUMENTLABEL = value; } |
168 | public string CURRENTPOINTMODEINDEX { get => _CURRENTPOINTMODEINDEX; set => _CURRENTPOINTMODEINDEX = value; } |
||
169 | public bool DRAWCHECKED { get => _DRAWCHECKED; set => _DRAWCHECKED = value; } |
||
170 | public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; } |
||
171 | public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; } |
||
172 | public int MIRROR { get => _MIRROR; set => _MIRROR = value; } |
||
173 | public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; } |
||
174 | 21be5063 | gaqhf | public string CONNECTIONPOINT { get => _CONNECTIONPOINT; set => _CONNECTIONPOINT = value; } |
175 | public List<SymbolChild> CHILD_LIST { get => _CHILD_LIST; set => _CHILD_LIST = value; } |
||
176 | cdf18b83 | gaqhf | #endregion |
177 | public override void AfterSetting() |
||
178 | { |
||
179 | 21be5063 | gaqhf | // SPPIDMAPPINGNAME Setting |
180 | SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME); |
||
181 | // End |
||
182 | |||
183 | cdf18b83 | gaqhf | // Angle Setting |
184 | if (ANGLE == 1.57) |
||
185 | ANGLE = 90 * Math.PI / 180; |
||
186 | else if (ANGLE == 3.14) |
||
187 | ANGLE = Math.PI; |
||
188 | else if (ANGLE == 4.71) |
||
189 | ANGLE = 270 * Math.PI / 180; |
||
190 | else |
||
191 | ANGLE = 0; |
||
192 | // End |
||
193 | |||
194 | // Location Setting |
||
195 | 8056c558 | gaqhf | SPPIDUtill.ConvertPointBystring(_ORIGINALPOINT, ref _LOCATION_X, ref _LOCATION_Y); |
196 | SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT); |
||
197 | // End |
||
198 | cdf18b83 | gaqhf | |
199 | 21be5063 | gaqhf | // SPPID Type Setting |
200 | 8056c558 | gaqhf | SPPID_TYPE = SPPID_ITEM_TYPE.SYMBOL; |
201 | cdf18b83 | gaqhf | // End |
202 | 21be5063 | gaqhf | |
203 | // Child Setting |
||
204 | if (!string.IsNullOrEmpty(CHILD) && CHILD != "None") |
||
205 | { |
||
206 | string[] childArray = CHILD.Split(new char[] { ',' }); |
||
207 | for (int i = 0; i < childArray.Length; i++) |
||
208 | { |
||
209 | SymbolChild child = new SymbolChild() |
||
210 | { |
||
211 | Arrow = childArray[0], |
||
212 | Name = childArray[1], |
||
213 | Index = i |
||
214 | }; |
||
215 | child.SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(child.Name); |
||
216 | CHILD_LIST.Add(child); |
||
217 | } |
||
218 | } |
||
219 | // End |
||
220 | |||
221 | // Input Drawing |
||
222 | AutoModeling.DrawingItem.SYMBOLS.Add(this); |
||
223 | // End |
||
224 | cdf18b83 | gaqhf | } |
225 | |||
226 | 8056c558 | gaqhf | public override void Modeling() |
227 | cdf18b83 | gaqhf | { |
228 | 8056c558 | gaqhf | try |
229 | { |
||
230 | Placement _placement = new Placement(); |
||
231 | LMSymbol lmSymbol = null; |
||
232 | SPPID_ITEM_OBJECT = null; |
||
233 | |||
234 | if (!string.IsNullOrEmpty(SPPIDMAPPINGNAME)) |
||
235 | { |
||
236 | LMSymbol connectedSymbol = null; |
||
237 | foreach (Connector connector in CONNECTORS) |
||
238 | { |
||
239 | if (!string.IsNullOrEmpty(connector.CONNECTEDITEM) || connector.CONNECTEDITEM != "None") |
||
240 | { |
||
241 | object _obj = SPPIDUtill.FindObjectByUID(connector.CONNECTEDITEM); |
||
242 | if (_obj != null && typeof(Symbol) == _obj.GetType()) |
||
243 | { |
||
244 | Symbol _symbol = _obj as Symbol; |
||
245 | if (_symbol.SPPID_ITEM_OBJECT != null) |
||
246 | connectedSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol; |
||
247 | } |
||
248 | } |
||
249 | } |
||
250 | |||
251 | if (connectedSymbol != null) |
||
252 | lmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Mirror: MIRROR, Rotation: ANGLE, TargetItem: connectedSymbol); |
||
253 | else |
||
254 | lmSymbol = _placement.PIDPlaceSymbol(SPPIDMAPPINGNAME, LOCATION_X, LOCATION_Y, Mirror: MIRROR, Rotation: ANGLE); |
||
255 | |||
256 | // Commit and input sppid item object |
||
257 | lmSymbol.Commit(); |
||
258 | SPPID_ITEM_OBJECT = lmSymbol; |
||
259 | // End |
||
260 | |||
261 | // Check Child And Modeling |
||
262 | 21be5063 | gaqhf | foreach (SymbolChild symoblChild in CHILD_LIST) |
263 | 8056c558 | gaqhf | { |
264 | try |
||
265 | { |
||
266 | 21be5063 | gaqhf | string sArrow = symoblChild.Arrow; |
267 | string sMappingName = symoblChild.SPPIDMAPPINGNAME; |
||
268 | 8056c558 | gaqhf | |
269 | double dChildAngle = 0; |
||
270 | if (sArrow == "UP") |
||
271 | dChildAngle = 0; |
||
272 | else if (sArrow == "RIGHT") |
||
273 | dChildAngle = 90 * Math.PI / 180; |
||
274 | else if (sArrow == "DOWN") |
||
275 | dChildAngle = Math.PI; |
||
276 | else |
||
277 | dChildAngle = 270 * Math.PI / 180; |
||
278 | |||
279 | LMSymbol _childLmSymbol = _placement.PIDPlaceSymbol(sMappingName, LOCATION_X, LOCATION_Y, Mirror: 0, Rotation: dChildAngle, TargetItem: SPPID_ITEM_OBJECT); |
||
280 | _childLmSymbol.Commit(); |
||
281 | 21be5063 | gaqhf | symoblChild.SPPID_ITEM_OBJECT = _childLmSymbol; |
282 | 8056c558 | gaqhf | } |
283 | catch (Exception) |
||
284 | { |
||
285 | 21be5063 | gaqhf | |
286 | 8056c558 | gaqhf | } |
287 | } |
||
288 | // End |
||
289 | } |
||
290 | } |
||
291 | catch (Exception) |
||
292 | { |
||
293 | |||
294 | } |
||
295 | cdf18b83 | gaqhf | } |
296 | |||
297 | public override void SetAttribute() |
||
298 | { |
||
299 | throw new NotImplementedException(); |
||
300 | } |
||
301 | } |
||
302 | |||
303 | public class Line : SPPID_ITEM |
||
304 | { |
||
305 | public enum SlopType |
||
306 | { |
||
307 | NONE = 0, |
||
308 | VERTICAL = 1, |
||
309 | HORIZONTAL = 2, |
||
310 | SLOPE = 3, |
||
311 | } |
||
312 | #region Property |
||
313 | private string _STARTPOINT; |
||
314 | private string _ENDPOINT; |
||
315 | 8056c558 | gaqhf | private List<Connector> _CONNECTORS = new List<Connector>(); |
316 | cdf18b83 | gaqhf | private string _LMCONNECTOR_MODELID; |
317 | private SlopType _SLOPTYPE; |
||
318 | private double _START_X; |
||
319 | private double _START_Y; |
||
320 | private double _END_X; |
||
321 | private double _END_Y; |
||
322 | |||
323 | public string STARTPOINT { get => _STARTPOINT; set => _STARTPOINT = value; } |
||
324 | public string ENDPOINT { get => _ENDPOINT; set => _ENDPOINT = value; } |
||
325 | public string LMCONNECTOR_MODELID { get => _LMCONNECTOR_MODELID; set => _LMCONNECTOR_MODELID = value; } |
||
326 | public double START_X { get => _START_X; set => _START_X = value; } |
||
327 | public double START_Y { get => _START_Y; set => _START_Y = value; } |
||
328 | public double END_X { get => _END_X; set => _END_X = value; } |
||
329 | public double END_Y { get => _END_Y; set => _END_Y = value; } |
||
330 | public List<Connector> CONNECTORS { get => _CONNECTORS; set => _CONNECTORS = value; } |
||
331 | public SlopType SLOPTYPE { get => _SLOPTYPE; set => _SLOPTYPE = value; } |
||
332 | #endregion |
||
333 | public override void AfterSetting() |
||
334 | { |
||
335 | 21be5063 | gaqhf | // SPPIDMAPPINGNAME Setting |
336 | SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME); |
||
337 | // End |
||
338 | |||
339 | 8056c558 | gaqhf | // Point Setting |
340 | SPPIDUtill.ConvertPointBystring(_STARTPOINT, ref _START_X, ref _START_Y); |
||
341 | SPPIDUtill.ConvertSPPIDPoint(ref _START_X, ref _START_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT); |
||
342 | SPPIDUtill.ConvertPointBystring(_ENDPOINT, ref _END_X, ref _END_Y); |
||
343 | SPPIDUtill.ConvertSPPIDPoint(ref _END_X,ref _END_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT); |
||
344 | // End |
||
345 | |||
346 | // Slop Setting |
||
347 | _SLOPTYPE = SPPIDUtill.CalcSlop(new Pointd(_START_X, _START_Y), new Pointd(_END_X, _END_Y)); |
||
348 | // End |
||
349 | |||
350 | // SPPID Type Setting |
||
351 | SPPID_TYPE = SPPID_ITEM_TYPE.LINE; |
||
352 | // End |
||
353 | 21be5063 | gaqhf | |
354 | // Input Drawing |
||
355 | AutoModeling.DrawingItem.LINES.Add(this); |
||
356 | // End |
||
357 | cdf18b83 | gaqhf | } |
358 | |||
359 | 8056c558 | gaqhf | public override void Modeling() |
360 | cdf18b83 | gaqhf | { |
361 | 8056c558 | gaqhf | throw new MissingMethodException(); |
362 | cdf18b83 | gaqhf | } |
363 | |||
364 | public override void SetAttribute() |
||
365 | { |
||
366 | throw new NotImplementedException(); |
||
367 | } |
||
368 | } |
||
369 | |||
370 | public class LineNumber : SPPID_ITEM |
||
371 | { |
||
372 | public enum LineNumberType |
||
373 | { |
||
374 | LineNumber = 1, |
||
375 | TrimLine = 2, |
||
376 | } |
||
377 | #region Property |
||
378 | 8056c558 | gaqhf | private double _ANGLE; |
379 | cdf18b83 | gaqhf | private string _LOCATION; |
380 | private double _LOCATION_X; |
||
381 | private double _LOCATION_Y; |
||
382 | private string _TEXT; |
||
383 | private string _CONNECTLINE; |
||
384 | private Line _TARGETLINE; |
||
385 | private LineNumberType _LINENUMBERTYPE; |
||
386 | |||
387 | 8056c558 | gaqhf | public double ANGLE { get => _ANGLE; set => _ANGLE = value; } |
388 | cdf18b83 | gaqhf | public string LOCATION { get => _LOCATION; set => _LOCATION = value; } |
389 | public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; } |
||
390 | public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; } |
||
391 | public string TEXT { get => _TEXT; set => _TEXT = value; } |
||
392 | public string CONNECTLINE { get => _CONNECTLINE; set => _CONNECTLINE = value; } |
||
393 | public Line TARGETLINE { get => _TARGETLINE; set => _TARGETLINE = value; } |
||
394 | public LineNumberType LINENUMBERTYPE { get => _LINENUMBERTYPE; set => _LINENUMBERTYPE = value; } |
||
395 | #endregion |
||
396 | |||
397 | public override void AfterSetting() |
||
398 | { |
||
399 | 21be5063 | gaqhf | // SPPIDMAPPINGNAME Setting |
400 | SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME); |
||
401 | // End |
||
402 | |||
403 | 8056c558 | gaqhf | // Angle Setting |
404 | if (ANGLE == 1.57) |
||
405 | ANGLE = 90 * Math.PI / 180; |
||
406 | else if (ANGLE == 3.14) |
||
407 | ANGLE = Math.PI; |
||
408 | else if (ANGLE == 4.71) |
||
409 | ANGLE = 270 * Math.PI / 180; |
||
410 | else |
||
411 | ANGLE = 0; |
||
412 | // End |
||
413 | |||
414 | // Location Setting |
||
415 | SPPIDUtill.ConvertPointBystring(_LOCATION, ref _LOCATION_X, ref _LOCATION_Y); |
||
416 | SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT); |
||
417 | // End |
||
418 | |||
419 | // SPPID Type Setting |
||
420 | SPPID_TYPE = SPPID_ITEM_TYPE.LABEL; |
||
421 | // End |
||
422 | 21be5063 | gaqhf | |
423 | // Input Drawing |
||
424 | AutoModeling.DrawingItem.LINENUMBERS.Add(this); |
||
425 | // End |
||
426 | cdf18b83 | gaqhf | } |
427 | |||
428 | 8056c558 | gaqhf | public override void Modeling() |
429 | cdf18b83 | gaqhf | { |
430 | 8056c558 | gaqhf | try |
431 | { |
||
432 | if (TARGETLINE != null && !string.IsNullOrEmpty(TARGETLINE.LMCONNECTOR_MODELID)) |
||
433 | { |
||
434 | Placement _placement = new Placement(); |
||
435 | Array points = new double[] { LOCATION_X, LOCATION_Y }; |
||
436 | LMPipeRun _pipeRun = _placement.PIDDataSource.GetPipeRun(TARGETLINE.LMCONNECTOR_MODELID); |
||
437 | if (_pipeRun != null) |
||
438 | { |
||
439 | foreach (LMRepresentation rep in _pipeRun.Representations) |
||
440 | { |
||
441 | if (rep.get_RepresentationType() == "Connector" && rep.get_ItemStatus() == "Active") |
||
442 | { |
||
443 | LMConnector _LmConnector = _placement.PIDDataSource.GetConnector(rep.Id); |
||
444 | LMLabelPersist _LmLabelPresist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref points, Rotation: ANGLE, LabeledItem: _LmConnector.AsLMRepresentation(), IsLeaderVisible: true); |
||
445 | _LmLabelPresist.Commit(); |
||
446 | SPPID_ITEM_OBJECT = _LmLabelPresist; |
||
447 | } |
||
448 | } |
||
449 | } |
||
450 | } |
||
451 | } |
||
452 | catch (Exception) |
||
453 | { |
||
454 | |||
455 | } |
||
456 | cdf18b83 | gaqhf | } |
457 | |||
458 | public override void SetAttribute() |
||
459 | { |
||
460 | throw new NotImplementedException(); |
||
461 | } |
||
462 | } |
||
463 | |||
464 | public class Text : SPPID_ITEM |
||
465 | { |
||
466 | #region Property |
||
467 | 8056c558 | gaqhf | private double _ANGLE; |
468 | cdf18b83 | gaqhf | private string _LOCATION; |
469 | 8056c558 | gaqhf | private double _LOCATION_X; |
470 | private double _LOCATION_Y; |
||
471 | cdf18b83 | gaqhf | private string _TEXT; |
472 | private string _OWNER; |
||
473 | |||
474 | 8056c558 | gaqhf | public double ANGLE { get => _ANGLE; set => _ANGLE = value; } |
475 | cdf18b83 | gaqhf | public string LOCATION { get => _LOCATION; set => _LOCATION = value; } |
476 | 8056c558 | gaqhf | public double LOCATION_X { get => _LOCATION_X; set => _LOCATION_X = value; } |
477 | public double LOCATION_Y { get => _LOCATION_Y; set => _LOCATION_Y = value; } |
||
478 | cdf18b83 | gaqhf | public string TEXT { get => _TEXT; set => _TEXT = value; } |
479 | public string OWNER { get => _OWNER; set => _OWNER = value; } |
||
480 | #endregion |
||
481 | public override void AfterSetting() |
||
482 | { |
||
483 | 21be5063 | gaqhf | // SPPIDMAPPINGNAME Setting |
484 | SPPIDMAPPINGNAME = SPPIDUtill.GetSPPIDMappingName(NAME); |
||
485 | // End |
||
486 | |||
487 | 8056c558 | gaqhf | // Angle Setting |
488 | if (ANGLE == 1.57) |
||
489 | ANGLE = 90 * Math.PI / 180; |
||
490 | else if (ANGLE == 3.14) |
||
491 | ANGLE = Math.PI; |
||
492 | else if (ANGLE == 4.71) |
||
493 | ANGLE = 270 * Math.PI / 180; |
||
494 | else |
||
495 | ANGLE = 0; |
||
496 | // End |
||
497 | |||
498 | // Location Setting |
||
499 | SPPIDUtill.ConvertPointBystring(_LOCATION, ref _LOCATION_X, ref _LOCATION_Y); |
||
500 | SPPIDUtill.ConvertSPPIDPoint(ref _LOCATION_X, ref _LOCATION_Y, AutoModeling.DrawingItem.WIDTH, AutoModeling.DrawingItem.HEIGHT); |
||
501 | // End |
||
502 | |||
503 | // SPPID Type Setting |
||
504 | SPPID_TYPE = SPPID_ITEM_TYPE.TEXT; |
||
505 | // End |
||
506 | 21be5063 | gaqhf | |
507 | // Input Drawing |
||
508 | AutoModeling.DrawingItem.TEXTS.Add(this); |
||
509 | // End |
||
510 | cdf18b83 | gaqhf | } |
511 | |||
512 | 8056c558 | gaqhf | public override void Modeling() |
513 | cdf18b83 | gaqhf | { |
514 | 8056c558 | gaqhf | try |
515 | { |
||
516 | Placement _placement = new Placement(); |
||
517 | 21be5063 | gaqhf | if (NAME == "TEXT" || NAME == "NOTE") |
518 | 8056c558 | gaqhf | { |
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()) |
||
532 | { |
||
533 | Symbol _symbol = _obj as Symbol; |
||
534 | LMSymbol _LmSymbol = _symbol.SPPID_ITEM_OBJECT as LMSymbol; |
||
535 | |||
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"; |
||
541 | |||
542 | LMLabelPersist _LmLabelPersist = _placement.PIDPlaceLabel(SPPIDMAPPINGNAME, ref array, Rotation: ANGLE, LabeledItem: _LmSymbol.AsLMRepresentation(), IsLeaderVisible: true); |
||
543 | _LmLabelPersist.Commit(); |
||
544 | |||
545 | SPPID_ITEM_OBJECT = _LmLabelPersist; |
||
546 | } |
||
547 | } |
||
548 | } |
||
549 | catch (Exception) |
||
550 | { |
||
551 | |||
552 | } |
||
553 | cdf18b83 | gaqhf | } |
554 | |||
555 | public override void SetAttribute() |
||
556 | { |
||
557 | throw new NotImplementedException(); |
||
558 | } |
||
559 | } |
||
560 | |||
561 | |||
562 | public class Attribute |
||
563 | { |
||
564 | #region Property |
||
565 | private string _UID; |
||
566 | private string _NAME; |
||
567 | private string _VALUE; |
||
568 | |||
569 | public string UID { get => _UID; set => _UID = value; } |
||
570 | public string NAME { get => _NAME; set => _NAME = value; } |
||
571 | public string VALUE { get => _VALUE; set => _VALUE = value; } |
||
572 | #endregion |
||
573 | } |
||
574 | |||
575 | public class Connector |
||
576 | { |
||
577 | #region Property |
||
578 | private string _CONNECTEDITEM; |
||
579 | private string _CONNECTPOINT; |
||
580 | private string _SCENECONNECTPOINT; |
||
581 | 21be5063 | gaqhf | private string _INDEX; |
582 | cdf18b83 | gaqhf | |
583 | public string CONNECTEDITEM { get => _CONNECTEDITEM; set => _CONNECTEDITEM = value; } |
||
584 | public string CONNECTPOINT { get => _CONNECTPOINT; set => _CONNECTPOINT = value; } |
||
585 | public string SCENECONNECTPOINT { get => _SCENECONNECTPOINT; set => _SCENECONNECTPOINT = value; } |
||
586 | 21be5063 | gaqhf | public string INDEX { get => _INDEX; set => _INDEX = value; } |
587 | cdf18b83 | gaqhf | #endregion |
588 | } |
||
589 | } |