9
$\begingroup$

I want the text to have this sort of colouring enter image description here

And this is the text.enter image description here

$\endgroup$
1
  • 5
    $\begingroup$ Hello and welcome to BSE. Create two materials, then select the letters in edit mode (shift+keyboard arrows) and assign them to the corresponding material in the material panel $\endgroup$
    – lemon
    Mar 3, 2017 at 7:06

1 Answer 1

20
$\begingroup$

Create two materials, set their colors.

Then enter edit mode in your text.

Select the wanted letters Shiftkeyboard arrows, and assign them to the wanted material.

enter image description here

General indications to do that using Python:

import bpy

# Get the text
o = bpy.data.objects['Text']

# Get all the characters descriptions
characters = [c for c in o.data.body_format.items()]

# Look at it:
for character in characters: 
    # The index of the char
    print(character[0])
    # The format to the char
    print(character[1])

# Get the third char (for instance)
my_char = characters[2]

# Get its format
my_char_format = my_char[1]

# Assign it a (existing) material index
my_char_format.material_index = 1
$\endgroup$
9
  • 2
    $\begingroup$ This is awesome. Didn't know you can assign materials to a text like this. Learned something new today :). Thnx. $\endgroup$
    – Paul Gonet
    Mar 3, 2017 at 12:08
  • 1
    $\begingroup$ @PaulGonet, Blender coders are awesome... $\endgroup$
    – lemon
    Mar 3, 2017 at 12:23
  • 1
    $\begingroup$ What did you use to grab your screen, with the keyboard labels in the corner and stuff? $\endgroup$
    – Jason C
    Mar 3, 2017 at 15:32
  • 1
    $\begingroup$ @JasonC, it is an addon for the 3D View, called 'screencast keys' $\endgroup$
    – lemon
    Mar 3, 2017 at 16:12
  • $\begingroup$ That was great but after meshing the text, the color somehow reverts back to red $\endgroup$ Mar 5, 2017 at 13:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.