AnsweredAssumed Answered

Modify A Global Variable Value (C#)

Question asked by Jason Taylor on Feb 7, 2016
Latest reply on Feb 7, 2016 by Jason Taylor

I am trying to modify global variables within my C# code.


Based on these two examples:
Re: Macro change global variable

2015 SOLIDWORKS API Help - Add and Modify Equations Example (C#)


I have come up with the following code, but it doesn't change the global variables. Also, when I go into the equation manager after the code runs it has red Xs by the equations and says "The syntax of this equation is incorrect".


     string Depth = "\"Depth\" = " + param["Part"].Substring(0, param["Part"].IndexOf("x"));

     string flangeWidth = "\"FlangeWidth\" = " + param["Width"];


     swEquationMgr = swModel.GetEquationMgr();

     swEquationMgr.SetEquationAndConfigurationOption(0, Depth, (int)swInConfigurationOpts_e.swAllConfiguration, null);

     swEquationMgr.SetEquationAndConfigurationOption(0, flangeWidth, (int)swInConfigurationOpts_e.swAllConfiguration, null);


NOTE: The Depth variable correctly evaluates to ("Depth" = 8) & flangeWidth evaluates to ("FlangeWidth" = 3.5).


Can anyone help me with what I am doing wrong?