Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Michael.Navara
in reply to: BeKirra

This code snippet can help you. 

Sub Main()
    Dim body As SurfaceBody
    Dim pick = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartBodyFilter, "Pick a body")
    Dim surfaceBodyProxy As SurfaceBodyProxy = TryCast(pick, SurfaceBodyProxy)
    If Not surfaceBodyProxy Is Nothing Then
        body = surfaceBodyProxy.NativeObject
    Else
        body = pick
    End If
    ChangeAppearance(body)
    ThisApplication.ActiveDocument.Update()
End Sub

Private Sub ChangeAppearance(body As SurfaceBody)
    Dim partDef As PartComponentDefinition = body.Parent
    Dim partDoc As PartDocument = partDef.Document
    Dim assetNames = partDoc.AppearanceAssets.OfType(Of Asset).Select(Function(x) x.DisplayName)
    Dim selectedAssetName As String = InputListBox("Select Appearance", assetNames).ToString()

    Dim selectedAsset As Asset = partDoc.AppearanceAssets.OfType(Of Asset).FirstOrDefault(Function(x) x.DisplayName = selectedAssetName)
    If selectedAsset Is Nothing Then Return

    body.Appearance = selectedAsset

End Sub