Hello to all,
Little problem I have.
I want to make ‘TextOnCurve’ of kanji(Japanese characters) set randomly.
For this I make a Text3d…But please see the code It will be clearer than my explainations.
In order that you can use the same elements than me here are the file with the Kanjis
#from Blender import
from Blender import Window
from Blender import Material
from Blender import Scene
from Blender import Text3d
from Blender import Mathutils
from os import chdir
#Les variables
t4=0.0
b1=0
w1=[]
#Les get
chdir("H:/ici")
sc = Scene.GetCurrent()
myfont= Text3d.Font.Load('C:/WINDOWS/Fonts/msmincho.ttc')
f = open('ListJoyouKanji.txt','r')
#Boucle de creations de la list de kanjis
while b1<10:
#une boucle pour determiner au Hasard chaque kanji
a10=0
a11=Mathutils.Rand(1.0,1946.0)
while a10<a11:
t = f.readline()
a10=a10+1
w1.append(t,)
b1=b1+1
#transformation de la list en string, seul argument accepte
#par txt3d.setText()
string = ("").join(w1)
#determination de la couleur du Kanji
t1=Mathutils.Rand(0.0,1.0)
t2=Mathutils.Rand(0.0,1.0)
t3=Mathutils.Rand(0.0,1.0)
#creation du Kanji
txt3d = Text3d.New("MyText3d")
ob = sc.objects.new(txt3d)
txt3d.setFont(myfont)
txt3d.setWidth(1)
txt3d.setText(string)
txt3d.setDefaultResolution(6.0)
txt3d.setExtrudeDepth(0.1)
txt3d.setAlignment(Text3d.MIDDLE)
txt3d.setName("Kanjis")
ob.setLocation (0.0,0.0,10.0)
ob.setEuler(t4,0.0,0.0)
txt3d.setSize(4.0)
mat= Material.New('newMat')
mat.rgbCol = [t1,t2,t3]
ob.setMaterials([mat])
ob.colbits = 1
Window.RedrawAll()
Thanks varkenvarken!!!
You put me in the right direction.
And with this simple tutorial http://davidbau.com/python/learning.html
I grasp what was wrong.
There is surely a more easy way to do it but it’s works,
any corrections is welcomed.
#from Blender import
from Blender import Window
from Blender import Material
from Blender import Scene
from Blender import Text3d
from Blender import Mathutils
from os import chdir
import random
#Les variables
t4=0.0
b1=0
a10=0
a11=5
w1=[]
#Les get
chdir("H:/ici")
sc = Scene.GetCurrent()
myfont= Text3d.Font.Load('C:/WINDOWS/Fonts/msmincho.ttc')
f = open('ListJoyouKanji.txt','r')
#Travail sur le Kanji
t = f.read().split()
while a10<a11:
t2 = random.choice(t)
w1.append(t2)
a10=a10+1
s1 = ("").join(w1)
#determination de la couleur du Kanji
t1=Mathutils.Rand(0.0,1.0)
t2=Mathutils.Rand(0.0,1.0)
t3=Mathutils.Rand(0.0,1.0)
#creation du Kanji
txt3d = Text3d.New("MyText3d")
ob = sc.objects.new(txt3d)
txt3d.setFont(myfont)
txt3d.setWidth(1)
txt3d.setText(s1)
txt3d.setDefaultResolution(6.0)
txt3d.setExtrudeDepth(0.1)
txt3d.setAlignment(Text3d.MIDDLE)
txt3d.setName("Kanjis")
ob.setLocation (0.0,0.0,10.0)
ob.setEuler(t4,0.0,0.0)
txt3d.setSize(4.0)
mat= Material.New('newMat')
mat.rgbCol = [t1,t2,t3]
ob.setMaterials([mat])
ob.colbits = 1
Window.RedrawAll()