compas_cadwork.scene
¤
Classes¤
BeamSceneObject
¤
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
¤
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)
-
API Reference
scene ClassesCamera Methods:from_activedoc
Methods:¤
apply_camera
¤
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
¤
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:
reload_camera
¤
Load the camera settings from the currently active cadwork document.
zoom_active_element
¤
Zoom the camera to the currently active element.
LinearDimensionSceneObject
¤
Text3dSceneObject
¤
Draws a 3d text volume instruction onto the view.
Parameters:
-
text_instruction(:class:`~monosashi.sequencer.Text3d`) –The text instruction to draw.