Python script not working from R22 to R23, any ideas why?


#1

I have a Python script called Zero Axis To Parent which, as the name suggests, zeroes the axis of a geometry object to its parent. It’s worked fine up until R22, but no longer works in R23. Does anyone know why and how I can fix it? The script is below…


import c4d

from c4d import Vector as V

def main():

if op is None or not op.CheckType(c4d.Opoint):
    return False

ObjMatrix = op.GetMg()

ObjPoints = op.GetAllPoints()

Pcount = op.GetPointCount()

doc.StartUndo()
doc.AddUndo(c4d.UNDOTYPE_CHANGE, op)
op.SetAbsRot(V(0))
op.SetAbsPos(V(0))
op.Message(c4d.MSG_UPDATE)
NewMatrix = op.GetMg()

for point in xrange(Pcount):
    op.SetPoint(point,~NewMatrix*ObjMatrix*ObjPoints[point])

op.Message(c4d.MSG_UPDATE)
c4d.EventAdd()
doc.EndUndo()

if name==‘main’:

main()

#2

Try this:

import c4d
from c4d import Vector as V

def main():
    if op is None or not op.CheckType(c4d.Opoint):
        return False

    ObjMatrix = op.GetMg()
    ObjPoints = op.GetAllPoints()
    Pcount = op.GetPointCount()
    doc.StartUndo()
    doc.AddUndo(c4d.UNDOTYPE_CHANGE, op)
    op.SetAbsRot(V(0))
    op.SetAbsPos(V(0))
    op.Message(c4d.MSG_UPDATE)
    NewMatrix = op.GetMg()

    for point in range(Pcount):
        op.SetPoint(point,~NewMatrix*ObjMatrix*ObjPoints[point])

    op.Message(c4d.MSG_UPDATE)
    c4d.EventAdd()
    doc.EndUndo()
if __name__=='__main__':
    main()

xrange is now range in R23


#3

Oh man, thank you so much! Works again.