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?
Hi,
Make sure that you are using the correct decimal point. Try to set your param["Width"] to integer (e.g. 5) and see how it goes. What is the value inside param["Width"] and what is the type of the value?
Thanks,
Artem