Camera

class compas_cadwork.scene.Camera[source]

Bases: Data

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:
frameFrame

Position and orientation of the camera.

fovfloat

The field of view of the camera.

fwidthfloat

The field width of the camera.

fheightfloat

The field height of the camera.

targetPoint

The point the camera is looking at.

projection_typeProjectionType

The projection type of the camera.

Attributes:
frameFrame, read-only

Position and orientation of the camera.

fovfloat, read-only

The field of view of the camera.

fov_widthfloat, read-only

The field width of the camera.

fov_heightfloat, read-only

The field height of the camera.

positionPoint

The position of the camera.

targetPoint

The point the camera is looking at.

up_vectorVector

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 the camera settings to the currently active cadwork document.

from_activedoc

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

look_at

Set the camera to look at a specific target point.

reload_camera

Load the camera settings from the currently active cadwork document.

reset_view

Reset the camera to the standard axonometric view.

zoom_active_element

Zoom the camera to the currently active element.

Inherited Methods

ToString

Converts the instance to a string.

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.

sha256

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

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.