-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
727ed30
commit 350deea
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from compas_timber.elements import Beam | ||
|
||
from compas_cadwork.conversions import point_to_cadwork | ||
from compas_cadwork.conversions import vector_to_cadwork | ||
|
||
import element_controller as ec | ||
import attribute_controller as ac | ||
|
||
from .scene import CadworkSceneObject | ||
|
||
|
||
class BeamSceneObject(CadworkSceneObject): | ||
"""Scene object for COMPAS Timber Beam objects. | ||
Parameters | ||
---------- | ||
item : :class:`compas_timber.elements.Beam` | ||
The beam object. | ||
""" | ||
|
||
def __init__(self, item: Beam, **kwargs) -> None: | ||
super().__init__(item) | ||
|
||
def draw(self): | ||
"""Draw the beam object in the scene. | ||
Returns | ||
------- | ||
list | ||
List of drawn element ids. | ||
""" | ||
beam = self._item | ||
origin = point_to_cadwork(beam.frame.point) | ||
xaxis = vector_to_cadwork(beam.frame.xaxis) | ||
zaxis = vector_to_cadwork(beam.frame.normal) | ||
element_id = ec.create_rectangular_beam_vectors(beam.width, beam.height, beam.length, origin, xaxis, zaxis) | ||
beam.attributes["cadwork_id"] = element_id | ||
beam.attributes["name"] = f"beam_{beam.guid}" | ||
ac.set_name([element_id], beam.attributes["name"]) | ||
return [element_id] |