PythonGenerater and Object not alive
-
On 24/10/2015 at 16:19, xxxxxxxx wrote:
Hello everybody,
the code below is just a light version for showing the problem.
Instead ofobj.SetPoint(0, obj.GetPoint(0)+c4d.Vector(100,100,100))
there is alot of calculating. That´s why I want the reference object to be checked if it is dirty. The easiest way i found is the GetAndCheckHierarchyClone()-method, because it returns True or False for nested objects like SplineMask as well. Howevery...
With the following code everything works fine as long as the reference object ist dirty. Otherwise the console tells me 'ReferenceError: the object 'c4d.SplineObject' is not alive'. But
print op.GetCache()
prints '<c4d.SplineObject object called 'Spline Mask/Spline' with ID 5101 at 0x00000000113B27F0>'.
What is wrong?
import c4d #Welcome to the world of Python def main() : first = op.GetDown() dic = op.GetAndCheckHierarchyClone(hh, first, c4d.HIERARCHYCLONEFLAGS_0, False) if dic["dirty"] or op.IsDirty(c4d.DIRTY_DATA) or not op.GetCache() : obj = c4d.utils.SendModelingCommand(c4d.MCOMMAND_CURRENTSTATETOOBJECT,[first],c4d.MODELINGCOMMANDMODE_ALL,c4d.BaseContainer(),doc)[0] if not obj.CheckType(c4d.Ospline) : return None else: obj.SetPoint(0, obj.GetPoint(0)+c4d.Vector(100,100,100)) else: print op.GetCache() obj = op.GetCache() first.Touch() return obj
OptimizeCache and ResetOnFrame0 are unchecked.
Greetings
rownn -
On 25/10/2015 at 05:37, xxxxxxxx wrote:
Ok, thing I got it.
Instead
obj = op.GetCache()
I use
obj = op.GetCache().GetClone()
now and it seems to work.