Hello again everyone,
sorry to publish without testing, so I'm following up
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Sub Management()
assignmentPrincipalObjects
Bottom Height Management
If Test("D1@Esq1", "500") Then
boolstatus = swModel.EditRebuild3()
Else
MsgBox "Problem"
End If
'Width...
'Depth...
'Thickness...
End Sub
Sub AssignmentPrincipalObjects() 'Can be placed in another module without PB
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
'Set= .....
End Sub
Function Test(NomVar As String, ValVar As String) As Boolean 'Can be placed in another module without PB
Dim swEquationMgr As SldWorks.EquationMgr
Dim vSplit as Variant
Set swEquationMgr = swModel.GetEquationMgr
Test = False
For i = 0 To swEquationMgr.GetCount - 1
vSplit = Split(swEquationMgr.equation(i), "=")
vSplit(0) = Replace(vSplit(0), Chr(34), Empty)
vSplit(0) = Replace(vSplit(0), Chr(32), Empty)
If vSplit(0) = VarName, Then
swEquationMgr.equation(i) = Replace(swEquationMgr.equation(i), vSplit(1), ValVar)
Test = True
Exit Function
End If
Next i
End Function
I just tested and quickly reworked this code, it's up to you JB to 'put it in your own way'.
Using functions (here Test) with passing arguments (here NomVar and ValVar) allows you to organize your things in several modules. Regarding the sub entitled Management, I can see it in a module of your UserForm, to be seen.
Regards MC