Get Appearance Filename Example (VBA)
This example shows how to get the filename of the first appearance applied
to a model.
'---------------------------------
'
' Preconditions: Model document is open that
' has
at least one appearance
' applied
to it.
'
' Postconditions: None
'
'---------------------------------
Option Explicit
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swModelDocExt As SldWorks.ModelDocExtension
Dim swAppearance As SldWorks.RenderMaterial
Dim lNbrAppearances As Long, i As Long
Sub main()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swModelDocExt = swModel.Extension
lNbrAppearances = swModelDocExt.GetRenderMaterialsCount
Debug.Print "Number of appearances: " &
lNbrAppearances
' If 1 or more appearances where applied to the model,
' then get the filename of the first appearance applied
If lNbrAppearances > 0 Then
Set
swAppearance = swModelDocExt.GetMaterial(1,
"Default")
Debug.Print
"First appearance's filename: " & swAppearance.FileName
Else
Debug.Print
"No appearances applied to this model."
End If
End Sub