Change apply appearance option in material using SOLIDWORKS API

Edit ArticleEdit Article

Apply Appearance option in Edit material dialog
Apply Appearance option in Edit material dialog

This example demonstrates how to change the Apply Appearance option in the material options using SOLIDWORKS API.

Dim swApp As SldWorks.SldWorks
Dim swPart As SldWorks.PartDoc

Sub main()

    Set swApp = Application.SldWorks
    Set swPart = swApp.ActiveDoc
    If Not swPart Is Nothing Then
        Dim swMatVisPrps As SldWorks.MaterialVisualPropertiesData
        Set swMatVisPrps = swPart.GetMaterialVisualProperties
        swMatVisPrps.ApplyAppearance = False
        swPart.SetMaterialVisualProperties swMatVisPrps, swInConfigurationOpts_e.swAllConfiguration, Empty
        MsgBox "Please open part document"
    End If
End Sub


All articles and code at CodeStack are now open-source and hosted on GitHub. If you want to contribute by modifying existing articles and code snippets, submitting new ones, reporting errors and bugs etc. please follow this blog post for more information. We appreciate any contribution.

Product of Xarial Product of Xarial