TextonCurve

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


And here a page with fonts to Download for exemple
http://www.wazu.jp/gallery/Fonts_Japanese.html

My problem is that my string is a column, not a lign.

I found explainations
but don’t know how to use it.

ici

Voici le code


#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()

Í have not tested your script but the line


t = f.readline()

couldn’t that be the problem? Because readline() will NOT strip a newline if its there.

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()

i tried to run it but get an erro on lline 21 ?

is there a file your trying to load with this ?

Thanks

Hello RickyBlender,
this two elements

myfont= Text3d.Font.Load(‘C:/WINDOWS/Fonts/msmincho.ttc’)

f = open(‘ListJoyouKanji.txt’,‘r’)

refere to external data,

First the japanese font. msmincho is a really commun one but see here

http://www.wazu.jp/gallery/Fonts_Japanese.html

and after that the text contening the kanjis,

you get it here

and don’t forget to change the directory where you will put the upper file.

chdir(“H:/ici”)

H was a usb key you can put it on C for exemple.