Scene

class compas.scene.Scene[source]

Bases: Tree

A scene is a container for hierarchical scene objects which are to be visualised in a given context.

Parameters:
namestr, optional

The name of the scene.

contextstr, optional

The context in which the scene is visualised. Will be automatically detected if not specified.

Attributes:
treecompas.scene.SceneTree

The underlying tree data structure of the scene.

objectslist[compas.scene.SceneObject]

All scene objects in the scene.

Examples

>>> from compas.scene import Scene
>>> from compas.geometry import Box
>>> scene = Scene()
>>> box = Box.from_width_height_depth(1, 1, 1)
>>> boxobj = scene.add(box)
>>> scene.draw()  

Methods

add

Add an item to the scene.

clear

Clear the scene.

clear_context

Clear the visualisation context.

draw

Draw the scene.

find_all_by_itemtype

Find all scene objects with a data item of the given type.

find_by_itemtype

Find the first scene object with a data item of the given type.

find_by_name

Find the first scene object with the given name.

redraw

Redraw the scene.

Inherited Methods

ToString

Converts the instance to a string.

compute_aabb

Compute the axis-aligned bounding box of the datastructure.

compute_obb

Compute the oriented bounding box of the datastructure.

copy

Make an independent copy of the data object.

from_json

Construct an object of this type from a JSON file.

from_jsonstring

Construct an object of this type from a JSON string.

get_hierarchy_string

Return string representation for the spatial hierarchy of the tree.

get_node_by_name

Get a node by its name.

get_nodes_by_name

Get all nodes by their name.

remove

Remove a node from the tree.

rotate

Rotate the datastructure.

rotated

Returns a rotated copy of this geometry.

scale

Scale the datastructure.

scaled

Returns a scaled copy of this geometry.

sha256

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

to_graph

Convert the tree to a graph.

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.

transform

Transforms the data structure.

transform_numpy

Transforms the data structure.

transformed

Returns a transformed copy of this data structure.

transformed_numpy

Returns a transformed copy of this data structure.

translate

Translate the datastructure.

translated

Returns a translated copy of this geometry.

traverse

Traverse the tree from the root node.

validate_data

Validate the data against the object's data schema.