Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Processing frame by frame from Script Manager
# NOTE: this script stops when esc key pressed not to freeze c4d because of some heavy codes.
import c4d
from c4d import gui
def frame( f ):
# exec some processing..
def escPressed():
bc = c4d.BaseContainer()
rs = gui.GetInputState( c4d.BFM_INPUT_KEYBOARD, c4d.KEY_ESC, bc )
if rs and bc[ c4d.BFM_INPUT_VALUE ]:
return True
return False
def main():
doc = c4d.documents.GetActiveDocument()
fps = doc[ c4d.DOCUMENT_FPS ]
minTime = doc[ c4d.DOCUMENT_MINTIME ].GetFrame( fps )
maxTime = doc[ c4d.DOCUMENT_MAXTIME ].GetFrame( fps )
f = 0
for f in range( minTime, maxTime ):
doc.SetTime( c4d.BaseTime( f, fps ) )
c4d.GeSyncMessage( c4d.EVMSG_TIMECHANGED )
c4d.EventAdd( c4d.EVENT_ANIMATE )
frame( f )
if escPressed():
gui.MessageDialog( "%i - %i frames processed." % (minTime, f) )
if __name__=='__main__':
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment