Skip to content

Anim Picker: Issues Occurring on 4K Monitors / Improve high DPI scaling #563

@miquelcampos

Description

@miquelcampos

Reported on the forum: http://forum.mgear-framework.com/t/anim-picker-issues-occurring-on-4k-monitors/4944/20
with the following solution

from maya import cmds
import re


def replacement_function(match_object):
    """
    A function that receives an object matching a regular expression, performs calculations, and returns the resulting string after substitution.
    """

    key_part = match_object.group(1)
    value_str = match_object.group(2)
    new_value = float(value_str) * 0.65

    return f"{key_part}{new_value}"


def main():
    for sel in cmds.ls(sl=True):
        if not cmds.ls(f"{sel}.picker_datas"):
            continue

        source_string = cmds.getAttr(f"{sel}.picker_datas")
        pattern = re.compile(r"('text_size':\s*)(\d+\.?\d*)")
        modified_string = re.sub(pattern, replacement_function, source_string)

        #
        cmds.setAttr(f"{sel}.picker_datas", l=False)
        cmds.setAttr(f"{sel}.picker_datas", modified_string, type="string")
        cmds.setAttr(f"{sel}.picker_datas", l=True)

main()

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions