On 20/08/2015 at 18:07, xxxxxxxx wrote:
Hello,
I'm trying to write a script for to align letters according to their bounding box xsize.
(Like in arrange command but depending on previous objects xsize)
For example each polygonal letters A,B,C have different xsizes. I want something like polygonal kerning:)
Problem:
https://www.dropbox.com/s/betsyjksb1y6zm3/alphabet0.jpg?dl=0
How it should look like (more or less) :
https://www.dropbox.com/s/pdjt4cp3f2t5vl5/alphabet1.jpg?dl=0
And my testing scene :
https://www.dropbox.com/s/lb34jrvh30q8691/scene_for_testing_script.c4d?dl=0
My code is :
(Note: All objects are centered to object axis, zero PSR and they are under a null as shown in the image above.)
I tried to assign objects into an array. But I stock around positioning them.
Please show me an example or check my script and note that I'm a beginner.
(P.S. I should solve that issue with Python Script because it will be another part of my main script...)
Thanks a lot.
import c4d
from c4d import Vector
def find_objects(op, objectarray) :
objectarray.append(op)
for child in op.GetChildren() :
find_objects(child, objectarray)
def getsize(op,size) :
size = op.GetRad()*2
position = op.GetMp() + op.GetAbsPos()
xsize = int(size.x)
xsizearray.append((xsize))
def main() :
global xsizearray
objects = []
size = []
xsizearray = []
position = []
xpos = []
for obj in doc.GetObjects() :
find_objects(obj, objects)
count = len(objects)
for i in xrange (count) :
getsize(objects _,size)
print xsizearray _
objects _.SetRelPos(c4d.Vector(xsizearray _,0,0))
c4d.EventAdd()
main()