6 Replies Latest reply on Jul 23, 2015 12:02 PM by Patrick Jensen

    Custom properties do not update when units are changed using macro

    Patrick Jensen

      I wrote a macro in Solidworks 2012 that begins with an assembly and adds a custom property to each one of its components. However, every component has custom units that are not the same across all components, therefore the custom properties are not in the same units either. In my loop that cycles through the components,  I added the following line to my code,

       

      Bool = swCompModel.Extension.SetUserPreferenceInteger(swUserPreferenceIntegerValue_e.swUnitSystem, 0, swUnitSystem_MKS)

       

      in order to change all components to MKS units. swCompModel was gotten by using the component and .GetModelDoc2. Heres the dilema, when I open a particular component, the custom property evaluated value did not update. The line above is placed before the custom property is added, therefore that is not the issue.

       

      What I have noticed:

      - In the bottom right corner, the units do not change from "Custom" to "MKS" until the program has finished running

      - (After the program has ran and bottom right corner says "MKS") When I use the drop down list in the bottom right corner, I can select any other units and the  custom properties will      update. However, if I switch back to "MKS", the custom properties have still not updated to MKS.
      - Even when I go into Options >Document Properties > Units , it says the units are MKS (after program has ran). If I press "cancel" or "X" out of the options, the units do not update in     custom properties. However, if I press okay (only when on the units page), then the custom properties finally update to MKS.

      - Rebuilding and/or Reloading the document does not work either.

       

      I need these properties to be the correct units when I add them in the macro because they are used in the next line.

       

      Any help is appreciated,

       

      Patrick