i looked in the API help and it seems like a loop thru all the equations needed to get a certain equation

is there a function call to get an equation without runn thru a loop

i looked in the API help and it seems like a loop thru all the equations needed to get a certain equation

is there a function call to get an equation without runn thru a loop

Chris, you should be able to get both name and values. This line

**swEquationMgr.Equation(0)**should give you both name and values.Deepak,

i know that. My question is i need strip the name out of the string of equation while I can get the value directly

2018 SOLIDWORKS API Help - ConvertToSystemValue Method (IUserUnit)

is this what you are looking for?

sorry Chris Champions, you are not making much sense.

please explain what you are trying to do.

if you don't want to loop through the equations, then write a function that does it for you, then call that function whenever you need it.

like

Public Function GetEquationIndex(Byval SomeArgument as string) as integerLoop here to find your equation

end function

Jacob,

Sorry, it's not clear to you while Deepak answered most of my questions

say I have a global variable

"Length" = 2.50 from equationManager.equation(index)

1) equationMangaer.Value (Index) returns value of 2.50. Is there a function call which can return the name "Length"? What I do is to use split and replace functions to strip the name "Length" from "Length" = 2.50

2) If I know the Variable name is "Legnth", is there a function call I can directly retrieve its value of 2.50 instead of going thru a loop and searching for it

1) Use the Left Method for removing the value.

Dim eqName As String

eqName = Left(equationManager.Equation(index), Len(equationManager.Equation(index)) - Len(equationMangaer.Value (Index)))

You might need to add - 3 after the last Length to remove the spaces and equal sign, but I don't know exactly what each one outputs.

2) No, there is no function that I have found to do this

Thank you for confirming it, Matt

a SW API function call for this option would be helpful

too bad it’s not available

Yes, it very annoying. The equation manager i very frustrating to work with in general.

We use regular expressions to extract values and names

string eq = eqman[0] string pattern = @"""([^@]+)""\s*=\s*(.+$)"; Regex regex = new Regex(pattern, RegexOptions.Compiled); MatchCollection m = regex.Matches(eq); if (m.Count == 0 || m[0].Groups.Count < 3) { return false; } name = m[0].Groups[1].Value; eqval = m[0].Groups[2].Value;

You can end your loop once you got the desired equation OR if you know the equation index(position), then try following. 0 indicates the equation on number 1 from top.