MaterialPropertyValues changes not being saved with part?

I have a program that sets the part color to some random color, but it doesn't save with the part unless you modify the part in some other way after the color change. I set the save flag but it doesn't seem to make a difference.

thanks for the help

jim

m_Doc is of type (IModelDoc2)

read material properties

change to random color

set material properties

set save flag

redraw

   public override void RadomizeColor()

        {

            double[]d  = (double[])m_Doc.Extension.GetMaterialPropertyValues((int)swInConfigurationOpts_e.swAllConfiguration,null);

            Random rand = new Random();

            d[0] = rand.NextDouble();

            d[1] = rand.NextDouble();

            d[2] = rand.NextDouble();

            m_Doc.Extension.SetMaterialPropertyValues(d, (int)swInConfigurationOpts_e.swAllConfiguration, null);

            m_Doc.SetSaveFlag();

            m_Doc.WindowRedraw();

        }

SolidworksApi macros