SDS2 Parametric API
 All Classes Namespaces Functions Variables Pages
List of all members
sds2.lockable.LockableValue Class Reference

A picklable class that simulates the behavior of connection design locks visible on the member edit screen. More...

Methods defined here:

def __copy__
def __deepcopy__
def __eq__
def __getinitargs__
def __getstate__
def __init__
def __ne__
def __reduce__
def __repr__
def __setstate__
def __str__
def add_option
def get_readable_value
def get_screen_label
def set
def set_lock

Data descriptors defined here:

def lock
def value

Data and other attributes defined here:

 __getstate_manages_dict__ = True
int __instance_size__ = 272
 __safe_for_unpickling__ = True

Data descriptors inherited from Boost.Python.instance:

def __dict__
def __weakref__

Data and other attributes inherited from Boost.Python.instance:

def __new__

Detailed Description

A picklable class that simulates the behavior of connection design locks visible on the member edit screen.

It is used by the ConnectionLocks class for this purpose and can also be instantiated and/or used by other APIs.


|LockableValue tutorial

Standalone instantiation:

Note: This tutorial does not cover pickling and equality checks, which are supported by Lockable values.

    import sds2.lockable

    ''' Create an integer LockableValue with lock set to False
        (Using the default lock value). '''
    lk = sds2.lockable.LockableValue(1)

    ''' Change the value of the LockableValue
        Note: This automatically locks the LockableValue if not locked. '''
    lk.set(21)

    ''' Unlock the LockableValue. '''
    lk.set_lock(False)

    ''' Create a float LockableValue with lock set to True. '''
    lk = sds2.lockable.LockableValue(1.0, True)

    ''' Create a LockableValue with an arbitrary string. '''
    lk = sds2.lockable.LockableValue('hello world')

    ''' Create a section size LockableValue.
        Note: If the section size does not exist in the material file, the size
        will be treated as an arbitrary string, as shown in the previous
        example. '''
    lk = sds2.lockable.LockableValue('w8x48')

    ''' Try to set an invalid section size to the above LockableValue.
        This will throw an exception. '''
    lk.set('unknown')

    ''' Create a dimension-entry style LockableValue. '''
    lk = sds2.lockable.LockableValue('1-3')

    ''' Print the float magnitude of the dimension style LockableValue. '''
    print lk.value

    ''' Print the human-readable dimension, as seen on member edit.
        Note: This doesn't affect dimensions that don't use ft-in notation.'''
    print lk.get_readable_value()

    ''' Create a variable-spacing LockableValue. '''
    lk = sds2.lockable.LockableValue('3, 3@4, 5')

    ''' Print the spacings as a list. '''
    print lk.value

    ''' Print the human-readable dimension, as seen on member edit. '''
    print lk.get_readable_value()

    ''' Create a combobox-style LockableValue (in two steps). '''
    # Step 1: Create a LockableValue.
    lk = sds2.lockable.LockableValue('option 1')

    # Step 2: Add the 'combobox' alternatives.
    lk.add_option('option 2')
    lk.add_option('option 3')

    # The above Lockable value is now restricted to 'option 1', 'option 2' and
    # 'option 3'.

    ''' Try to set the above LockableValue to a value other than the above options.
        This will throw an exception. '''
    lk.set('option 4')

Instantiation with ConnectionLocks:

In addition to the behavior of standalone LockableValues, those instantiated by ConnectionLocks possess validation routines corresponding to those on member edit. They also possess 'screen labels' that are visible on member edit.

See help(sds2.lockable.ConnectionLocks) for examples of validation and

screen labels.

Method resolution order

LockableValue
Boost.Python.instance
builtin.object

Constructor & Destructor Documentation

def sds2.lockable.LockableValue.__init__ (   arg1,
  value,
  lock 
)
Returns
Instance of type None

Member Function Documentation

def sds2.lockable.LockableValue.__copy__ (   arg1)
Returns
Instance of type object
def sds2.lockable.LockableValue.__deepcopy__ (   arg1,
  arg2 
)
Returns
Instance of type object
def sds2.lockable.LockableValue.__dict__ (   args)
def sds2.lockable.LockableValue.__eq__ (   arg1,
  arg2 
)
Returns
Instance of type bool
def sds2.lockable.LockableValue.__getinitargs__ (   arg1)
Returns
Instance of type tuple
def sds2.lockable.LockableValue.__getstate__ (   arg1)
Returns
Instance of type tuple
def sds2.lockable.LockableValue.__ne__ (   arg1,
  arg2 
)
Returns
Instance of type bool
def sds2.lockable.LockableValue.__new__ (   args)
T.__new__(S, ...) -> a new object with type S, a subtype of T
 __new__ = <built-in method __new__ of Boost.Python.class object>
def sds2.lockable.LockableValue.__reduce__ (   args)
 __reduce__ = <unnamed Boost.Python function>(args)
def sds2.lockable.LockableValue.__repr__ (   arg1)
Returns
Instance of type object
def sds2.lockable.LockableValue.__setstate__ (   arg1,
  arg2 
)
Returns
Instance of type None
def sds2.lockable.LockableValue.__str__ (   arg1)
Returns
Instance of type object
def sds2.lockable.LockableValue.__weakref__ (   args)
def sds2.lockable.LockableValue.add_option (   self,
  new_option 
)
Returns
Instance of type None
     When first called:
         Restricts valid assignment using LockableValue.Set(...) 
         to the current value and new_option.
     
         Calling LockableValue.Set(...) with a value other
         than these two will fail validation.
     
         In other words, turns the LockableValue into a
         command-line-combo-box with fixed alternatives.
     
     When called again:
         Adds new_option to the existing alternatives if valid.
def sds2.lockable.LockableValue.get_readable_value (   self)
Returns
Instance of type str
     Returns 'value' as a human-readable string.
     Visibly affects dimensions and variable spacing.
def sds2.lockable.LockableValue.get_screen_label (   self)
Returns
Instance of type str
     If instantiated by a ConnectionLocks opbject, returns a
     human readable description of the field.
     This corresponds to labels of connection design lock fields
     on member edit.
def sds2.lockable.LockableValue.lock (   args)
def sds2.lockable.LockableValue.set (   self,
  value 
)
Returns
Instance of type None
     Update value and lock.
 
     Update value and lock.
 
     Update value and lock.
 
     Update value and lock.
 
     Update value and lock.
Note
Additional signature: set( (LockableValue)self, (bool)value) -> None
Additional signature: set( (LockableValue)self, (float)value) -> None
Additional signature: set( (LockableValue)self, (str)value) -> None
Additional signature: set( (LockableValue)self, (list)list) -> None
def sds2.lockable.LockableValue.set_lock (   self,
  new_lock 
)
Returns
Instance of type None
     Update LockableValue.lock with new_lock.
def sds2.lockable.LockableValue.value (   args)

Member Data Documentation

sds2.lockable.LockableValue.__getstate_manages_dict__ = True
staticprivate
int sds2.lockable.LockableValue.__instance_size__ = 272
staticprivate
sds2.lockable.LockableValue.__safe_for_unpickling__ = True
staticprivate