@mgeurts
Maybe it doesn't get the StyleSourceTypeEnum correct with just kOverrideRenderStyle...
Could try changing it to this:
Dim oDoc As PartDocument = ThisDoc.Document
Dim oRenderStyles As RenderStyles = oDoc.RenderStyles
Dim oName As String = "Red_Color"
Dim styleExists As Boolean = False
Dim myStyle As RenderStyle
For Each oRenderStyle As RenderStyle In oRenderStyles
If oRenderStyle.Name = oName
styleExists = True
myStyle = oRenderStyle
Exit For
End If
Next
If Not styleExists
myStyle = oRenderStyles.Add(oName)
myStyle.SetAmbientColor(255, 0, 0)
myStyle.SetDiffuseColor(255, 0, 0)
End If
For Each oSurfBod As SurfaceBody In oDoc.ComponentDefinition.SurfaceBodies
For Each oFace As Face In oSurfBod.Faces
oFace.SetRenderStyle(StyleSourceTypeEnum.kOverrideRenderStyle, myStyle)
Next
Next
Or this:
Dim oDoc As PartDocument = ThisDoc.Document
Dim oRenderStyles As RenderStyles = oDoc.RenderStyles
Dim oName As String = "Red_Color"
Dim styleExists As Boolean = False
Dim myStyle As RenderStyle
For Each oRenderStyle As RenderStyle In oRenderStyles
If oRenderStyle.Name = oName
styleExists = True
myStyle = oRenderStyle
Exit For
End If
Next
If Not styleExists
myStyle = oRenderStyles.Add(oName)
myStyle.SetAmbientColor(255, 0, 0)
myStyle.SetDiffuseColor(255, 0, 0)
End If
For Each oSurfBod As SurfaceBody In oDoc.ComponentDefinition.SurfaceBodies
For Each oFace As Face In oSurfBod.Faces
oFace.SetRenderStyle(37123, myStyle)
Next
Next
It works for me in 2020 either way - See screencast. I can't test in 2016 though...