Next the error will occur when the View is no Flat Pattern view:
Now you receive a message if it is not:
Dim dwg As Inventor.DrawingDocument = ThisDrawing.Document
Dim v As Inventor.DrawingView '= dwg.ActiveSheet.DrawingViews.Item(1)
v = ThisApplication.CommandManager.Pick(Inventor.selectionfilterenum.kDrawingViewFilter, "Select a Flat Pattern View")
If v.IsFlatPatternView = True Then
Dim a As Inventor.PartDocument = v.ReferencedDocumentDescriptor.ReferencedDocument 'ThisDoc.Document
If a.SubType = "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}" Then
Dim s As Inventor.SheetMetalComponentDefinition = a.ComponentDefinition
Dim f As Inventor.FlatPattern = s.FlatPattern
Dim fl As Inventor.FlatPatternOrientation = f.FlatPatternOrientations.Item(1)
If fl.FlipBaseFace = False Then
fl.FlipBaseFace = True
ElseIf fl.FlipBaseFace = True
fl.FlipBaseFace= False
End If
dwg.Update
End If
Else
MsgBox("This View Contains no Flat Pattern")
End If