hytos / DTI_PID / SPPIDAutoModeling / SPPIDUtill.cs @ 21be5063
이력 | 보기 | 이력해설 | 다운로드 (2.59 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 | |||
7 | namespace SPPIDAutoModeling |
||
8 | { |
||
9 | 8056c558 | gaqhf | public static class SPPIDUtill |
10 | cdf18b83 | gaqhf | { |
11 | private static readonly double _DWG_X = 0.875; |
||
12 | private static readonly double _DWG_Y = 0.617; |
||
13 | |||
14 | public static void ConvertSPPIDPoint(ref double dX, ref double dY, double dDwgX, double dDwgY) |
||
15 | { |
||
16 | double calcX = 0; |
||
17 | double calcY = 0; |
||
18 | 8056c558 | gaqhf | calcX = (dX * _DWG_X) / dDwgX; |
19 | cdf18b83 | gaqhf | calcX = Math.Truncate(calcX * 1000) / 1000; |
20 | calcY = _DWG_Y - ((dY * _DWG_Y) / dDwgY); |
||
21 | calcY = Math.Truncate(calcY * 1000) / 1000; |
||
22 | dX = calcX; |
||
23 | dY = calcY; |
||
24 | } |
||
25 | 8056c558 | gaqhf | |
26 | public static bool ConvertPointBystring(string sPoint, ref double dX, ref double dY) |
||
27 | { |
||
28 | try |
||
29 | { |
||
30 | string[] pointArr = sPoint.Split(new char[] { ',' }); |
||
31 | if (pointArr.Length == 2) |
||
32 | { |
||
33 | dX = Convert.ToDouble(pointArr[0]); |
||
34 | dY = Convert.ToDouble(pointArr[1]); |
||
35 | } |
||
36 | } |
||
37 | catch (Exception) |
||
38 | { |
||
39 | dX = 0; |
||
40 | dY = 0; |
||
41 | return false; |
||
42 | } |
||
43 | |||
44 | return true; |
||
45 | } |
||
46 | |||
47 | public static Line.SlopType CalcSlop(Pointd point1, Pointd point2) |
||
48 | { |
||
49 | Line.SlopType _type = Line.SlopType.NONE; |
||
50 | |||
51 | if (point1.X - point2.X == 0) |
||
52 | _type = Line.SlopType.VERTICAL; |
||
53 | else |
||
54 | { |
||
55 | double angle = Math.Atan(Math.Abs(point2.Y - point1.Y) / Math.Abs(point2.X - point1.X)) * 180 / Math.PI; |
||
56 | if (angle < 20) |
||
57 | _type = Line.SlopType.HORIZONTAL; |
||
58 | else if (angle > 70) |
||
59 | _type = Line.SlopType.VERTICAL; |
||
60 | else |
||
61 | _type = Line.SlopType.SLOPE; |
||
62 | } |
||
63 | |||
64 | return _type; |
||
65 | } |
||
66 | |||
67 | public static object FindObjectByUID(string UID) |
||
68 | { |
||
69 | foreach (Symbol item in AutoModeling.DrawingItem.SYMBOLS) |
||
70 | { |
||
71 | if (item.UID == UID) |
||
72 | return item; |
||
73 | } |
||
74 | |||
75 | foreach (Line item in AutoModeling.DrawingItem.LINES) |
||
76 | { |
||
77 | if (item.UID == UID) |
||
78 | return item; |
||
79 | } |
||
80 | |||
81 | return null; |
||
82 | } |
||
83 | 21be5063 | gaqhf | |
84 | public static string GetSPPIDMappingName(string name) |
||
85 | { |
||
86 | string SPPIDName = @"\Piping\Valves\2 Way Common\Ball Valve.sym"; |
||
87 | |||
88 | |||
89 | return SPPIDName; |
||
90 | } |
||
91 | cdf18b83 | gaqhf | } |
92 | } |