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: 

Provide multiple fonts in single ModelLeaderNoteDefinition

10 REPLIES 10
SOLVED
Reply
Message 1 of 11
ramasamy_thangaperumal
318 Views, 10 Replies

Provide multiple fonts in single ModelLeaderNoteDefinition

I want to provide different font size in one Model Leader note definition like attached image. Is there any possible way to do this?

10 REPLIES 10
Message 2 of 11

Hi @ramasamy_thangaperumal,

 

You could use the Formatted Text property as folowing :

Dim o As Inventor.ModelLeaderNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "")
o.Definition.Text.FormattedText = "<StyleOverride FontSize='0,6'>4</StyleOverride>(4x)"

 

What you can do to get the  actual string on line 2 is format the text, copy it co clip board (ctrl + c) & paste it in the code afterwards :

Dim o As Inventor.ModelLeaderNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "")
My.Computer.Clipboard.SetText(o.Definition.Text.FormattedText.ToString) 

 

Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

Message 3 of 11

@FINET_Laurent is right - use the FormattedText property.

Whenever I want to set formatting for drawing views (or other objects) I manually set the object as an example, use VBA to extract the formatted text string, then paste it back to my code like @FINET_Laurent suggested, but you'll want to build your own string by replacing the text you manually typed with the text generated by your code.

Message 4 of 11

Thanks for the quick reply. It is working for me. Like this can we able to change the color?

Message 5 of 11

Yes - its the same process... Manually create a text box and change the colour, then have a look at the FormattedText property in VBA, and adjust it to suit your needs.

Message 6 of 11

Can you share me sample code? FormattedText = <styleoverride color="Here what should i need to provide(RGB / color name)">.

Message 7 of 11

My apologies - you set the text colour using the color property - sample code below.

 

The TransientObjects.CreateColour() method uses 3 inputs as RGB values between 0 and 255.

 

Sub GetFormattedText()

Dim oSS As SelectSet
Set oSS = ThisApplication.ActiveDocument.SelectSet

Dim oObj As Object
Dim oTB As GeneralNote

Dim oCol As Color
Set oCol = ThisApplication.TransientObjects.CreateColor(255, 0, 0)

For Each oObj In oSS
    If oObj.Type = kGeneralNoteObject Then
        oTB.Color = oCol
    End If
Next oObj

End Sub

 

 Unfortunately it appears that you can't change SOME of your text - you must change the colour of the whole text box only.

 

I hope that helps.

Message 8 of 11

@gerrardhickson Thanks for your support. Actually, I want to change multiple color like how I am trying to change multiple font size. 

o.Definition.Text.FormattedText = "<StyleOverride FontSize='0,6'>4</StyleOverride>(4x)"

Here for text "4" I am setting one font size. like same way I want to change color only for text"4x". 

text = 4(4x)

Message 9 of 11

Hi, I understand what you hope to do, but I don't believe it is possible.

Message 10 of 11

Thanks @gerrardhickson . @FINET_Laurent Can you support me on this color change code?

Message 11 of 11

Hi @ramasamy_thangaperumal 

 

Indeed you can only have one color for the whole text note.

To get the color of an existing one (already formatted), here is the code :

Dim o As Inventor.ModelLeaderNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "")
Dim rgb As String = o.Definition.Text.Color.Red & " - " & o.Definition.Text.Color.Green & " - " & o.Definition.Text.Color.Blue
MsgBox(rgb)

 

To create a new color and set it to the selected note, here is the code :

Dim o As Inventor.ModelLeaderNote = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "")
Dim c As Inventor.Color = ThisApplication.TransientObjects.CreateColor(100, 150, 200)
o.Definition.Text.Color = c

About colors : https://help.autodesk.com/view/INVNTOR/2022/ENU/?guid=TransientObjects_CreateColor


Note you can mark multiples replies as solution in the same post.


Kind regards,

FINET L.

If this post solved your question, please kindly mark it as "Solution"

If this post helped out in any way to solve your question, please drop a "Like"

@LinkedIn     @JohnCockerill

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report