Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

iproperty in title block

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
ac69
830 Views, 2 Replies

iproperty in title block

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.

Tags (1)
2 REPLIES 2
Message 2 of 3
Dennis.Ossadnik
in reply to: ac69

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)

PartNumberGerman.png

 

I hope this will work for you.

 

Please click "Accept as Solution" if this response answers your question.

 



Dennis Ossadnik
Senior Technical Support Specialist
Message 3 of 3
ac69
in reply to: Dennis.Ossadnik

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,

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report