Thanks a lot for the explanation!
I replaced the plugin id with a user data and it seems to work ok. Still trying to figure out the matrix on the other thread though.
Here is the adapted code:
def main(): ID_PYGEN_DIRTY_CACHE = op[c4d.ID_USERDATA,3] linked_object = op[c4d.ID_USERDATA, 2] # Get the last cached dirty count and the current dirty count. lst_dcount = ID_PYGEN_DIRTY_CACHE cur_dcount = linked_object.GetDirty(c4d.DIRTYFLAGS_ALL) if linked_object is None: return c4d.BaseList2D(c4d.Onull) # Return the linked object if its dirty count exceeds our cached dirty # count or there is no cached dirty count. if lst_dcount is None or lst_dcount < cur_dcount or op.GetCache() is None: # Cache the current dirty count. op[c4d.ID_USERDATA,3] = cur_dcount clone = linked_object.GetClone(c4d.COPYFLAGS_NO_HIERARCHY) clone.SetMg(c4d.Matrix()) print "Built cache" return clone # Otherwise return the cache. else: print "Returned cache" return op.GetCache()And the file:
python_dirtyState_0001.c4d