Skip to content

Commit 58a9b31

Browse files
authored
Merge pull request #1052 from compas-dev/rhino_box_bug
Rhino box bug
2 parents 21c8e8b + 095a7d1 commit 58a9b31

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

AUTHORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@
3333
- Andrea Ghensi <<a.ghensi@swsglobal.com>> [@sanzoghenzo](https://github.com/sanzoghenzo)
3434
- Nizar Taha <<taha@arch.ethz.ch>> [@nizartaha](https://github.com/nizartaha)
3535
- Gene Ting-Chun Kao <<kao@arch.ethz.ch>> [@GeneKao](https://github.com/GeneKao)
36+
- Chen Kasirer <<kasirer@arch.ethz.ch>> [@chenkasirer](https://github.com/chenkasirer)

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3131
* Rebuild part index after deserialization in `Assembly`.
3232
* Fixed bug in `compas.artists.colordict.ColorDict`.
3333
* Change `Mesh.mesh_dual` with option of including the boundary.
34-
* Fixed type error in `compas_rhino.conversions._shapes.box_to_rhino`.
34+
* Fixed type error in `compas_rhino.conversions.box_to_rhino`.
3535
* Moved from `autopep8` to `black`
3636
* Fixed bug in `compas.utilities.linspace` for number series with high precision start and stop values.
3737
* Fixed uncentered viewbox in `Plotter.zoom_extents()`
3838
* Changed `RobotModelArtists.atteched_tool_models` to dictionary to support multiple tools.
3939
* Locked `sphinx` to 4.5.
4040
* Fixed source directory path in `compas_ghpython.uninstall` plugin.
4141
* Fixed bug in`compas_ghpython.components`that ignored input list of `.ghuser` objects to uninstall.
42+
* Fixed conversion bug of transformed `Box` in `compas_rhino.conversions`
4243

4344
### Removed
4445

src/compas_rhino/conversions/_shapes.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,9 @@ def box_to_compas(box):
4141
ysize = box.Y.Length
4242
zsize = box.Z.Length
4343
frame = plane_to_compas_frame(box.Plane)
44-
frame.point.x += 0.5 * xsize
45-
frame.point.y += 0.5 * ysize
46-
frame.point.z += 0.5 * zsize
44+
frame.point += frame.xaxis * 0.5 * xsize
45+
frame.point += frame.yaxis * 0.5 * ysize
46+
frame.point += frame.zaxis * 0.5 * zsize
4747
return Box(frame, xsize, ysize, zsize)
4848

4949

@@ -59,7 +59,12 @@ def box_to_rhino(box):
5959
:rhino:`Rhino.Geometry.Box`
6060
6161
"""
62-
return RhinoBox(frame_to_rhino(box.frame), Interval(0., box.xsize), Interval(0., box.ysize), Interval(0., box.zsize))
62+
# compas frame is center of box, intervals are in frame space
63+
base_plane = box.frame.copy()
64+
base_plane.point -= base_plane.xaxis * 0.5 * box.xsize
65+
base_plane.point -= base_plane.yaxis * 0.5 * box.ysize
66+
base_plane.point -= base_plane.zaxis * 0.5 * box.zsize
67+
return RhinoBox(frame_to_rhino(base_plane), Interval(0, box.xsize), Interval(0, box.ysize), Interval(0, box.zsize))
6368

6469

6570
def sphere_to_compas(sphere):

0 commit comments

Comments
 (0)