Center Axis with Python
-
On 21/06/2015 at 01:13, xxxxxxxx wrote:
Hello,
I'm trying to make a xpresso setup, as a beginner in python I have a trouble to set axis to center of an object. (For example by default if we convert a text into an editable spline its align stays as left I want its axis to set center automatically. Because other calculations are being made as it is in center)
As I understand SetMg should be matrix value but I could not convert my vector data to matrix.
And of course it should only run for once. (Sorry if these questions are silly, as I said I'm a beginner:)
Here is my code; (I'm using it as python node in xpresso )import c4d
def setAxis(obj) :
size = obj.GetRad()*2
pos = obj.GetMp() + obj.GetAbsPos()
for i, point in enumerate(obj.GetAllPoints()) :
obj.SetPoint(i, point * pos)
obj.Message (c4d.MSG_UPDATE)
obj.SetRelPos(pos) #????
obj.SetMg(pos) ### ??? Axis should be in center of an object but how???def main() :
global Source
if Source.CheckType(c4d.Opoint) :
setAxis(Source)
doc.EndUndo()
c4d.EventAdd()