import c4d
from c4d import gui, utils
#Welcome to the world of Python
globrot = True
upVector = c4d.Vector(1,1,0)
rotVector = c4d.Vector(utils.Rad(45), 0, 0)
def main():
rotmgp = utils.HPBToMatrix(rotVector)
rotmgm = utils.HPBToMatrix(rotVector - c4d.Vector(utils.Rad(180), 0, 0))
if op:
if globrot:
for id, pvec in enumerate(op.GetAllPoints()):
tng = op.GetTangent(id)
op.SetTangent(id,
rotmgp.MulV(tng["vl"]),
rotmgp.MulV(tng["vr"]))
else:
for id, pvec in enumerate(op.GetAllPoints()):
dtng = op.GetTangent(id)
tng = (dtng["vr"] - dtng["vl"]).GetNormalized()
nrm = (tng % upVector).GetNormalized()
brnm = (nrm % tng).GetNormalized()
vmg = c4d.Matrix(pvec, nrm, brnm, tng)
op.SetTangent(id,
(vmg * rotmgm).MulV(c4d.Vector(dtng["vl"].GetLength(),0,0)),
(vmg * rotmgp).MulV(c4d.Vector(dtng["vr"].GetLength(),0,0)))
op.Message(c4d.MSG_POINTS_CHANGED)
c4d.EventAdd()
if __name__=='__main__':
main()