Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setMin / setMax no longer working in 1.4.0 #477

Closed
briankendall opened this issue Jul 3, 2024 · 2 comments
Closed

setMin / setMax no longer working in 1.4.0 #477

briankendall opened this issue Jul 3, 2024 · 2 comments

Comments

@briankendall
Copy link

The setMin and setMax methods on pymel.core.general.Attribute no longer appear to work in PyMEL 1.4.0. When calling them they silently fail, and don't actually set a minimum or maximum. Example:

import pymel.core as pm
node = pm.spaceLocator()
node.addAttr("testAttr", at="double", keyable=True)
node.testAttr.setMin(0.0)
node.testAttr.setMax(1.0)
print(node.testAttr.getMin(), node.testAttr.getMax())

In PyMEL 1.1.0 / Maya 2020, this correctly prints (0.0, 1.0).

In PyMEL 1.4.0, it incorrectly prints None None.

I'm not sure at which point exactly this bug was introduced.

@iamsleepy
Copy link
Contributor

Find the pymel/core/general.py

There are two extra overloads after the setRange implementation.

e.g.,

  @overload
    def setRange(self, range):
        # type: (Tuple[Optional[float], Optional[float]]) -> None
        pass

    @overload
    def setRange(self, newMin, newMax):
        # type: (Optional[float], Optional[float]) -> None
        pass

    def setRange(self, *args):
        # type: (*Union[Optional[float], Tuple[Optional[float], Optional[float]]]) -> None
        """provide a min and max value as a two-element tuple or list, or as two arguments to the
        method. To remove a limit, provide a None value.  for example:

            >>> from pymel.core import *
            >>> s = polyCube()[0]
            >>> s.addAttr( 'new' )
            >>> s.new.setRange( -2, None ) #sets just the min to -2 and removes the max limit
            >>> s.new.setMax( 3 ) # sets just the max value and leaves the min at its previous default
            >>> s.new.getRange()
            [-2.0, 3.0]

        """

        self._setRange('hard', *args)

    @overload
    def setRange(self, range):
        # type: (Tuple[Optional[float], Optional[float]]) -> None
        pass

    @overload
    def setRange(self, newMin, newMax):
        # type: (Optional[float], Optional[float]) -> None
        pass

Removing them should fix this problem.

@JasonGilholme
Copy link
Member

The fix for this is included in the latest release of pymel. Installing 1.5.0 from pypi should fix your problem. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants