09-29-2024
10:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
09-29-2024
10:53 AM
I used the following iLogic rule to print all (or at least most) AssetValue for a face appearance. (Disclaimer: I only tested it on one face. Reslut may be different on your faces.)
Sub main()
Dim doc As PartDocument = ThisDoc.Document
Dim body As SurfaceBody = doc.ComponentDefinition.SurfaceBodies.Item(1)
Dim face = body.Faces.Item(1)
Dim appearance = face.Appearance
LogAssetValues(appearance.Cast(Of AssetValue))
End Sub
Private Sub LogAssetValues(assetValues As IEnumerable(Of AssetValue), Optional preText As String = "")
For Each assetValue As AssetValue In assetValues
Select Case AssetValue.ValueType
Case AssetValueTypeEnum.kAssetValueTypeString
PrintAssetValueDefault(preText, AssetValue)
Case AssetValueTypeEnum.kAssetValueTypeBoolean
PrintAssetValueDefault(preText, AssetValue)
Case AssetValueTypeEnum.kAssetValueTypeInteger
PrintAssetValueDefault(preText, AssetValue)
Case AssetValueTypeEnum.kAssetValueTypeFloat
PrintAssetValueDefault(preText, AssetValue)
'logger.Info(preText + assetValue.DisplayName + ": " + assetValue.Value.ToString())
Case AssetValueTypeEnum.kAssetValueTypeFilename
Dim a As FilenameAssetValue = AssetValue
If (a.HasMultipleValues) Then
logger.Info(preText + a.DisplayName + " (" + a.Name + ") has values: ")
For Each val As String In a.Values
logger.Info(preText + " - " + Val)
Next
Else
logger.Info(preText + a.DisplayName + " (" + a.Name + ") has value: " + a.Value)
End If
Case AssetValueTypeEnum.kAssetValueTypeColor
Dim a As ColorAssetValue = AssetValue
If (a.HasMultipleValues) Then
logger.Info(preText + a.DisplayName + " (" + a.Name + ") has values: -----------------------------------------------")
For Each color As Color In a.Values
Dim colorString = String.Format("Red:{0}, Green:{1}, Blue:{2}, Opacity:{3}",
Color.Red, Color.Green, Color.Blue, Color.Opacity)
If (a.HasConnectedTexture) Then
logger.Info(preText + " - " + a.DisplayName + ": " + colorString + " (Has connected texture:)")
Dim textureAsset As AssetTexture = a.ConnectedTexture
LogAssetValues(textureAsset.Cast(Of AssetValue), " " + preText)
Else
logger.Info(preText + a.DisplayName + " (" + a.Name + "): " + colorString + " (NONE connected texture)")
End If
Next
Else
Dim color = a.Value
Dim colorString = String.Format("Red:{0}, Green:{1}, Blue:{2}, Opacity:{3}",
color.Red, color.Green, color.Blue, color.Opacity)
If (a.HasConnectedTexture) Then
logger.Info(preText + a.DisplayName + " (" + a.Name + "): " + colorString + " Has connected texture:")
Dim textureAsset As AssetTexture = a.ConnectedTexture
LogAssetValues(textureAsset.Cast(Of AssetValue), " " + preText)
Else
logger.Info(preText + a.DisplayName + " (" + a.Name + "): " + colorString + " (NONE connected texture)")
End If
End If
Case AssetValueTypeEnum.kAssetValueTypeChoice
Dim a As ChoiceAssetValue = AssetValue
Dim names As String() = {}
Dim choises As String() = {}
a.GetChoices(names, choises)
Dim allChoises = String.Join("//", choises)
logger.Info(preText + a.DisplayName + " (" + a.Name + ") has value: " + a.Value + "(" + allChoises + ")")
Case Else
logger.Info("----------> " + AssetValue.DisplayName + ": " + CType(AssetValue.Type, ObjectTypeEnum).ToString())
End Select
Next
End Sub
Private Sub PrintAssetValueDefault(preText As String, assetValue As AssetValue)
Dim template = preText + "{0} ({1}): {2}"
logger.Info(String.Format(template, assetValue.DisplayName, assetValue.Name, assetValue.Value.ToString()))
End Sub
With this I came to the conclusion that you can get the filename using this line of code:
appearance.Item("generic_diffuse").ConnectedTexture.Item("unifiedbitmap_Bitmap").Value
As a warning, I found that the file path can be a relative path. and there can be multiple paths. Have a look at what I found for my "Bump" texture:
Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Blog: hjalte.nl - github.com