Skip to content

Commit

Permalink
Merge pull request #18 from monkeez/issue-15
Browse files Browse the repository at this point in the history
Added time argument to a number of functions
  • Loading branch information
mottosso authored Sep 27, 2020
2 parents 8953b0f + bdd51c9 commit d2203e8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions cmdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -2289,7 +2289,7 @@ def extend(self, values):
def count(self):
return self._mplug.evaluateNumElements()

def asDouble(self):
def asDouble(self, time=None):
"""Return plug as double (Python float)
Example:
Expand All @@ -2300,6 +2300,8 @@ def asDouble(self):
"""

if time is not None:
return self._mplug.asDouble(DGContext(time=time))
return self._mplug.asDouble()

def asMatrix(self, time=None):
Expand All @@ -2322,7 +2324,7 @@ def asMatrix(self, time=None):
"""

if time is not None:
context = om.MDGContext(time=time)
context = DGContext(time=time)
obj = self._mplug.asMObject(context)
else:
obj = self._mplug.asMObject()
Expand Down Expand Up @@ -2357,9 +2359,9 @@ def asQuaternion(self, time=None):
value = self.read(time=time)
value = Euler(value).asQuaternion()

def asVector(self):
def asVector(self, time=None):
assert self.isArray or self.isCompound, "'%s' not an array" % self
return Vector(self.read())
return Vector(self.read(time=time))

@property
def connected(self):
Expand Down Expand Up @@ -2482,7 +2484,7 @@ def reset(self):
@property
def writable(self):
"""Can the user write to this attribute?
Convenience for combined call to `plug.connected`
and `plug.locked`.
Expand Down Expand Up @@ -2915,7 +2917,7 @@ def __call__(self, *item):
Arguments:
item (int, tuple): 1 integer for row, 2 for element
Identity/default matrix:
[[1.0, 0.0, 0.0, 0.0]]
[[0.0, 1.0, 0.0, 0.0]]
Expand Down Expand Up @@ -4135,12 +4137,13 @@ def createNode(type, name=None, parent=None):
return node


def getAttr(attr, type=None):
def getAttr(attr, type=None, time=None):
"""Read `attr`
Arguments:
attr (Plug): Attribute as a cmdx.Plug
type (str, optional): Unused
time (float, optional): Time at which to evaluate the attribute
Example:
>>> node = createNode("transform")
Expand All @@ -4149,7 +4152,7 @@ def getAttr(attr, type=None):
"""

return attr.read()
return attr.read(time=time)


def setAttr(attr, value, type=None):
Expand Down

0 comments on commit d2203e8

Please sign in to comment.