I want to provide different font size in one Model Leader note definition like attached image. Is there any possible way to do this?
Solved! Go to Solution.
Solved by FINET_Laurent. Go to Solution.
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"@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.
Thanks for the quick reply. It is working for me. Like this can we able to change the color?
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.
Can you share me sample code? FormattedText = <styleoverride color="Here what should i need to provide(RGB / color name)">.
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.
@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)
Hi, I understand what you hope to do, but I don't believe it is possible.
Thanks @gerrardhickson . @FINET_Laurent Can you support me on this color change code?
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"Can't find what you're looking for? Ask the community or share your knowledge.