Part

class compas.datastructures.Part(name=None, frame=None, shape=None, features=None, **kwargs)[source]

Bases: compas.datastructures.datastructure.Datastructure

A data structure for representing assembly parts.

Parameters
  • name (str, optional) – The name of the part. The name will be stored in Part.attributes.

  • frame (compas.geometry.Frame, optional) – The local coordinate system of the part.

  • shape (compas.geometry.Shape, optional) – The base shape of the part geometry.

  • features (list of tuple(compas.geometry.Shape, str), optional) – The features to be added to the base shape of the part geometry.

Attributes
  • attributes (dict) – General object attributes that will be included in the data dict.

  • key (int or str) – The identifier of the part in the connectivity graph of the parent assembly.

  • frame (compas.geometry.Frame) – The local coordinate system of the part.

  • shape (compas.geometry.Shape) – The base shape of the part geometry.

  • features (list of tuple(compas.geometry.Shape, str)) – The features added to the base shape of the part geometry.

  • transformations (deque of compas.geometry.Transformation) – The stack of transformations applied to the part geometry. The most recent transformation is on the left of the stack. All transformations are with respect to the local coordinate system.

Attributes

DATASCHEMA

The schema of the data of this object.

JSONSCHEMANAME

data

A data dict representing the part attributes, the assembly graph identifier, the local coordinate system, the base shape, the shape features, and the transformation tack wrt to the local coordinate system.

frame

geometry

name

The name of the part.

operations

Inherited Attributes

JSONSCHEMA

The schema of the JSON representation of the data of this object.

dtype

The type of the object in the form of a '2-level' import and a class name.

guid

The globally unique identifier of the object.

jsondefinitions

Reusable schema definitions.

jsonstring

The representation of the object data in JSON format.

jsonvalidator

JSON schema validator for draft 7.

Methods

add_feature

Add a feature to the shape of the part and the operation through which it should be integrated.

to_mesh

Convert the part geometry to a mesh.

transform

Transform the part with respect to the local cooordinate system.

Inherited Methods

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 from serialized data contained in a JSON file.

from_jsonstring

Construct an object from serialized data contained in a JSON string.

to_data

Convert an object to its native data representation.

to_json

Serialize the data representation of an object to a JSON file.

to_jsonstring

Serialize the data representation of an object to a JSON string.

validate_data

Validate the object's data against its data schema (self.DATASCHEMA).

validate_json

Validate the object's data against its json schema (self.JSONSCHEMA).