Code:
Sub CATMain()
Start:Dim varSelection
Set varSelection = CATIA.ActiveDocument.Selection
Dim ArrSelectionFilter(1)
ArrSelectionFilter(0) = "Face"
ArrSelectionFilter(1) = "Product"
Dim SelectionPart As String
SelectionPart = varSelection.SelectElement2(ArrSelectionFilter, "Part wählen!", False)
If SelectionPart = "Cancel" Then
GoTo Ende
End If
Dim drawingDocument1 As DrawingDocument
Set drawingDocument1 = CATIA.Documents.Item("Drawing1.CATDrawing")
Dim drawingSheets1 As DrawingSheets
Set drawingSheets1 = drawingDocument1.Sheets
Dim drawingSheet1 As DrawingSheet
Set drawingSheet1 = drawingSheets1.Item("Blatt .1")
Dim drawingViews1 As DrawingViews
Set drawingViews1 = drawingSheet1.Views
Dim drawingView1 As DrawingView
Set drawingView1 = drawingViews1.Add("AutomaticNaming")
Dim drawingViewGenerativeLinks1 As DrawingViewGenerativeLinks
Set drawingViewGenerativeLinks1 = drawingView1.GenerativeLinks
Dim drawingViewGenerativeBehavior1 As DrawingViewGenerativeBehavior
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
Dim varSelection2
Set varSelection2 = CATIA.Documents.Item(varSelection.Item(1).Value.Name + ".CATPart").Selection
Dim SelectionSchore As String
SelectionSchore = varSelection2.SelectElement2(ArrSelectionFilter, "Fläche anklicken!", False)
Dim documents1 As Documents
Set documents1 = CATIA.Documents
Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.Documents.Item(varSelection.Item(1).Value.Name + ".CATPart")
Dim Name As String
Dim AnzZeichen As Long
Name = partDocument1.Name
AnzZeichen = Len(Name)
Name = Left(Name, AnzZeichen - 8)
Dim product1 As Product
Set product1 = partDocument1.GetItem(Name)
drawingViewGenerativeBehavior1.Document = product1
'drawingViewGenerativeBehavior1.DefineFrontView 0#, -0.111251, -0.993792, 0#, 0.993792, -0.111251
'drawingView1.X = 148.5
'drawingView1.Y = 105#
drawingView1.[Scale] = 1#
Set drawingViewGenerativeBehavior1 = drawingView1.GenerativeBehavior
drawingViewGenerativeBehavior1.Update
drawingView1.Activate
GoTo Start
Ende:
End Sub