Skip to content

Commit

Permalink
add setter for up vector on beams and support beam offset export dire…
Browse files Browse the repository at this point in the history
…ctory to visualization
  • Loading branch information
Krande committed Nov 5, 2024
1 parent 5a6e8e1 commit 5d5f4bd
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion environment.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- conda-forge
dependencies:
- ada-py
- ada-cpp
# - ada-cpp
- bcf-client
- hdf5=1.14.4.3
- paradoc
Expand Down
22 changes: 22 additions & 0 deletions examples/scripts/geom/beams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import ada


def build_and_show():
pl = ada.Plate("pl1", [(0, 0), (1, 0), (1, 1), (0, 1)], 0.01)
bm = ada.Beam('bm1', (0, 0, 0), (1, 0, 0), 'TG1000x300x20x30')
p = ada.Part('MyPart') / (pl, bm)
p.show()

bm.up = ada.Direction((0, 0, -1))
p.show()

h = bm.section.h
offset = 1 * bm.up * h / 2
bm.e1 = offset
bm.e2 = offset
p.show()
print('done')


if __name__ == '__main__':
build_and_show()
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -154,4 +154,4 @@ wbuild = { cmd="npm run build", cwd="./src/frontend" }
fdepcheck = { cmd="depcheck", cwd="./src/frontend" }

[tool.pixi.dependencies]
pixi-pycharm = ">=0.0.6,<0.0.7"
pixi-pycharm = ">=0.0.7,<0.0.8"
4 changes: 4 additions & 0 deletions src/ada/api/beams/base_bm.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ def yvec(self) -> Direction:
def up(self) -> Direction:
return self._up

@up.setter
def up(self, value: Direction):
self._init_orientation(up=value)

@property
def xvec_e(self) -> Direction:
"""Local X-vector (including eccentricities)"""
Expand Down
11 changes: 10 additions & 1 deletion src/ada/api/beams/geom_beams.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import ada.geom.curves
import ada.geom.solids as geo_so
import ada.geom.surfaces as geo_su
from ada.config import Config
from ada.core.vector_transforms import transform_csys_to_csys
from ada.geom import Geometry
from ada.geom.booleans import BooleanOperation
Expand All @@ -20,9 +21,17 @@


def straight_beam_to_geom(beam: Beam | PipeSegStraight, is_solid=True) -> Geometry:
vec = beam.xvec
yvec = beam.yvec
p1 = beam.n1.p
if Config().ifc_export_include_ecc and beam.e1 is not None:
e1 = beam.e1
vec = beam.xvec_e
p1 = tuple([float(x) + float(e1[i]) for i, x in enumerate(beam.n1.p.copy())])

if is_solid:
profile = section_to_arbitrary_profile_def_with_voids(beam.section)
place = Axis2Placement3D(location=beam.n1.p, axis=beam.xvec, ref_direction=beam.yvec)
place = Axis2Placement3D(location=p1, axis=vec, ref_direction=yvec)
solid = geo_so.ExtrudedAreaSolid(profile, place, beam.length, Direction(0, 0, 1))
geom = Geometry(beam.guid, solid, beam.color)
else:
Expand Down

0 comments on commit 5d5f4bd

Please sign in to comment.