Font size setting in the corner stamp

Font size setting in the corner stamp

DeptaM
Enthusiast Enthusiast
528 Views
8 Replies
Message 1 of 9

Font size setting in the corner stamp

DeptaM
Enthusiast
Enthusiast

Hi to all,
in the corner stamp in the name box I have the font size set to 5mm. Sometimes we have long names and we have to resize the stamp directly to fit the name. Is there a rule where the font can be set directly?
Thanks

27.06.2022.JPG

0 Likes
529 Views
8 Replies
Replies (8)
Message 2 of 9

JelteDeJong
Mentor
Mentor

it is possible but you need to give more info. Let's start with the following rule.  Change the property name at the start of the rule and run it. You should get a message box. Can you share the text in the message box? This is needed to see what needs to be updated/changed.

Dim propertyName As String = "Title" ' Set your property name here!

Dim doc As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = doc.ActiveSheet
Dim titleBlock As TitleBlockDefinition = sheet.TitleBlock.Definition

For Each textBox As Inventor.TextBox In titleBlock.Sketch.TextBoxes
    Dim propertyText As String = String.Format("Property='{0}'", propertyName)
    Dim formatedText As String = textBox.FormattedText

    If (formatedText.Contains(propertyText)) Then

        MsgBox(formatedText)

        ' TODO Update the formatedText with a smaller font size

        ' Set the new formated text
        'textBox.FormattedText = formatedText
    End If
Next

 

Jelte de Jong
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


Blog: hjalte.nl - github.com

0 Likes
Message 3 of 9

Michael.Navara
Advisor
Advisor

You have two possibilities

  1. Turn on the textBox border, then the text will be wrapped automaticallyMichaelNavara_0-1656360421764.png MichaelNavara_1-1656360637330.png

     

  2. You can modify the FormattedText or WidthScale property of TextBox. Then you can change the font size, width ratio etc. 

 

0 Likes
Message 4 of 9

DeptaM
Enthusiast
Enthusiast

Good day,
I would need a dialog box to open so I could adjust the text size.

Good day,
I would need a dialog box to open so I could adjust the text size. Basically, it could be applied to any line in the corner stamp, depending on what was set there.


Dim propertyName As String = "????" 'Set your property name here!

 

dialogové okno.png

0 Likes
Message 5 of 9

DeptaM
Enthusiast
Enthusiast

Dobrý den pane Navaro, díky za odpověď. V rohovém razítku je defaultně nastavená velikost písma 5mm a pokud je název dlouhý tak při zalomení textu přesahuje nahoru i dolů. Proto potřebuji velikost textu někdy změnit. Dělám to klasicky "Upravit definici", ale kdyby se to povedlo prostřednictvím iLogic, tak by to bylo komfortnější.

0 Likes
Message 6 of 9

Michael.Navara
Advisor
Advisor

To asi není problém, dá se to upravit ve vlastnosti FormattedText, která obsahuje definici i pro velikost textu. V podstatě je to totéž, jako úprava v definici razítka.

Here is the code sample how to change font size for textbox which displays the 'Title' property

Dim formattedTextFormat = "<StyleOverride FontSize='FONT_SIZE_HERE'><Property Document='drawing' PropertySet='Inventor Summary Information' Property='Title' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='2'>NÁZEV</Property></StyleOverride>"
Dim porpertyTitle = "Property='Title'"

Dim fontSize As Double = InputListBox("Font size [mm]", {2, 3.5, 5 })
fontSize /= 10 ' mm -> cm

Dim drawing As DrawingDocument = ThisDoc.Document
Dim sheet As Sheet = drawing.ActiveSheet
Dim titleBlock As TitleBlock = sheet.TitleBlock
Dim drawingSketch As DrawingSketch
titleBlock.Definition.Edit(drawingSketch)
For Each oTextBox As Inventor.TextBox In drawingSketch.TextBoxes
	If oTextBox.FormattedText.Contains(porpertyTitle) Then
		Dim formattedText = formattedTextFormat.Replace("FONT_SIZE_HERE", fontSize.ToString())
		oTextBox.FormattedText = formattedText
		titleBlock.Definition.ExitEdit(True)
		Return
	End If
Next
0 Likes
Message 7 of 9

DeptaM
Enthusiast
Enthusiast
0 Likes
Message 8 of 9

Michael.Navara
Advisor
Advisor

Asi je špatně ten formattedTextFormat. Bral jsem ho z defaultní DIN šablony a ta se odkazuje na vlastnost výkresu.

Lepší je si najít ten textbox a formattedText si vykopírovat. Potom nahradit velikost fontu tak, jak je to v tom příkladu (FontSize='FONT_SIZE_HERE'). Nebo změnit zdroj vlastnosti na Document='model'

 

Dim oTextBox As Inventor.TextBox = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchTextBoxFilter, "Pick TextBox")
Logger.Info(oTextBox.FormattedText)
0 Likes
Message 9 of 9

DeptaM
Enthusiast
Enthusiast

Dobrý den,

Vyměnil jsem tento první řádek, ale hlásí to chybu. Je pravda, že úplně nerozumím tomu, co píšete dál. Vyhazuje to chybu.

 

Dim formattedTextFormat = "<StyleOverride FontSize='FONT_SIZE_HERE'><Property Document='drawing' PropertySet='Inventor Summary Information' Property='Title' FormatID='{F29F85E0-4FF9-1068-AB91-08002B27B3D9}' PropertyID='2'>NÁZEV</Property></StyleOverride>"
Dim oTextBox As Inventor.TextBox = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchTextBoxFilter, "Pick TextBox")
Logger.Info(oTextBox.FormattedText)

 

0 Likes