Files
Code
Module: mMain
'Increases ambient light for better viewing of SolidWorks models on a projector.
'Preconditions: Assembly or part is open.
'Written by Keith Rice
'CADSharp LLC
'www.cadsharp.com
Sub main()
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim vConfigNames As Variant
Dim strOrigConfigName As String
Dim i As Integer
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
If swModel Is Nothing Then Exit Sub
strOrigConfigName = swModel.ConfigurationManager.ActiveConfiguration.Name
vConfigNames = swModel.GetConfigurationNames
For i = 0 To UBound(vConfigNames)
swModel.ShowConfiguration2 vConfigNames(i)
ChangeLightSourceProps swModel
Next i
swModel.ShowConfiguration2 strOrigConfigName
End Sub
Private Sub ChangeLightSourceProps(swModel As SldWorks.ModelDoc2)
Dim i As Integer
Dim dblAmbientVal As Double
For i = 0 To swModel.GetLightSourceCount - 1
If InStr(swModel.GetLightSourceName(i), "Ambient") > 0 Then
dblAmbientVal = swModel.LightSourcePropertyValues(i)(15)
If dblAmbientVal < 0.3 Then boolstatus = swModel.SetLightSourcePropertyValuesVB(swModel.GetLightSourceName(i), 1, 1, 16777215, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.75, 0, 0, False)
If dblAmbientVal > 0.29 Then boolstatus = swModel.SetLightSourcePropertyValuesVB(swModel.GetLightSourceName(i), 1, 1, 16777215, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0.29, 0, 0, False)
End If
Next i
End Sub