Skip to content

Commit 906b4ab

Browse files
committed
Merge branches 'bugfix/user_data_ignore_unsupported_values' and 'develop' of https://github.com/ynput/ayon-cinema4d into bugfix/user_data_ignore_unsupported_values
2 parents 459e7e2 + 52f39a7 commit 906b4ab

File tree

1 file changed

+21
-2
lines changed
  • client/ayon_cinema4d/api

1 file changed

+21
-2
lines changed

client/ayon_cinema4d/api/lib.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -481,10 +481,29 @@ def set_resolution_from_entity(task_entity, doc=None):
481481
attrib = task_entity["attrib"]
482482
width: int = int(attrib["resolutionWidth"])
483483
height: int = int(attrib["resolutionHeight"])
484+
pixel_aspect: float = attrib["pixelAspect"]
485+
486+
@contextlib.contextmanager
487+
def _unlocked_ratio(render_data):
488+
"""Temporarily unlock the ratio of the render resolution."""
489+
original = render_data[c4d.RDATA_LOCKRATIO]
490+
render_data[c4d.RDATA_LOCKRATIO] = False
491+
try:
492+
yield
493+
finally:
494+
render_data[c4d.RDATA_LOCKRATIO] = original
484495

485496
rd = doc.GetFirstRenderData()
486497
while rd:
487-
rd[c4d.RDATA_XRES] = width
488-
rd[c4d.RDATA_YRES] = height
498+
# Fix #20: Set the virtual resolution with user interaction so Redshift
499+
# still triggers some additional checks on the attribute change.
500+
with _unlocked_ratio(rd):
501+
flag = c4d.DESCFLAGS_SET_USERINTERACTION
502+
rd.SetParameter(c4d.RDATA_XRES_VIRTUAL, width, flag)
503+
rd.SetParameter(c4d.RDATA_YRES_VIRTUAL, height, flag)
504+
505+
# Set pixel aspect ratio
506+
rd[c4d.RDATA_PIXELASPECT] = pixel_aspect
507+
489508
rd = rd.GetNext()
490509
c4d.EventAdd()

0 commit comments

Comments
 (0)