4 Replies Latest reply on Aug 26, 2016 9:45 AM by Sanya Shmidt

# Equations Update Fail.

Hello guys!

Looking for some help here. I`m having problems updating the Equations values via API. Below is what i have written:

PushValue("FRAMEWIDTH",3)

Private Function PushValue(ByVal var As String, ByVal ind As Integer) As Boolean

Dim Values() As String

Try

Dim swEqnMgr = swPart.GetEquationMgr : Values = ImportData.GetValues(var)

swEqnMgr.Equation(ind) = "" & var & "=" & Values(0) ' What would be the proper way of re-writing it? so It pushes "FRAMEWIDTH" vs FRAMEWIDTH

Catch ex As Exception

Return False

End Try

Return True

End Function

So what it does it`s replaces the Equation FRAMEWIDTH without brackets. So if you look in the equations folder all Variables have "brackets".

That causes Solidworks to spit out the message

And then it just deletes it from equations folder. So all of the formulas I have - based on this Variable are screwed.

Thank you.

Any help appreciated.

• ###### Re: Equations Update Fail.

'i believe chr(34) = "

swEqnMgr.Equation(ind) = "" & var & "=" + chr(34) + Values(0) + chr(34)

that should work if you looking for the missing "

• ###### Re: Equations Update Fail.

Elmar,

No, this one doesnt work. Same end result.

Thank you

• ###### Re: Equations Update Fail.

swEqnMgr.Equation(ind) = """" & var & """=" & Values(0)

• ###### Re: Equations Update Fail.

This one worked good! Thank you.

I also found another solution from Keith:

Dim vSplit As Object

vSplit = Split(swEqnMgr.Equation(ind), "=")

vSplit(0) = Replace(vSplit(0), Chr(34), "")

If vSplit(0) = var Then _

swEqnMgr.Equation(ind) = Replace(swEqnMgr.Equation(ind), vSplit(1), Values(0))

but I like this one better cause its just one line :

swEqnMgr.Equation(ind) = """" & var & """=" & Values(0)

Thank you.