A picklable class that simulates the behavior of connection design locks visible on the member edit screen.
More...
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