Hi everyone,
I have a text box in the title block which displays the "part number" from drawing iproperties.
I need to change it to display the "part number" from model iproperties.
Will this be possible via VBA?
Thank you.
Solved! Go to Solution.
Solved by Dennis.Ossadnik. Go to Solution.
Hi ac69.
You can change the reference to model by editing the FormattedText of the text box. Here you have to replace Property Document="'drawing'" with Property Document="'model'"
Here you can find a litte example that works with our standard templates (English)
VBA example:
Sub ChangeReferenceInTitleBlock()
Dim oApp As Application
Set oApp = ThisApplication
Dim oDoc As DrawingDocument
Set oDoc = oapp.ActiveDocument
'Select the title block you want to edit
Dim oTitleB As TitleBlockDefinition
Set oTitleB = oDoc.TitleBlockDefinitions.Item(1)
'go to sketch edit mode
Dim oSketch As DrawingSketch
Call oTitleB.Edit(oSketch)
'Search for the correct text box
'replace "<PART NUMBER>" for the correct expression in the language you have installed Inventor
'this example shows the English version
'You can check the expression by opening your title block manually. -> Screenshot
Dim tempTB As TextBox
For Each tempTB In oSketch.TextBoxes
If tempTB.Text = "<PART NUMBER>" Then 'see hint above
'change reference from drawing to model
tempTB.FormattedText = Replace(tempTB.FormattedText, "Property Document='drawing'", "Property Document='model'")
End If
Next
'exit edit mode and save
Call oTitleB.ExitEdit(True)
End Sub
---
Here you can find the correct expression: Edit - Title block (f.e. German version)
I hope this will work for you.
Please click "Accept as Solution" if this response answers your question.
Hi Dennis,
Thanks for the solution. It works well.
One more question: Is there any way to set the height of the text? Either to fit into the textbox either to give an actual value (5.5 for example).
I tried to use : "tempTB.FittedTextHeight() = True"
but it doesn't work. And unfortunatelly, there is no "tiptext" to help. Just an error message : "Wrong number of arguments or invalid property assignment".
Thanks,