AnsweredAssumed Answered

modelExtension.SetUserPreferenceInteger(259, 0, 3); is failing - why?

Question asked by Eric Snyder on Feb 24, 2020

Using SolidWorks 2020 SP01.

I am trying to change the mass unit setting to grams. Using the following code:


bool success = modelExtension.SetUserPreferenceInteger((int)swUserPreferenceIntegerValue_e.swUnitsMassPropMass, (int)swUserPreferenceOption_e.swDetailingNoOptionSpecified, (int)swUnitsMassPropMass_e.swUnitsMassPropMass_Grams);

The units do not change from Pounds to grams. The function returns failed.


I tried this as well:

modelExtension.SetUserPreferenceInteger(259, 0, 3);

That fails as well.


I tried the depreciated method on the IModelDoc2 interface and it fails as well:

bool successA = model.SetUserPreferenceIntegerValue(259, 3);

I HAVE changed a double value setting in this same document so I know that the document can allow changes to settings.


Anybody have any ideas on what to try?



I am able to set double and toggle with their respective set functions. I am unable to set string and integer types.