PDA

View Full Version : How do I get the preview start/end frames?



Celshader
04-09-2012, 12:00 PM
Hi,

I am trying to get the start and end frames of the timeline/preview. When I use the following code in PCore, I get a "property" object instead of a double:



import lwsdk

x = lwsdk.LWInterfaceInfo
print x.previewStart


This prints out "<property object at 0x000000BC89908>" instead of a time in seconds or a frame number. What methods could I use to get the values stored in this property object?

Jen

Celshader
04-09-2012, 12:21 PM
Well, typing "help(property)" uncovered this:


>>> help(property)
Help on class property in module __builtin__:
class property(object)
| property(fget=None, fset=None, fdel=None, doc=None) -> property attribute
|
| fget is a function to be used for getting an attribute value, and likewise
| fset is a function for setting, and fdel a function for del'ing, an
| attribute. Typical use is to define a managed attribute x:
| class C(object):
| def getx(self): return self._x
| def setx(self, value): self._x = value
| def delx(self): del self._x
| x = property(getx, setx, delx, "I'm the 'x' property.")
|
| Decorators make defining new properties or modifying existing ones easy:
| class C(object):
| @property
| def x(self): return self._x
| @x.setter
| def x(self, value): self._x = value
| @x.deleter
| def x(self): del self._x
|
| Methods defined here:
|
| __delete__(...)
| descr.__delete__(obj)
|
| __get__(...)
| descr.__get__(obj[, type]) -> value
|
| __getattribute__(...)
| x.__getattribute__('name') <==> x.name
|
| __init__(...)
| x.__init__(...) initializes x; see help(type(x)) for signature
|
| __set__(...)
| descr.__set__(obj, value)
|
| deleter(...)
| Descriptor to change the deleter on a property.
|
| getter(...)
| Descriptor to change the getter on a property.
|
| setter(...)
| Descriptor to change the setter on a property.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| fdel
|
| fget
|
| fset
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __new__ = <built-in method __new__ of type object>
| T.__new__(S, ...) -> a new object with type S, a subtype of T


I'm not yet sure what argument to use with fget(), though.

Celshader
04-09-2012, 01:04 PM
My bad. I forgot to use parentheses on LWInterfaceInfo.

This works:



import lwsdk
x = lwsdk.LWInterfaceInfo()
print x.previewStart
print x.previewEnd