File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -467,10 +467,29 @@ def set_resolution_from_entity(task_entity, doc=None):
467467 attrib = task_entity ["attrib" ]
468468 width : int = int (attrib ["resolutionWidth" ])
469469 height : int = int (attrib ["resolutionHeight" ])
470+ pixel_aspect : float = attrib ["pixelAspect" ]
471+
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
470481
471482 rd = doc .GetFirstRenderData ()
472483 while rd :
473- rd [c4d .RDATA_XRES ] = width
474- rd [c4d .RDATA_YRES ] = height
484+ # Fix #20: Set the virtual resolution with user interaction so Redshift
485+ # still triggers some additional checks on the attribute change.
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 )
490+
491+ # Set pixel aspect ratio
492+ rd [c4d .RDATA_PIXELASPECT ] = pixel_aspect
493+
475494 rd = rd .GetNext ()
476495 c4d .EventAdd ()
You can’t perform that action at this time.
0 commit comments