1 Reply Latest reply on Apr 24, 2017 5:22 PM by Christian Chu

    How to use macro to change the appearance of a part?

    Marco Wu

      I tried to record a macro for changing the part appearance. However, the code does not show anything regarding the change. Does anyone have any example (e.g. change RGB and change the transparent)

      Thank

        • Re: How to use macro to change the appearance of a part?
          Christian Chu

          Sure, see the code - just set the number of RGB

           

          Set swApp = Application.SldWorks

              Set swModelDoc = swApp.ActiveDoc

              Set swPart = swModelDoc

            

              vMatProps = swPart.MaterialPropertyValues  

              'Define the RGB values (1 = RGB value 255)

              vMatProps(0) = 154 / 255 'R

              vMatProps(1) = 155 / 255 'G

              vMatProps(2) = 156 / 255 'B

            

              swPart.MaterialPropertyValues = vMatProps

              swModelDoc.GraphicsRedraw2

              swModelDoc.Save3 swSaveAsOptions_Silent, nErrors, nWarnings