This is just a matter of programming style, but VB does have a switch/case option called select/case. The difference is it looks like it does not have "fall through". It can be more graceful and easier to read.
Original Message:
Sent: 11-22-2023 15:14
From: John Robbins
Subject: Setting font material without using tags
I figured out what was happening. At one point I had multiple layers, one for each selectable style, in the font's face thinking I would use the ".Enable" command. Removing the extra layers resolved the issue. My final script is below. Thank you everyone for your help!
dim txtStyle as xpTextObject
dim fontTitle as xpFont
dim fontStyle as xpFontLayerAttrib
dim matFont as xpMaterial
Self.Project.GetFontByName("FS Title", fontTitle)
Self.GetObjectByName("Style", txtStyle)
fontTitle.GetLayerAttribByName("Face", fontStyle)
fontStyle.GetMaterial(matFont)
If (txtStyle.Text = "Normal" OR txtStyle.Text = "Elections") Then
matFont.ColorDiffuse.Update(0,47,124,100)
Else If txtStyle.Text = "Breaking" Then
matFont.ColorDiffuse.Update(156,2,1,100)
Else If txtStyle.Text = "Sports" Then
matFont.ColorDiffuse.Update(80,94,101,100)
End If
------------------------------
John Robbins
Graham Media Group INC
Original Message:
Sent: 11-22-2023 09:59
From: Simon Redmile
Subject: Setting font material without using tags
could you just grab the font material by its name and then just adjust it like you would any other material?
------------------------------
Simon Redmile
Senior Graphic Programmer & Designer
Ross Video
Bristol United Kingdom
Original Message:
Sent: 11-22-2023 09:57
From: John Robbins
Subject: Setting font material without using tags
Thank you. You're right in that I forgot to declare the material. However, upon further testing I found that the "Face" attribute does not seem to be setting the material. I can declare the other font attributes (border, neon, stroke, shadow) and see the color change as expected, but the "Face" attribute does not set. Update code below. Note ".Enabled" and ".Size" were used to test the other attributes to verify the code was working.
dim txtStyle as xpTextObject
dim fontTitle as xpFont
dim fontStyle as xpFontLayerAttrib
dim matFont as xpMaterial
Self.Project.GetFontByName("FS Title", fontTitle)
Self.GetObjectByName("Style", txtStyle)
fontTitle.GetLayerAttribByName("Face", fontStyle)
'fontStyle.Enabled = True
'fontStyle.Size = 50
fontStyle.GetMaterial(matFont)
If (txtStyle.Text = "Normal" OR txtStyle.Text = "Elections") Then
matFont.ColorDiffuse.Update(0,47,124,100)
Else If txtStyle.Text = "Breaking" Then
matFont.ColorDiffuse.Update(156,2,1,100)
Else If txtStyle.Text = "Sports" Then
matFont.ColorDiffuse.Update(80,94,101,100)
End If
------------------------------
John Robbins
Graham Media Group INC
Original Message:
Sent: 11-22-2023 09:23
From: Azathoth Son of Cthulhu
Subject: Setting font material without using tags
You are setting the ColorDiffuse on the fontLayer, not the material. Also, your material is not declared.
dim txtStyle as xpTextObject
dim fontTitle as xpFont
dim fontStyle as xpFontLayerAttrib
dim matFont as xpMaterial
Self.Project.GetFontByName("FS Title", fontTitle)
Self.GetObjectByName("Style", txtStyle)
fontTitle.GetLayerAttribByName("Face", fontStyle)
fontStyle.GetMaterial(matFont)
If (txtStyle.Text = "Blue" OR txtStyle.Text = "Elections") Then
matFont.ColorDiffuse.Update(0,47,124,100)
Else If txtStyle.Text = "Red" Then
matFont.ColorDiffuse.Update(156,2,1,100)
Else If txtStyle.Text = "Sports" Then
matFont.ColorDiffuse.Update(80,94,101,100)
End If
Use Self.Project instead of Engine because Engine can affect materials from one Scene to another.
Fingers crossed.
------------------------------
Azathoth
Son of Cthulhu
Original Message:
Sent: 11-22-2023 09:03
From: John Robbins
Subject: Setting font material without using tags
Thank you for the suggestion. I tried that with no luck.
------------------------------
John Robbins
Graham Media Group INC
Original Message:
Sent: 11-20-2023 12:01
From: Azathoth Son of Cthulhu
Subject: Setting font material without using tags
Instead of using "Engine.GetFontByName" try using "Self.Project.GetFontByName".
If that change works, I cannot explain why it does; it just does. It fixed a problem when I was making materials.
------------------------------
Azathoth
Son of Cthulhu
Original Message:
Sent: 11-20-2023 11:10
From: John Robbins
Subject: Setting font material without using tags
I'm trying to set the color of a font's material without using tags. I have a project where multiple fonts in different scenes will change color based on a selected style. The goal is to create a single font where the size, leading, and kerning are set and a script will change the color. I'm trying to avoid creating multiple fonts for a scene, where I would them have to update each font if there is change. I have a script that I'm testing, but so far it is not working. Any help would be appreciated, thank you!
dim txtStyle as xpTextObject
dim fontTitle as xpFont
dim fontStyle as xpFontLayerAttrib
Engine.GetFontByName("FS Title", fontTitle)
Self.GetObjectByName("Style", txtStyle)
fontTitle.GetLayerAttribByName("Face", fontStyle)
fontStyle.GetMaterial(matFont)
If (txtStyle.Text = "Blue" OR txtStyle.Text = "Elections") Then
fontStyle.ColorDiffuse.Update(0,47,124,100)
Else If txtStyle.Text = "Red" Then
fontStyle.ColorDiffuse.Update(156,2,1,100)
Else If txtStyle.Text = "Sports" Then
fontStyle.ColorDiffuse.Update(80,94,101,100)
End If
------------------------------
John Robbins
Graham Media Group INC
------------------------------