Skip to content

compas_cadwork.scene ¤

Classes¤

BeamSceneObject ¤

BeamSceneObject(item: Beam, **kwargs)

Scene object for COMPAS Timber Beam objects.

Parameters:

  • item (:class:`compas_timber.elements.Beam`) –

    The beam object.

Methods:¤

draw ¤
draw()

Draw the beam object in the scene.

Returns:

  • list

    List of drawn element ids.

CadworkSceneObject ¤

CadworkSceneObject(item=None, name=None, color=None, opacity=1.0, show=True, transformation=None, context=None, **kwargs)

Base class for all of cadwork's SceneObject.

Methods:¤

add_element ¤
add_element(element_id) -> Element

Records the given element_id to track elements added by the :class:~compas_cadwork.scene.CadworkSceneObject.

Parameters:

  • element_id (int) –

    The element ID to add to tracking.

clear classmethod ¤
clear(*args, **kwargs)

Removes all elements tracked by the :class:~compas_cadwork.scene.CadworkSceneObject from the cadwork model.

Camera ¤

Camera(frame: Frame, fov: float, fwidth: float, fheight: float, target: Point, projection_type: ProjectionType)

This class is a wrapper for cadwork's camera data which allows to get information and manipulate the camera settings in an object-oriented way.

..note:: While the cadwork document might use millimeters as the unit of length, the camera data is expected in meters. The caller is responsible for converting the data to the correct unit before passing it to the camera.

Parameters:

  • frame (Frame) –

    Position and orientation of the camera.

  • fov (float) –

    The field of view of the camera.

  • fwidth (float) –

    The field width of the camera.

  • fheight (float) –

    The field height of the camera.

  • target (Point) –

    The point the camera is looking at.

  • projection_type (ProjectionType) –

    The projection type of the camera.

Attributes:

  • frame (:class:`~compas.geometry.Frame`, read-only) –

    Position and orientation of the camera.

  • fov ((float, read - only)) –

    The field of view of the camera.

  • fov_width ((float, read - only)) –

    The field width of the camera.

  • fov_height ((float, read - only)) –

    The field height of the camera.

  • position (Point) –

    The position of the camera.

  • target (Point) –

    The point the camera is looking at.

  • up_vector (Vector) –

    The up vector of the camera.

Examples:

>>> from compas_cadwork.scene import Camera
>>> camera = Camera.from_activedoc()
>>> camera.position
Point(0.0, 0.0, 0.0)
>>> # Set the camera position to the center of the active element and zoom to it:
>>> length = element.length * 0.001
>>> target = element.midpoint * 0.001
>>> location = target + element.frame.zaxis * length
>>> camera = Camera.from_activedoc()
>>> camera.look_at(target, up_vector=element.frame.xaxis)

Methods:¤

apply_camera ¤
apply_camera() -> None

Apply the camera settings to the currently active cadwork document.

from_activedoc classmethod ¤
from_activedoc() -> Camera

Create a camera from the camera in the currently active cadwork document.

Returns:

  • Camera

    The camera object created from the active cadwork document.

look_at ¤
look_at(target: Point, up_vector: Vector) -> None

Set the camera to look at a specific target point.

Raises:

  • ValueError

    If the up vector and the camera-to-target vector are not orthogonal.

Parameters:

  • target (Point) –

    The point the camera should look at.

  • up_vector (Vector) –

    The up vector of the camera.

reload_camera ¤
reload_camera() -> None

Load the camera settings from the currently active cadwork document.

reset_view ¤
reset_view() -> None

Reset the camera to the standard axonometric view.

zoom_active_element ¤
zoom_active_element() -> None

Zoom the camera to the currently active element.

LinearDimensionSceneObject ¤

LinearDimensionSceneObject(item: LinearDimension, **kwargs)

Draw a linear dimension instruction.

Parameters:

  • linear_dimension (:class:`~monosashi.sequencer.LineraDimension`) –

    The linear dimension to draw.

Methods:¤

draw ¤
draw(*args, **kwargs)

Adds a new dimension to the cadwork document.

Returns:

  • int

    cadwork element ID of the added dimension.

Text3dSceneObject ¤

Text3dSceneObject(item: Text3d, **kwargs)

Draws a 3d text volume instruction onto the view.

Parameters:

  • text_instruction (:class:`~monosashi.sequencer.Text3d`) –

    The text instruction to draw.

Methods:¤

draw ¤
draw(*args, **kwargs)

Adds a text element with the text included in the provided text instruction.

Returns:

  • int

    cadwork element ID of the added text.