Set PhotoWorks Light Schemes Example (VBA)
This example shows how to change the PhotoWorks light scenes in a model.
'---------------------------------------------
' Preconditions: The PhotoWorks add-in is loaded, and
the specified
' SolidWorks
part file exists.
'
' Postconditions: Different lights scenes are set, and
the updated
' images
rendered to your screen.
'
'---------------------------------------------
Option Explicit
Sub main()
Dim
swApp As
SldWorks.SldWorks
Dim
pwAddIn As
PhotoWorks.PhotoWorks
Dim
pwOpt As
PhotoWorks.PwOptions
Dim
bRetVal As
Boolean
Dim
swModel As
SldWorks.ModelDoc2
Dim
lErrors As
Long
Dim
lWarnings As
Long
'
Get the SolidWorks application
Set
swApp = Application.SldWorks
'
Get the PhotoWorks add-in
Set
pwAddIn = swApp.GetAddInObject("PhotoWorks.PhotoWorks")
'
Get the PhotoWorks Options
Set
pwOpt = pwAddIn.PwOptions()
'
Open a SolidWorks part file
'
NOTE: Instead of specifying king.sldprt, substitute
'
the name of the SolidWorks part file that
'
you want to open
Set
swModel = swApp.OpenDoc6("king.sldprt", swDocPART, swOpenDocOptions_Silent,
"", lErrors, lWarnings)
'
Clear the screen before rendering
pwOpt.ClearImageBeforeRendering = True
'
Render the image to your screen
bRetVal
= pwAddIn.RenderToScreen
'
Set a different light scheme
'
NOTE: The path specified is the
default SolidWorks and PhotoWorks
'
installation path; substitute your path if
'
it is not the same as the default
bRetVal
= pwAddIn.SetLightScheme("C:\Program
Files\SolidWorks\photoworks\data\Lights\Multiple\Cyan and Yellow Directional.p2l")
'
Render the image to your screen again
bRetVal
= pwAddIn.RenderToScreen
'
Set a different light scheme
'
NOTE: The path specified is the
default SolidWorks and PhotoWorks
'
installation path; substitute your path if
'
it is not the same as the default
bRetVal
= pwAddIn.SetLightScheme("C:\Program
Files\SolidWorks\photoworks\data\Lights\Multiple\White and Yellow Directional.p2l")
'
Render the image to your screen again
bRetVal
= pwAddIn.RenderToScreen
End Sub