Hello,
I'm pretty new to C4D and I am tasked with creating a script.
What I want to achieve is pretty basic, in theory, but I have been struggling so I hope you'll be able to provide me with a solution.
I want to toggle the visibility of an object and keyframe that parameter.
Here's what I've tried so far:
import c4d
from c4d import gui
def main():
# c4d.CallCommand(12410)
curTime = doc.GetTime()
fps = doc[c4d.DOCUMENT_FPS]
obj = doc.SearchObject('Tshirt_white')
print(obj)
print(curTime.GetFrame(fps))
# setting visibility ON
obj[c4d.ID_BASEOBJECT_VISIBILITY_EDITOR] = 0
# getting the animation track for the object's visibility'
visTrack = c4d.CTrack(obj, c4d.ID_BASEOBJECT_VISIBILITY_EDITOR)
# getting the curve? of the track
curve = visTrack.GetCurve()
# adding a keyframe to the curve of the track
keyDict = curve.AddKey (curTime)
# no idea what's going on here
visTrack.FillKey (doc, obj, keyDict["key"])
obj.InsertTrackSorted(visTrack)
Some of these comments might be wrong as I'm not entirely sure what I'm doing and the documentation is not a lot of help.
This does change the value of the editor visibility and toggles the keyFrame indicator orange. Orange is not really the color I want though as it doesn't save the value if I move up one frame and come back.
Any suggestions would be appreciated.