-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm_SelectVariable.vb
More file actions
166 lines (108 loc) · 4.87 KB
/
Form_SelectVariable.vb
File metadata and controls
166 lines (108 loc) · 4.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
Imports SolidEdgeConstants
Public Class Form_SelectVariable
Public ObjDoc As SolidEdgeFramework.SolidEdgeDocument
Public Valid As Boolean = False
Public LengthUnits As SolidEdgeConstants.UnitOfMeasureLengthReadoutConstants
Private Sub Form_SelectVariable_Load(sender As Object, e As EventArgs) Handles Me.Load
RefreshList()
End Sub
Private Sub RefreshList()
ListBox_Variables.Items.Clear()
Dim _FindVars = FindVars()
If Not IsNothing(_FindVars) Then
ListBox_Variables.DisplayMember = "Name"
Dim UU As New UtilsUnits(ObjDoc)
For Each item In _FindVars
Dim UnitString = UU.GetUnitReadout(item)
Dim tmpVar As New VarListItem(item, LengthUnits, ObjDoc)
'tmpVar.LengthUnits = LengthUnits '<---- This has to be set before the VarListItem is created
ListBox_Variables.Items.Add(tmpVar)
Next
End If
End Sub
Private Function FindVars() As Object
Dim NameBy As Object = Nothing
If CB_Users.Checked And CB_System.Checked Then NameBy = 2
If Not CB_Users.Checked And CB_System.Checked Then NameBy = 1
If CB_Users.Checked And Not CB_System.Checked Then NameBy = 0
If Not CB_Users.Checked And Not CB_System.Checked Then Return Nothing
Dim _VarType As Object = Nothing
If CB_Variables.Checked And CB_Dimensions.Checked Then _VarType = 3
If CB_Variables.Checked And Not CB_Dimensions.Checked Then _VarType = 2
If Not CB_Variables.Checked And CB_Dimensions.Checked Then _VarType = 1
If Not CB_Variables.Checked And Not CB_Dimensions.Checked Then Return Nothing
If Not IsNothing(ObjDoc) Then
Dim objVars As SolidEdgeFramework.Variables = ObjDoc.Variables
Dim _FindVars = objVars.Query("*", NameBy, _VarType)
Return _FindVars
End If
Return Nothing
End Function
Private Sub BT_OK_Click(sender As Object, e As EventArgs) Handles BT_OK.Click
If ListBox_Variables.SelectedItems.Count > 0 Then
Valid = True
Else
Valid = False
End If
Me.Close()
End Sub
Private Sub BT_Cancel_Click(sender As Object, e As EventArgs) Handles BT_Cancel.Click
Valid = False
Me.Close()
End Sub
Private Sub CB_CheckedChanged(sender As Object, e As EventArgs) Handles CB_Users.CheckedChanged, CB_System.CheckedChanged, CB_Variables.CheckedChanged, CB_Dimensions.CheckedChanged
refreshList()
End Sub
End Class
Public Class VarListItem
Public Property Name As String
Public Property VarName As String
Public Property Value As String
Public Property Formula As String
Public Property ObjVariable As Object 'SolidEdgeFramework.variable
'Public Property objDimension As SolidEdgeFrameworkSupport.Dimension
Public Property ExName As String
Public Property LengthUnits As SolidEdgeConstants.UnitOfMeasureLengthReadoutConstants
Public Property NewWay As Boolean = True
Public Property ObjDoc As SolidEdgeFramework.SolidEdgeDocument
Public Sub New(
objVar As Object,
_LengthUnits As SolidEdgeConstants.UnitOfMeasureLengthReadoutConstants,
_ObjDoc As SolidEdgeFramework.SolidEdgeDocument) 'SolidEdgeFramework.variable)
'If TypeOf (objVar) Is SolidEdgeFramework.variable Then
ObjVariable = objVar
'Else
' objDimension = objVar
'End If
LengthUnits = _LengthUnits
ObjDoc = _ObjDoc
VarName = objVar.Name
Formula = objVar.Formula
ExName = objVar.ExposeName
If ExName <> "" Then ExName = " -->(" & ExName & ")"
Dim UnitType = objVar.UnitsType
Dim UU As New UtilsUnits(ObjDoc)
If NewWay Then
Dim tmpValue As Double = UU.GetVarValue(objVar)
Value = CStr(tmpValue)
Dim UnitReadout As String = UU.GetUnitReadout(objVar)
If Not UnitReadout = "" Then Value = String.Format("{0} {1}", Value, UnitReadout)
Else
Value = UC_Slider.CadToValue(objVar.Value, UnitType, LengthUnits).ToString
If UnitType = SolidEdgeFramework.UnitTypeConstants.igUnitDistance Then
If LengthUnits = UnitOfMeasureLengthReadoutConstants.seLengthInch Then
Value = Value & " in"
ElseIf LengthUnits = UnitOfMeasureLengthReadoutConstants.seLengthMillimeter Then
Value = Value & " mm"
End If
ElseIf UnitType = SolidEdgeFramework.UnitTypeConstants.igUnitAngle Then
Value = Value & " °"
End If
End If
If Formula = "" Then
Name = objVar.Name & ExName & " = " & Value
Else
Name = objVar.Name & ExName & " = " & objVar.Formula
End If
End Sub
End Class