@@ -469,16 +469,24 @@ def set_resolution_from_entity(task_entity, doc=None):
469469 height : int = int (attrib ["resolutionHeight" ])
470470 pixel_aspect : float = attrib ["pixelAspect" ]
471471
472+ @contextlib .contextmanager
473+ def _unlocked_ratio (render_data ):
474+ """Temporarily unlock the ratio of the render resolution."""
475+ original = render_data [c4d .RDATA_LOCKRATIO ]
476+ render_data [c4d .RDATA_LOCKRATIO ] = False
477+ try :
478+ yield
479+ finally :
480+ render_data [c4d .RDATA_LOCKRATIO ] = original
481+
472482 rd = doc .GetFirstRenderData ()
473483 while rd :
474484 # Fix #20: Set the virtual resolution with user interaction so Redshift
475485 # still triggers some additional checks on the attribute change.
476- # TODO: Confirm whether we must unlock e.g. aspect ratio lock to allow
477- # changing the render resolution aspect ratio?
478- rd .SetParameter (
479- c4d .RDATA_XRES_VIRTUAL , width , c4d .DESCFLAGS_SET_USERINTERACTION )
480- rd .SetParameter (
481- c4d .RDATA_YRES_VIRTUAL , height , c4d .DESCFLAGS_SET_USERINTERACTION )
486+ with _unlocked_ratio (rd ):
487+ flag = c4d .DESCFLAGS_SET_USERINTERACTION
488+ rd .SetParameter (c4d .RDATA_XRES_VIRTUAL , width , flag )
489+ rd .SetParameter (c4d .RDATA_YRES_VIRTUAL , height , flag )
482490
483491 # Set pixel aspect ratio
484492 rd [c4d .RDATA_PIXELASPECT ] = pixel_aspect
0 commit comments