AnsweredAssumed Answered

Part turns totally black when changing color

Question asked by Gabriel Penalba on Jun 25, 2015
Latest reply on Jun 14, 2017 by Scott Stuart

Hey all, I'm making a quick macro to change the color of the assembly that I have selected in the tree. I thought it would be really simple, but it's malfunctioning for some reason. First off, I'd like to change the color of the assembly I have selected, not just it's appearance in the assembly in which it's selected. Second, the color does change, but it goes totally black!! If I remove the appearance, it goes back to the default color. Any ideas?


Dim swApp As SldWorks.SldWorks

Dim Part As Object

Dim swModel As SldWorks.ModelDoc2

Dim swSelMgr As SldWorks.SelectionMgr

Dim swSelComp As SldWorks.Component2

Dim dMatProps As Variant

Dim vNames As Variant


Sub main()


Set swApp = Application.SldWorks

Set swModelDoc = swApp.ActiveDoc

Set swSelMgr = swModelDoc.SelectionManager


Set swSelComp = swSelMgr.GetSelectedObjectsComponent4(1, -1)


dMatProps = swSelComp.GetMaterialPropertyValues2(1, vNames)


'set the properties array to the desires color

dMatProps(0) = 0

dMatProps(1) = 255 / 256

dMatProps(2) = 255 / 256


'set the component properties to the changed array properties

swSelComp.SetMaterialPropertyValues2 dMatProps, 1, vNames


End Sub