1) Not all material Appearance Assets have the Generic Diffuse property.
2) Not all Generic Diffuse properties have an embedded UnifiedBitmap (which is the container for the BitMap properties)
3) the path is stored within the unifiedbitmap_Bitmap string property of the embedded Asset
Here is a clip from a utility that I just finished that creates a new material, then adds an embedded asset to the appearance Asset if it doesn't already have one, then assigns an image path to the embedded asset...
*Please note that I use text strings for all of the "findByName" calls but this doesn't translate to other languages and will be replaced with calls such as : FindByName(RDV.Generic.GenericDiffuse)
Using editScope As New RDV.AppearanceAssetEditScope(thisDoc)
' returns an editable copy of the new appearance asset
Dim editableAsset As RDV.Asset = editScope.Start(thisAsset.Id)
Dim descriptionProperty As RDV.AssetPropertyString = TryCast(editableAsset.FindByName("description"), RDV.AssetPropertyString)
descriptionProperty.Value = "My First Generic Appearance Asset"
'let's attach some images
'create a reusable string for the images
Dim imagePath As String
'** add a generic Diffuse image to the Appearance Asset
Dim diffuseMapProperty As RDV.AssetProperty = editableAsset.FindByName("generic_diffuse")
Dim connectedDiffAsset As RDV.Asset = diffuseMapProperty.GetSingleConnectedAsset()
' Add a new connected asset if it doesn't already have one
If connectedDiffAsset Is Nothing Then
diffuseMapProperty.AddConnectedAsset("UnifiedBitmap")
connectedDiffAsset = diffuseMapProperty.GetSingleConnectedAsset()
End If
If connectedDiffAsset IsNot Nothing Then
' Find the target asset path property
Dim diffuseBitmapProperty As RDV.AssetPropertyString = TryCast(connectedDiffAsset.FindByName("unifiedbitmap_Bitmap"), RDV.AssetPropertyString)
'build a path to an image
imagePath = My.Computer.FileSystem.CombinePath(thisPath, "Concrete.Cast-In-Place.Exposed Aggregate.Medium.jpg")
If diffuseBitmapProperty.IsValidValue(imagePath) Then
diffuseBitmapProperty.Value = imagePath
End If
End If
Sorry for the VB but it's the only language that I can speak fluently at this time 🙂
-G
Gary J. Orr
GaryOrrMBI (MBI Companies 2014-Current)
aka (past user names):
Gary_J_Orr (GOMO Stuff 2008-2014);
OrrG (Forum Studio 2005-2008);
Gary J. Orr (LHB Inc 2002-2005);
Orr, Gary J. (Gossen Livingston 1997-2002)