05-17-2024
01:13 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
05-17-2024
01:13 AM
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