Hide Table of Contents

Get PhotoWorks Options Example (VBA)

This example shows how to get the values for most of the PhotoWorks options in the SolidWorks document and prints the values to the Visual Basic Immediate window.

 

'---------------------------------------------

'

' Preconditions: The PhotoWorks add-in is loaded, and a SolidWorks

'                a document is open.

'

' Postconditions: All of the options available on the

'                PhotoWorks, Options dialog are printed

'                to the Visual Basic Immediate window.

'

'---------------------------------------------

Option Explicit

 

Sub main()

 

    Dim swApp                   As SldWorks.SldWorks

    Dim pwAddIn                 As PhotoWorks.PhotoWorks

    Dim pwOpt                   As PhotoWorks.PwOptions

    Dim vCustomFolders          As Variant

    Dim vSearchFileList         As Variant

    Dim lPathItr                As Long

    Dim strActiveCustomFolder   As String

    Dim strCustomFolder         As String

    

    ' 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()

    

    Debug.Print "PhotoWorks options"

    Debug.Print "++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"

    

    Debug.Print " "

    

    '

    ' Print options on PhotoWorks, Options, System Options tab

    '

    

    Debug.Print "System Options:"

    Debug.Print "  Display preview window = " & CStr(pwOpt.DisplayPreviewWindow)

    Debug.Print "  Clear image before rendering = " & CStr(pwOpt.ClearImageBeforeRendering)

    Debug.Print "  Display progress/abort dialog = " & CStr(pwOpt.DisplayProgressAbortDialog)

    Debug.Print "  Overwrite SolidWorks properties = " & CStr(pwOpt.OverwriteSolidWorksProperties)

    Debug.Print "  Use SolidWorks materials = " & CStr(pwOpt.UseSolidWorksMaterials)

    Debug.Print "  Use SolidWorks physical materials = " & CStr(pwOpt.UseSolidWorksPhysicalProperties)

    Debug.Print "  Enable dynamic help = " & CStr(pwOpt.EnableDynamicHelp)

    Debug.Print "  Screen image gamma correction = " & CStr(pwOpt.GammaCorrection)

    Debug.Print "  Enable memory settings = " & CStr(pwOpt.EnableMemorySettings)

 

    Debug.Print "  Maximum memory allocation = " & CStr(pwOpt.MemoryLimit)

    Debug.Print "    Minimum = " & CStr(pwOpt.MemoryLimitMinimum)

    Debug.Print "    Maximum = " & CStr(pwOpt.MemoryLimitMaximum)

 

    

    Debug.Print " "

    

    '

    ' Print options on PhotoWorks, Options, Document Properties tab

    '

    

    Debug.Print "Document Properties:"

    Debug.Print "  Display preview window = " & CStr(pwOpt.DisplayPreviewWindow)

    Select Case pwOpt.AntiAliasingQuality

        Case pwAA_MEDIUM

            Debug.Print "  Anti-aliasing quality = Medium"

        Case pwAA_HIGH

            Debug.Print "  Anti-aliasing quality = High"

        Case pwAA_VERYHIGH

            Debug.Print "  Anti-aliasing quality = Very High"

        Case pwAA_CUSTOM

            Debug.Print "  Anti-aliasing quality = Custom"

            Debug.Print "    Current value = " & CStr(pwOpt.AntiAliasingQualityCustom)

End Select

    Debug.Print "  Enable depth settings = " & CStr(pwOpt.EnableRayTraceDepthSettings)

    Debug.Print "    Number of reflections = " & CStr(pwOpt.RayTraceNumberReflections)

    Debug.Print "    Number of refractions = " & CStr(pwOpt.RayTraceNumberRefractions)

    Debug.Print "  RayTraceDepth = " & CStr(pwOpt.RayTraceDepth)

    Debug.Print "    Minimum = " & CStr(pwOpt.RayTraceDepthMinimum)

    Debug.Print "    Maximum = " & CStr(pwOpt.RayTraceDepthMaximum)

    Debug.Print "  Brightness = " & CStr(pwOpt.Brightness)

    Debug.Print "  Contrast = " & CStr(pwOpt.Contrast)

    Debug.Print "  Color Saturation = " & CStr(pwOpt.Saturation)

    Debug.Print "  SaveImageWithDocument = " & CStr(pwOpt.SaveImageWithDocument)

    

    Debug.Print " "

    

    '

    ' Print options on PhotoWorks, Options, Advanced tab

    '

    

    Debug.Print "Advanced:"

    Select Case pwOpt.ContourRenderingMode

        Case pwModelOnly

            Debug.Print "  Contour rendering = Render model only (not contours)"

        Case pwModelAndContours

            Debug.Print "  Contour rendering = Render model and contours"

        Case pwContoursOnly

            Debug.Print "  Contour rendering = Render contours only"

    End Select

    Debug.Print "  Line thickness = " & CStr(pwOpt.ContourLineThickness)

    Debug.Print "    Minimum = " & CStr(pwOpt.ContourLineThicknessMinimum)

    Debug.Print "    Maximum = " & CStr(pwOpt.ContourLineThicknessMaximum)

    Debug.Print "  Contours fade with depth = " & CStr(pwOpt.EnableContourFadesWithDepth)

    Debug.Print "  Depth fade = " & CStr(pwOpt.ContourDepthFade)

    Debug.Print "    Minimum = " & CStr(pwOpt.ContourDepthFadeMinimum)

    Debug.Print "    Maximum = " & CStr(pwOpt.ContourDepthFadeMaximum)

    Debug.Print "  Line color = " & RGB2String(pwOpt.ContourLineColor)

    Debug.Print "  Background color = " & RGB2String(pwOpt.ContourBackgroundColor)

    

    Debug.Print

    '

    ' Print options on PhotoWorks, Options, Illumination tab

    '

    

    Debug.Print "Indirect Illumination:"

    Debug.Print "  Enable indirect illumination = " & CStr(pwOpt.EnableIndirectIllumination)

    Debug.Print "  Use default radius = " & CStr(pwOpt.UseIndirectIlluminationDefaultRadius)

    Debug.Print "    Default value = " & CStr(pwOpt.IndirectIlluminationRadiusDefault)

    Debug.Print "  Custom radius = " & CStr(pwOpt.IndirectIlluminationRadius)

    Debug.Print "    Minimum = " & CStr(pwOpt.IndirectIlluminationRadiusMinimum)

    Debug.Print "    Maximum = " & CStr(pwOpt.IndirectIlluminationRadiusMaximum)

    Debug.Print "  Amount of indirect illumination = " & CStr(pwOpt.IndirectIlluminationAccuracy)

    Debug.Print "    Minimum = " & CStr(pwOpt.IndirectIlluminationAccuracyMinimum)

    Debug.Print "    Maximum = " & CStr(pwOpt.IndirectIlluminationAccuracyMaximum)

    Debug.Print "  Indirect illumination quality = " & CStr(pwOpt.IndirectIlluminationQuality)

    Debug.Print "    Details = " & CStr(pwOpt.IndirectIlluminationDetails)

    Debug.Print "    Precison = " & CStr(pwOpt.IndirectIlluminationPrecision)

    Debug.Print "    Averaging = " & CStr(pwOpt.IndirectIlluminationAveraging)

    Debug.Print "    Bounces = " & CStr(pwOpt.IndirectIlluminationBounces)

    

    Debug.Print "  Enable caustic = " & CStr(pwOpt.EnableCaustic)

    Debug.Print "  Use default caustic radius = " & CStr(pwOpt.UseCausticDefaultRadius)

    Debug.Print "    Default value = " & CStr(pwOpt.CausticRadiusDefault)

    Debug.Print "  Custom caustic radius = " & CStr(pwOpt.CausticRadius)

    Debug.Print "    Minimum = " & CStr(pwOpt.CausticsRadiusMinimum)

    Debug.Print "    Maximum = " & CStr(pwOpt.CausticsRadiusMaximum)

    Debug.Print "  Caustic accuracy = " & CStr(pwOpt.CausticAccuracy)

    Debug.Print "    Minimum = " & CStr(pwOpt.CausticsAccuracyMinimum)

    Debug.Print "    Maximum = " & CStr(pwOpt.CausticsAccuracyMaximum)

    Debug.Print "  All materials cast and receive caustics by default = " & CStr(pwOpt.CausticAllCastAndReceive)

    

    Debug.Print "  Enable global illumination = " & CStr(pwOpt.EnableGlobalIllumination)

    Debug.Print "  Use default radius = " & CStr(pwOpt.UseGlobalIlluminationDefaultRadius)

    Debug.Print "    Default value = " & CStr(pwOpt.GlobalIlluminationRadiusDefault)

    Debug.Print "  Custom global illumination radius = " & CStr(pwOpt.GlobalIlluminationRadius)

    Debug.Print "    Minimum = " & CStr(pwOpt.GlobalIlluminationRadiusMinimum)

    Debug.Print "    Maximum = " & CStr(pwOpt.GlobalIlluminationRadiusMaximum)

    Debug.Print "  Accuracy = " & CStr(pwOpt.GlobalIlluminationAccuracy)

    Debug.Print "    Minimum = " & CStr(pwOpt.GlobalIlluminationAccuracyMinimum)

    Debug.Print "    Maximum = " & CStr(pwOpt.GlobalIlluminationAccuracyMaximum)

    Debug.Print "  All materials cast and receive global illumination by default = " & CStr(pwOpt.GlobalIlluminationAllCastAndReceive)

    

    Debug.Print " "

    

    '

    ' Print options on PhotoWorks, Options, File Locations tab

    '

    

    Debug.Print "File Locations:"

    Debug.Print "  Custom folders:"

    Debug.Print "    #active custom folders = " & CStr(pwOpt.GetCustomFolderListCount)

    If pwOpt.GetCustomFolderListCount > 0 Then

        strActiveCustomFolder = pwOpt.GetActiveCustomFolder

        vCustomFolders = pwOpt.GetCustomFolderList()

        For lPathItr = LBound(vCustomFolders) To UBound(vCustomFolders)

            strCustomFolder = vCustomFolders(lPathItr)

            If strCustomFolder = strActiveCustomFolder Then

                Debug.Print "      " & strCustomFolder & " <active>"

            Else

                Debug.Print "      " & strCustomFolder

            End If

         Next lPathItr

    End If

    

    Debug.Print "    Autoload selected folders = " & CStr(pwOpt.AutoLoadSelectedFolder)

    Debug.Print "    Suppress standard materials = " & CStr(pwOpt.SuppressStandardMaterials)

    

    Debug.Print "  Search paths:"

    Debug.Print "    Number of paths = " & CStr(pwOpt.GetSearchPathListCount)

    If pwOpt.GetSearchPathListCount > 0 Then

        

        vSearchFileList = pwOpt.GetSearchPathList()

        

        For lPathItr = LBound(vSearchFileList) To UBound(vSearchFileList)

            Debug.Print "      " & vSearchFileList(lPathItr)

        Next lPathItr

        

    End If

    

    Debug.Print "    Search sub-folders = " & CStr(pwOpt.SearchSubFolders)

    

    Debug.Print " "

    

    Debug.Print "--------------------------------------------------------------------------"    

End Sub

 

Function RGB2String(ByVal lRgb As Long) As String

    Dim lRed   As Long

    Dim lGreen As Long

    Dim lBlue  As Long

    

    ExtractRGB lRgb, lRed, lGreen, lBlue

    

    RGB2String = "(" & CStr(lRed) & ", " & CStr(lGreen) & ", " & CStr(lBlue) & ")"

End Function

 

Sub ExtractRGB(ByVal lRgb As Long, ByRef lRed As Long, ByRef lGreen As Long, ByRef lBlue As Long)

    ' Revert work done by Visual Basic function RGB()

    lRed = (lRgb And RGB(255, 0, 0))

    lGreen = (lRgb And RGB(0, 255, 0)) / 256

    lBlue = (lRgb And RGB(0, 0, 255)) / 65536

    

End Sub



Provide feedback on this topic

SOLIDWORKS welcomes your feedback concerning the presentation, accuracy, and thoroughness of the documentation. Use the form below to send your comments and suggestions about this topic directly to our documentation team. The documentation team cannot answer technical support questions. Click here for information about technical support.

* Required

 
*Email:  
Subject:   Feedback on Help Topics
Page:   Get PhotoWorks Options Example (VBA)
*Comment:  
*   I acknowledge I have read and I hereby accept the privacy policy under which my Personal Data will be used by Dassault Systèmes

Print Topic

Select the scope of content to print:

x

We have detected you are using a browser version older than Internet Explorer 7. For optimized display, we suggest upgrading your browser to Internet Explorer 7 or newer.

 Never show this message again
x

Web Help Content Version: API Help (English only) 2010 SP05

To disable Web help from within SOLIDWORKS and use local help instead, click Help > Use SOLIDWORKS Web Help.

To report problems encountered with the Web help interface and search, contact your local support representative. To provide feedback on individual help topics, use the “Feedback on this topic” link on the individual topic page.