In diesem Video zeige ich wie man Gleichungen in Teilen per Makro anspricht.
Und an dieser Stelle der Code der im Makro vorhanden ist.
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As ModelDoc2
Dim swEqnMgr As EquationMgr
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swEqnMgr = swModel.GetEquationMgr
Debug.Print "Anzahl: " & swEqnMgr.GetCount
Dim i As Long
For i = 0 To swEqnMgr.GetCount - 1
Debug.Print "Gleichung (" & i & ") = " & swEqnMgr.Equation(i)
Debug.Print "Wert = " & swEqnMgr.value(i)
Debug.Print "Index = " & swEqnMgr.Status
Debug.Print "Globale Variable? " & swEqnMgr.GlobalVariable(i)
Next i
' changeGlobalEqn 2, 65
addEqn "Tiefe", 50, -1
End Sub
Sub changeGlobalEqn(index As Long, value As Double)
Dim eqnString As String
Dim splitString As Variant
If swEqnMgr.GlobalVariable(index) Then
eqnString = swEqnMgr.Equation(index)
Debug.Print "eqnString: " & eqnString
splitString = Split(eqnString, "=")
splitString(1) = value
eqnString = splitString(0) & "=" & splitString(1)
Debug.Print "Neuer eqnString: " & eqnString
swEqnMgr.Equation(index) = eqnString
Debug.Print swEqnMgr.Status
End If
End Sub
Sub addEqn(name As String, value As Double, index As Long)
Dim retVal As Long
retVal = swEqnMgr.Add2(index, Chr(34) & name & Chr(34) & "=" & value, True)
Debug.Print retVal
End Sub