THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 18/04/2012 at 02:09, xxxxxxxx wrote:
Tangents are not swapped so here is the code for the fixed OrientObject() method:
@staticmethod
def OrientObject(op, plane, reverse) :
pcnt = op.GetPointCount()
points = op.GetAllPoints()
if plane>=c4d.PRIM_PLANE_ZY:
if plane==c4d.PRIM_PLANE_ZY:
for i, point in enumerate(points) :
x = -point.z
y = point.y
z = point.x
op.SetPoint(i, c4d.Vector(x, y, z))
h = op.GetTangent(i)
vl = h["vl"]
vr = h["vr"]
vl = c4d.Vector(-vl.z, vl.y, vl.x)
vr = c4d.Vector(-vr.z, vr.y, vr.x)
op.SetTangent(i, vl, vr)
elif plane==c4d.PRIM_PLANE_XZ:
for i, point in enumerate(points) :
x = point.x
y = -point.z
z = point.y
op.SetPoint(i, c4d.Vector(x, y, z))
h = op.GetTangent(i)
vl = h["vl"]
vr = h["vr"]
vl = c4d.Vector(vl.x, -vl.z, vl.y)
vr = c4d.Vector(vr.x, -vr.z, vr.y)
op.SetTangent(i, vl, vr)
if reverse:
to = pcnt/float(2)
if pcnt%2:
to+=1
for i, point in enumerate(points[:int(to)]) :
op.SetPoint(i, points[pcnt-1-i])
op.SetPoint(pcnt-1-i, point)
h = op.GetTangent(i)
tangents = op.GetTangent(pcnt-1-i)
# Move from right to left
vr, vl = tangents["vl"], tangents["vr"]
op.SetTangent(i, vl, vr)
op.SetTangent(pcnt-1-i, h["vr"], h["vl"])
op.Message(c4d.MSG_UPDATE)
And MoveHandle() :
def MoveHandle(self, op, undo, mouse_pos, hit_id, qualifier, bd) :
if hit_id==c4d.NOTOK: return False
src = undo.GetDataInstance()
dst = op.GetDataInstance()
handle_dir = c4d.Vector(1.0, 0.0, 0.0)
handle_dir = DoubleCircleData.SwapPoint(handle_dir, src.GetLong(c4d.PRIM_PLANE))
val = 0 #tm.off.Dot(handle_dir) # FIX
cut = utils.FCut(src.GetReal(c4d.PYCIRCLEOBJECT_RAD)+val, 0.0, sys.maxint)
dst.SetReal(c4d.PYCIRCLEOBJECT_RAD, cut)
return True