Hi,
Is there a way to convert joints to spline (limited to only 2 with Bezier Handles). By default, the joint to spline default C4D command convert them point by point per joint.
My main problem is what values to plug in the SetTangent
method so that the spline will conform to the previous shape despite only having two positions.
Is there a way around this?
Thank you
Here is an illustration of what I am after:
https://www.dropbox.com/s/9riwmyevlq9g6gl/c4d083_convert_joints_to_spline.jpg?dl=0
If you want the actual file you can check it here:
https://www.dropbox.com/s/gx5yylf2b423irh/c4d083_convert_joints_to_spline.c4d?dl=0
Here is my code so far:
import c4d
from c4d import gui
#Welcome to the world of Python
def GetNextObject(op):
if op==None:
return None
if op.GetDown():
return op.GetDown()
return op.GetDown()
def IterateHierarchy(op):
if op is None:
return
count = 0
objList = []
while op:
count += 1
objList.append(op)
op = GetNextObject(op)
return objList
def createSpline(numPoints, pointPosition):
spline = c4d.BaseObject(c4d.Ospline)
spline.ResizeObject(numPoints)
for point in range(numPoints):
spline.SetPoint(point, pointPosition[point])
spline[c4d.SPLINEOBJECT_CLOSED] = False
spline.Message(c4d.MSG_POINTS_CHANGED)
doc.InsertObject(spline)
c4d.EventAdd()
objList = IterateHierarchy(op)
objLen = len(objList)
objListPosition = []
for obj in objList:
objListPosition.append(obj.GetMg().off)
createSpline(objLen, objListPosition)
Thanks to the C4D documentation for the iterate codes and the Scott Ayers to the Create Spline code