Troubleshooting Safe Frame Calculations Across Different Takes in Cinema 4D
-
Hi,
I want to calculate the safe frame value for all takes, where each take has a different camera and possibly different render settings. If I manually change a take and run my code, it returns the same safe frame for all other takes as for the currently selected one, which is incorrect in my case. It seems the values used for safe frame calculations are not being updated when I iterate through takes via code. What am I missing? I've attached a simple test scene to test the code.
Best regards,
Tomaszimport c4d def grab_children_of_main_take(take_data): children = [] mainTake = take_data.GetMainTake() take = mainTake.GetDown() while take is not None: children.append(take) take = take.GetNext() return children def get_safe_frame_for_the_current_per_take(doc): bd = doc.GetRenderBaseDraw() safeframe = bd.GetSafeFrame() print(safeframe) def main(): c4d.CallCommand(13957) # Clear Console doc = c4d.documents.GetActiveDocument() take_data = doc.GetTakeData() if take_data is None: raise RuntimeError("Failed to retrieve the take data.") children_of_main_take = grab_children_of_main_take(take_data) print("Returned : " + str(len(children_of_main_take)) + " children of main take") for child_take in children_of_main_take: take_data.SetCurrentTake(child_take) doc.ExecutePasses(bt=None, animation=True, expressions=True, caches=True, flags=c4d.BUILDFLAGS_NONE) current_camera = child_take.GetCamera(take_data) print("\n--------------------------------------------------") print(f"Checking take {child_take.GetName()} with camera {current_camera.GetName()}") get_safe_frame_for_the_current_per_take(doc) if __name__ == '__main__': c4d.CallCommand(13957) # Clear Console main()
-
Hi Tomasz,
You need to use function DrawViews() to update the document BaseDraw that is used for SafeFrame calculation. ExecutePasses updates the document but does not initiate view redraw.
Just try your script with the following line instead of ExecutePasses function call:
c4d.DrawViews(c4d.DRAWFLAGS_ONLY_ACTIVE_VIEW | c4d.DRAWFLAGS_NO_THREAD | c4d.DRAWFLAGS_STATICBREAK)
You can have a closer look to our basedocument_animate_r13.py example.
By the way, it also wouldn't hurt to call c4d.EventAdd() at the very end of your script to initiate GUI update.
Cheers,
Ilia -