Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resize font inside a CATDrawing text box 1

Status
Not open for further replies.

LucasC

Automotive
Feb 18, 2019
157
US
Im trying to resize some font in a V5 textbox to a size different than the rest of the textbox.

Example is: "Sheet 1(size3.5) of(size1.5) 20(size3.5)"


V5 is defaulted to size 3.5 so no problem there. when i try to resize the "of" the method in the documentation does not function properly. I've tried web searches, the examples given do not work either.

Code:

(I need the orange highlighted resized)

Dim SheetNum
Set SheetNum = TitleBlockTexts.GetItem("TitleBlock_Text_Sheet")

'TitleBlock_Text_Sheet is the name of the textbox I'm editing

Dim SheetOfText As Double
SheetOfText = "OF"

Dim OfText As Double
OfText = SheetOfText.Size = 1.5

SheetNum.Text = Title_Block.Current_Sheet_TB.Value + " " + [highlight #F57900]OfText[/highlight] + " " + Title_Block.Total_Sheet_TB.Value

Ive tried:

SheetOfText.setfontsize 0,0,1.5 doesn't work

SheetOfText.text.font.size = 1.5 doesn't work

OfText.changefontsize 0,0,1.5 (also with a dim assigned 1.5 value)

I usually get Object required or invalid qualifier when trying different things


 
Replies continue below

Recommended for you

Are you able to change the size of a regular text with a simple macro ? That's the first thing I tried quickly and for the moment I'm not even able to change the size or color (I tried using a DrawingText variable to define my object and then access the DrawingText.TextProperties.Fontsize but this method doesn't work.
From what I saw on a regular text already defined with 2 different sizes inside the textbox, the VBA doesn't "see" the different sizes inside the same object.

However I'm just starting to explore Catia VBA and maybe there are some more advanced functions or method but I think the first step is to find the way to change the text size and color, then find a way to combine that in a single object.
 
I don't need 2 different sizes in 1 object, I just need OfText to be a smaller size.

OfText.size = 1.5 or something. This is where I'm stuck. literally the last line of the macro...
 
This is from the documentation and what I tried to use first:

o Property FontSize( ) As double

Returns or sets the font size of the drawing text.
Example:
This example sets the MyText drawing text font size to 3.5.
iFontSize = 3.5
MyText.SetFontSize 0, 0, iFontSize

 
your SheetNum is a DrawingText, you can apply .SetFontSize to it

your SheetOfText is a string

so what you need is to change the size of SheetOfText string inside SheetNum using

Code:
SheetNum.Text = Title_Block.Current_Sheet_TB.Value + " " + OfText + " " + Title_Block.Total_Sheet_TB.Value

start = Len(Title_Block.Current_Sheet_TB.Value + " " ) +1  [i](not sure about the +1, you find out and tell us)[/i]

number = Len (OfText )

SheetNum.SetFontSize start, number , 3.5

Eric N.
indocti discant et ament meminisse periti
 
LucasC said:
I don't need 2 different sizes in 1 object, I just need OfText to be a smaller size.

I understood that you have only one textbox (text tool in Catia, which is a DrawingText object in VBA) but you want 2 different sizes inside the same textbox.

Anyway, itsmyjob found the way to change the size. Digging on my side I found that you can also use SetParameterOnSubString on DrawingText objects but it seems heavy because you can't change multiple parameters at once (however it works fine, I was able to change the color of substrings inside the text box).

With the same objects that you use (and itsmyjob used also) you can for instance change the color like this :

Code:
Dim SheetNum
Set SheetNum = TitleBlockTexts.GetItem("TitleBlock_Text_Sheet")

Dim colBlue as Long
colBlue = 65535

SheetNum.Text = Title_Block.Current_Sheet_TB.Value + " " + OfText + " " + Title_Block.Total_Sheet_TB.Value

start = Len(Title_Block.Current_Sheet_TB.Value + " " ) +1  (not sure about the +1, you find out and tell us)

number = Len (OfText )

SheetNum.SetParameterOnSubString catColor, start, number, colBlue 'the text from "start" position and on "number" characters will be blue

I was not able to change the size with this method even if it's suppose to work with CatFontSize enum instead of catColor.
 
@itsmyjob, your solution worked.
the +1 is the starting character of the size change. In example, in a string of 123456 (with 2 and 5 = " " in my code) +1 makes "3" change size ending with "4"(since sheetoftext = 2 characters in my code) +2 will make "4" and "5" change size. Thank you very much. It seems my mistake was using integers instead of objects with SetFontSize


Code:
Dim StringStart
StringStart = Len(Title_Block.Current_Sheet_TB.Value + " ") + 1

Dim StringLength
StringLength = Len(SheetOfText)

SheetNum.SetFontSize StringStart, StringLength, 1.5 [COLOR=#8AE234]'1.5 is font size[/color]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top