Code:
Sub schriftkopf_update()Dim Rev As String
Dim Bauteil As String
Dim oDrawDoc As DrawingDocument
Set oDrawDoc = ThisApplication.ActiveDocument
''Revisionsnummer von dem Erstansicht
Dim oReferencedPartDoc As Document
For Each oReferencedPartDoc In oDrawDoc.AllReferencedDocuments
Dim name As String
Dim typ1 As String
name = oReferencedPartDoc.DisplayName
typ1 = Right(oReferencedPartDoc.FullFileName, 4)
If name = oDrawDoc.DisplayName And typ1 = ".ipt" Then
'.............................................................................................................................
'Textfild Inhalt geht an die Modell iProp
Dim oapp As Inventor.Application
Dim oDoc As Inventor.DrawingDocument
Set oapp = ThisApplication
Set oDoc = oapp.ActiveDocument
Dim obox As Inventor.TextBox
Dim kundName As String, verwZweck As String, bez As String, typ As String 'Variable für die Datenübergabe von Textfield nach Bauteil iProps
For Each obox In oDoc.ActiveSheet.TitleBlock.Definition.Sketch.TextBoxes
Select Case obox.Text
'Bezeichnung --> Bezeichnung
Case "BEZEICHNUNG"
bez = oDoc.ActiveSheet.TitleBlock.GetResultText(obox)
If bez <> "" Then
oReferencedPartDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").Item("Description").Value = bez
End If
'Kundennamme --> Kostenstelle
Case "Kunde-Name:", "Kundenname:" To "Kundenname"
kundName = oDoc.ActiveSheet.TitleBlock.GetResultText(obox)
If kundName <> "" Then
oReferencedPartDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").Item("Cost Center").Value = kundName 'odoc.ActiveSheet.TitleBlock.GetResultText(obox)
End If
'Kundennamme --> Kostenstelle
Case "Kundenname:"
kundName = oDoc.ActiveSheet.TitleBlock.GetResultText(obox)
If kundName <> "" Then
oReferencedPartDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").Item("Cost Center").Value = kundName 'odoc.ActiveSheet.TitleBlock.GetResultText(obox)
End If
'Kundennamme --> Kostenstelle
Case "Kundenname"
kundName = oDoc.ActiveSheet.TitleBlock.GetResultText(obox)
If kundName <> "" Then
oReferencedPartDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").Item("Cost Center").Value = kundName
End If 'odoc.ActiveSheet.TitleBlock.GetResultText(obox)
'Verwendungszweck --> Kategorie
Case "Verwendungszweck"
verwZweck = oDoc.ActiveSheet.TitleBlock.GetResultText(obox)
If verwZweck <> "" Then
oReferencedPartDoc.PropertySets.Item("{D5CDD502-2E9C-101B-9397-08002B2CF9AE}").Item("Category").Value = verwZweck
End If
Case "Verwendungszweck:"
verwZweck = oDoc.ActiveSheet.TitleBlock.GetResultText(obox)
If verwZweck <> "" Then
oReferencedPartDoc.PropertySets.Item("{D5CDD502-2E9C-101B-9397-08002B2CF9AE}").Item("Category").Value = verwZweck
End If
'Typ --> Project
Case "Typ"
typ = oDoc.ActiveSheet.TitleBlock.GetResultText(obox)
If typ <> "" Then
oReferencedPartDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").Item("Project").Value = typ
End If
Case "Typ:"
typ = oDoc.ActiveSheet.TitleBlock.GetResultText(obox)
If typ <> "" Then
oReferencedPartDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").Item("Project").Value = typ
End If
End Select
Next obox
End If
Next oReferencedPartDoc
'............................................................................................................................
Dim bezeichnung As String
Dim kostenstelle As String
Dim kategorie As String
Dim projekt As String
Dim oRefDoc As Document
Set oRefDoc = oDrawDoc.ReferencedDocuments.Item(1)
' Create the new title block defintion.
Dim oTitleBlockDef As TitleBlockDefinition
Set oTitleBlockDef = oDrawDoc.ActiveSheet.TitleBlock.Definition
Dim oSketch As DrawingSketch
Call oTitleBlockDef.Edit(oSketch)
Dim bauteilnummer As String
bauteilnummer = oRefDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").Item("Part Number").Value
projekt = oRefDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").Item("Project").Value
kostenstelle = oRefDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").Item("Cost Center").Value
bezeichnung = oRefDoc.PropertySets.Item("{32853F0F-3444-11D1-9E93-0060B03C1CA6}").Item("Description").Value
kategorie = oRefDoc.PropertySets.Item("{D5CDD502-2E9C-101B-9397-08002B2CF9AE}").Item("Category").Value
' Kostenstelle, also Kundenname
If kostenstelle <> "" Then
If Len(kostenstelle) < 16 Then 'And oSketch.TextBoxes.Item(65).FormattedText = "<Prompt ReadOnlyUniqueID='55'>Kunde-Name:</Prompt>" Then
oSketch.TextBoxes.Item(65).FormattedText = "<StyleOverride FontSize='0,5'><Property Document='model' PropertySet='Design Tracking Properties' Property='Cost Center' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='9'>KOSTENSTELLE</Property></StyleOverride>"
ElseIf Len(kostenstelle) <= 24 And oSketch.TextBoxes.Item(65).FormattedText = "<Prompt ReadOnlyUniqueID='55'>Kunde-Name:</Prompt>" Then
oSketch.TextBoxes.Item(65).FormattedText = "<StyleOverride FontSize='0,35'><Property Document='model' PropertySet='Design Tracking Properties' Property='Cost Center' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='9'>KOSTENSTELLE</Property></StyleOverride>"
ElseIf Len(kostenstelle) > 24 And oSketch.TextBoxes.Item(65).FormattedText = "<Prompt ReadOnlyUniqueID='55'>Kunde-Name:</Prompt>" Then
oSketch.TextBoxes.Item(65).FormattedText = "<StyleOverride FontSize='0,25'><Property Document='model' PropertySet='Design Tracking Properties' Property='Cost Center' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='9'>KOSTENSTELLE</Property></StyleOverride>"
End If
Else: MsgBox "Kundenname bzw. Kostenstelle muss manuell eingetragen werden!"
End If
'Bezeichnung
If bezeichnung <> "" Then 'And oSketch.TextBoxes.Item(21).FormattedText = "<Prompt ReadOnlyUniqueID='1'>BEZEICHNUNG</Prompt>" Then
If Len(bezeichnung) < 24 And bezeichnung <> "" Then
oSketch.TextBoxes.Item(21).FormattedText = "<StyleOverride FontSize='0,6'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>BESCHREIBUNG</Property></StyleOverride>"
ElseIf Len(bezeichnung) >= 24 And Len(bezeichnung) <= 27 Then
oSketch.TextBoxes.Item(21).FormattedText = "<StyleOverride FontSize='0,52'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>BESCHREIBUNG</Property></StyleOverride>"
ElseIf Len(bezeichnung) >= 27 Then
oSketch.TextBoxes.Item(21).FormattedText = "<StyleOverride FontSize='0,45'><Property Document='model' PropertySet='Design Tracking Properties' Property='Description' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='29'>BESCHREIBUNG</Property></StyleOverride>"
End If
Else: MsgBox "Bezeichnung muss manuell eingetragen werden!"
End If
'Kategorie
If kategorie <> "" Then 'And oSketch.TextBoxes.Item(66).FormattedText = "<Prompt ReadOnlyUniqueID='56'>Verwendungszweck</Prompt>" Then
If Len(kategorie) < 35 Then
oSketch.TextBoxes.Item(66).FormattedText = "<StyleOverride FontSize='0,4'><Property Document='model' PropertySet='Inventor Document Summary Information' Property='Category' FormatID='{D5CDD502-2E9C-101B-9397-08002B2CF9AE}' PropertyID='2'>KATEGORIE</Property></StyleOverride>"
Else
oSketch.TextBoxes.Item(66).FormattedText = "<StyleOverride FontSize='0,3'><Property Document='model' PropertySet='Inventor Document Summary Information' Property='Category' FormatID='{D5CDD502-2E9C-101B-9397-08002B2CF9AE}' PropertyID='2'>KATEGORIE</Property></StyleOverride>"
End If
Else: MsgBox "Verwendungszweck bzw. Kategorie muss manuell eingetragen werden!"
End If
'Project
If projekt <> "" Then 'And oSketch.TextBoxes.Item(67).FormattedText = "<Prompt ReadOnlyUniqueID='57'>Typ</Prompt>" Then
If Len(projekt) < 36 Then
oSketch.TextBoxes.Item(67).FormattedText = "<StyleOverride FontSize='0,35'><Property Document='model' PropertySet='Design Tracking Properties' Property='Project' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='7'>PROJEKT</Property></StyleOverride>"
Else
oSketch.TextBoxes.Item(67).FormattedText = "<StyleOverride FontSize='0,2'><Property Document='model' PropertySet='Design Tracking Properties' Property='Project' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='7'>PROJEKT</Property></StyleOverride>"
End If
Else: MsgBox "Projekt bzw. Typ muss manuell eingetragen werden!"
End If
'Bauteilnummer und Revisionsnummer
If Len(bauteilnummer) < 10 Then 'And oSketch.TextBoxes.Item(22).FormattedText = "<Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>BAUTEILNUMMER</Property>" Then
oSketch.TextBoxes.Item(21).FormattedText = "<StyleOverride FontSize='0,6'><Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>BAUTEILNUMMER</Property></StyleOverride><StyleOverride FontSize='0,6'> Rev </StyleOverride><StyleOverride FontSize='0,6'><Property Document='model' PropertySet='Inventor Summary Information' Property='Revision Number' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='9'>REVISIONSNUMMER</Property></StyleOverride>"
ElseIf Len(bauteilnummer) >= 10 Then 'And oSketch.TextBoxes.Item(22).FormattedText = "<Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>BAUTEILNUMMER</Property>" Then
oSketch.TextBoxes.Item(21).FormattedText = "<StyleOverride FontSize='0,4'><Property Document='model' PropertySet='Design Tracking Properties' Property='Part Number' FormatID='{32853F0F-3444-11D1-9E93-0060B03C1CA6}' PropertyID='5'>BAUTEILNUMMER</Property></StyleOverride><StyleOverride FontSize='0,4'> Rev </StyleOverride><StyleOverride FontSize='0,4'><Property Document='model' PropertySet='Inventor Summary Information' Property='Revision Number' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='9'>REVISIONSNUMMER</Property></StyleOverride>"
Else: MsgBox "Bauteilnummer bzw. Revisionsnummer muss manuell eingetragen werden!"
End If
Call oTitleBlockDef.ExitEdit
End Sub