Keyframe Texture Tag with no material
-
Hi,
I feel a bit stupid. I'm trying to create keyframes on a Texture tag. Everything's fine, until I try to have a key with no assigned material in between (basically
SetGeData(..., None)
). Then I end up with keyframes, which seem to look right. They show nothing for the material. But the tag behaves, as if the key is not there and shows the material from the frame shown before (it does not matter, if that's the preceding frame or any other). As if the key wasn't there at all.In user interface this seems to work and the object correctly shows no material on such frames.
While writing this, I seem to have the same issue with the BaseLink in Instance objects as well.
I must be doing something awfully wrong. I also tried
FlushData()
in these cases, but this didn't help either.TL;DR: How do I set a BaseLink parameter keyframe to an empty link?
Any help would be much appreciated.
Thanks in advance,
Andreas -
Hi @a_block there is currently an issue were the internal conversion of a GeData fail if this is None (this will be fixed within the next Cinema 4D version).
As a workaround you can call SetGeData with a temporary Material. Then you delete the object, therefor the BaseLink will then be empty.
import c4d def main(): if not op: return tag = op.GetTag(c4d.Ttexture) track = tag.GetFirstCTrack() if track.GetDescriptionID()[0].id != c4d.TEXTURETAG_MATERIAL: raise RuntimeError("'Material' track not found") curve = track.GetCurve(c4d.CCURVE_CURVE) if curve.GetKeyCount() < 1: raise RuntimeError("Curve has no keys.") key = curve.GetKey(0) mat = c4d.BaseMaterial(c4d.Mmaterial) key.SetGeData(curve, mat) mat.Remove() c4d.EventAdd() # Execute main() if __name__=='__main__': main()
Cheers,
Maxime. -
Hi Maxime,
thanks for the prompt help, much appreciated.
I like your thinking with the workaround.This topic can be marked solved, unless you want to keep it open to add not on the fix later on.
Cheers,
Andreas -
Thinking about it, is the
mat.Remove()
needed at all? After all the material is not inserted in the usual way in this case, it should get wiped when going out of context anyway. -
@a_block said in Keyframe Texture Tag with no material:
Thinking about it, is the
mat.Remove()
needed at all? After all the material is not inserted in the usual way in this case, it should get wiped when going out of context anyway.Right, but then I need to explain garbage collector for next readers. So the garbage collector is a mechanism by Python that have the duty to clean memory. This is usually done at the end of the scope. Since we do not add the material into a document, this is the python variable, who take care of holding this material. If you delete the variable, the Material is then automatically deleted.
Cheers,
Maxime. -
Sorry, for causing extra work