Hi @Darkforce_the_ilogic_guy. Here is something you can try out. It first checks to see if any true 'A-Side' face has been defined, and if not, it then checks the FlatPattern for its 'BaseFace'. You can set this when creating a flat pattern initially, but if you do not specify one, one is set for you automatically, so I believe it will always have a value. I believe the FlatPattern.BottomFace will always have a value too, but it seems to me like I have encountered situations where there was no value for the FlatPattern.TopFace, so I did not include that as a possibility. Also, this version attempts to get a standard appearance from the 'Inventor Material Library' named "White", then checks to see if there is a local copy of it, and if not, it creates a local copy of it for use when setting the appearance to the face. I don't know if something like that is what you had in mind, but it seemed more realistic than simply getting the first appearance in the document to use for the face, so that's what I went with for this example.
If ThisDoc.Document.SubType <> "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
MsgBox("This is not a Sheet Metal Part. Exiting rule.", vbCritical, "")
Exit Sub
End If
Dim oPDoc As PartDocument = ThisDoc.Document
Dim oSMDef As SheetMetalComponentDefinition = oPDoc.ComponentDefinition
Dim oFaceToChange As Face = Nothing
If oSMDef.ASideDefinitions.Count > 0 Then
oFaceToChange = oSMDef.ASideDefinitions.Item(1).ASideFace
End If
If IsNothing(oFaceToChange) Then
'try to get the 'BaseFace' from the FlatPattern
Dim oFP As FlatPattern = Nothing
If oSMDef.HasFlatPattern Then
oFP = oSMDef.FlatPattern
Else
Try
oSMDef.Unfold
oFP = oSMDef.FlatPattern
oFP.ExitEdit
Catch
MsgBox("Error unfolding part to get FlatPattern.", vbCritical, "")
Exit Sub
End Try
End If
If IsNothing(oFP) Then Exit Sub
oFaceToChange = oFP.BaseFace 'usually the stationary face when others unfold
'oFaceToChange = oFP.BottomFace
End If
'get/specify appearance type Asset to supply as value to face appearance
Dim oInvMatLib As AssetLibrary = ThisApplication.AssetLibraries.Item("Inventor Material Library")
Dim oWhite As Asset = oInvMatLib.AppearanceAssets.Item("White")
'get a 'local copy' of this appearance to work with (needed)
Dim oDocApps As AssetsEnumerator = oPDoc.AppearanceAssets
Dim oAppAsset As Asset = Nothing
Try
oAppAsset = oDocApps.Item("White")
Catch
oAppAsset = oWhite.CopyTo(oPDoc, True)
End Try
oFaceToChange.Appearance = oAppAsset
'oFaceToChange.AppearanceSourceType = AppearanceSourceTypeEnum.kOverrideAppearance
Wesley Crihfield

(Not an Autodesk Employee)