There is an example in the API help about how to use IDimensionTolerance.SetValues2:
[...]
status = swDimensionTolerance.SetValues2(0.01, 0.015, (int)swSetValueInConfiguration_e.swSetValue_InThisConfiguration, "")
[...]
However, I followed this example and it does not work - it always returns "false".
I attached a part document for which the following C# code is written, so you can try yourself.
IModelDoc2 activeDoc = swApp.ActiveDoc; // swApp is the ISldWorks object
string[] dimNames = new string[] { "width@Rectangle", "length@Rectangle", "D1@Extrude" };
foreach (string dimName in dimNames)
{
IDimension dim = activeDoc.Parameter(dimName);
IDimensionTolerance tol = dim.Tolerance;
int tolType = tol.Type;
double min = tol.GetMinValue();
double max = tol.GetMaxValue();
Debug.WriteLine("dimension \"" + dimName + "\" has tolerance type " + tolType + ", min = " + min + ", max = " + max);
bool success = tol.SetValues2(-0.2, 0.3, (int)swSetValueInConfiguration_e.swSetValue_InThisConfiguration, "");
Debug.WriteLine("successfully changed tolerance values? -> " + success);
}
Any ideas on how to make it work?