Control Font Size of Text Parameters in a Title Block with ilogic?

Control Font Size of Text Parameters in a Title Block with ilogic?

RockieM
Advocate Advocate
1,123 Views
2 Replies
Message 1 of 3

Control Font Size of Text Parameters in a Title Block with ilogic?

RockieM
Advocate
Advocate

Either this is more complicated than I thought it would be or I'm not searching the right text.....or I haven't had enough coffee.

 

Problem:  I have a text parameter in my .idw title block populated from a custom iProperty in my model document.

Is there a way to control this text?  Basically I want to reduce the font size if the text in the iProperty goes beyond the space allotted in my title block.

 

(Inventor 2016)

 

Any info on this would be much appreciated!

Thanks!

 

 

0 Likes
Accepted solutions (1)
1,124 Views
2 Replies
Replies (2)
Message 2 of 3

marcin_otręba
Advisor
Advisor
Accepted solution

use this:

 

Sub b()

Dim odoc As DrawingDocument
Set odoc = ThisApplication.ActiveDocument ' drawing must be open
Dim otitle As TitleBlock
Set otitle = odoc.ActiveSheet.TitleBlock
Dim otxt As TextBox
For Each otxt In otitle.Definition.Sketch.TextBoxes
Debug.Print otxt.FormattedText
Next

to see how to define format of text in your title block then you can simply reuse it and call

 

 

 otxt.FormattedText = "something you will whant"

or you can simply try to use

 

 

otxt.Width
or
otxt.widthscale

if you will need any more assist give me known...

 

 

you can check also inventor help file: search for : XML Tags for FormattedText

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

Message 3 of 3

RockieM
Advocate
Advocate

Thanks for the reply. 

 

This got me in the direction I needed as I was looking at it the wrong way.

I tried all your suggestions and found the otext.WidthScale to work the best.

 

Im not sure if it's as clean as it could be but here is a snippet of my code :

 

    Dim oTG As TransientGeometry
        oTG = ThisApplication.TransientGeometry
    Dim oDoc As DrawingDocument
        oDoc = ThisApplication.ActiveDocument
    Dim oSheet As Sheet
        oSheet = oDoc.ActiveSheet
    Dim oTB As TitleBlock
        oTB = oSheet.TitleBlock
    Dim oDef As TitleBlockDefinition
        oDef = oTB.Definition
        
    'open sketch in edit mode
    Dim oSketch As DrawingSketch
    Call oDef.Edit(oSketch)
    
    Dim oTextBoxes As TextBoxes
        oTextBoxes = oSketch.TextBoxes

    Dim oBox As TextBox            
        For Each oBox In oTextBoxes
            If oBox.Text = "<CHK1>" Then 'The text parameter you want to change             
                Call oDef.Edit(oSketch)
                oBox.WidthScale = 0.8
                Call oDef.ExitEdit(True)
            End If
        Next
 
 InventorVb.DocumentUpdate()