On 12/06/2016 at 13:12, xxxxxxxx wrote:
I'm trying to generate MoSpline with Python Generator, but nothing happens.
What's may be wrong?
def main() :
if not op.GetDown() : return None
obj = op.GetDown()
source = obj.GetClone()
op.GetDown()[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 1
op.GetDown()[c4d.ID_BASEOBJECT_VISIBILITY_RENDER] = 1
if source.CheckType(c4d.Ospline) is False: #Parametric object
source = obj.GetRealSpline()
newSpline = c4d.BaseObject(c4d.Ospline)
newSpline = c4d.SplineObject(source.GetPointCount(), c4d.SPLINETYPE_BEZIER)
for index,position in enumerate(source.GetAllPoints()) :
tangent = source.GetTangent(index)
newSpline.SetTangent(index, tangent["vl"], tangent["vr"])
newSpline[c4d.SPLINEOBJECT_CLOSED] = 0
MoSpline = c4d.BaseObject(440000054)
MoSpline[c4d.MGMOSPLINEOBJECT_GROWTH_START] = op[c4d.ID_USERDATA,1]
MoSpline[c4d.MGMOSPLINEOBJECT_MODE] = 1
MoSpline[c4d.MGMOSPLINEOBJECT_SOURCE_SPLINE] = newSpline
#return newSpline.GetClone() # it works
return MoSpline.GetClone() # isn't works
Звуковая функция ограничена 100 символами
Настройки : История : Справка : Обратная связьЗакрыть
On 13/06/2016 at 03:06, xxxxxxxx wrote:
there are several issues with your code. First you should check the return value of GetRealSpline() since this function can return None.
Second, you allocate the "newSpline" two times: once with "BaseObject", then with "SplineObject".
Third, you insert the "newSpline" object into nothing, so the garbage collection will delete it. You reference the "newSpline" object in your MoSpline but this is only a BaseLink reference. The MoSpline does not take the ownership of the "newSpline". The "newSpline" will not become part of the document and a link to an object that is not part of a document cannot be resolved. So you have to make the "newSpline" part of the document. You could try to make it the child object of the MoSpline object.
Finally, you return the clone of the MoSpline object. Why are you doing that?