ParametricFeature

class compas.datastructures.ParametricFeature[source]

Bases: Feature

Base class for Features that may be applied to the parametric definition of a compas.datastructures.Part.

Examples

>>> class ExtensionFeature(ParametricFeature):
>>>     def __init__(self, extend_by):
>>>         super(ExtensionFeature, self).__init__()
>>>         self.extend_by = extend_by
>>>
>>>     def apply(self, part):
>>>         part.length += self._extend_by
>>>
>>>     def restore(self, part):
>>>         part.length -= self._extend_by
>>>
>>>     def accumulate(self, other):
>>>         return BeamExtensionFeature(max(self.extend_by, other.extend_by))

Methods

accumulate

Returns a new ParametricFeature which has the accumulative effect of this and the given feature.

restore

Reverses the effect this ParametricFeature has incured onto the given part.

Inherited Methods

ToString

Converts the instance to a string.

apply

Apply this Feature to the given part.

copy

Make an independent copy of the data object.

from_data

Construct an object of this type from the provided data.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

sha256

Compute a hash of the data for comparison during version control using the sha256 algorithm.

to_data

Convert an object to its native data representation.

to_json

Convert an object to its native data representation and save it to a JSON file.

to_jsonstring

Convert an object to its native data representation and save it to a JSON string.

validate_data

Validate the data against the object's data schema.