From 86d9abd8684011723496732836eb6324215dfac3 Mon Sep 17 00:00:00 2001 From: tomvanmele Date: Fri, 23 Aug 2024 17:52:55 +0200 Subject: [PATCH] fix bugs in shape conversions --- CHANGELOG.md | 2 ++ src/compas_rhino/conversions/shapes.py | 15 ++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 852ec8e1a8c9..23b8efbda387 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed * Changed supported Blender versions to latest LTS versions (3.3, 3.6, 4.2). +* Fixed bug in `compas_rhino.conversions.cone_to_compas`. +* Fixed bug in `compas_rhino.conversions.cylinder_to_compas`. ### Removed diff --git a/src/compas_rhino/conversions/shapes.py b/src/compas_rhino/conversions/shapes.py index 955568fbf6c5..320db85a7eec 100644 --- a/src/compas_rhino/conversions/shapes.py +++ b/src/compas_rhino/conversions/shapes.py @@ -6,11 +6,9 @@ import scriptcontext as sc # type: ignore from compas.geometry import Box -from compas.geometry import Circle from compas.geometry import Cone from compas.geometry import Cylinder from compas.geometry import Frame -from compas.geometry import Plane from compas.geometry import Sphere from compas.geometry import Torus @@ -19,11 +17,9 @@ # from .geometry import plane_to_rhino from .geometry import frame_to_rhino -from .geometry import plane_to_compas from .geometry import plane_to_compas_frame from .geometry import point_to_compas from .geometry import point_to_rhino -from .geometry import vector_to_compas # ============================================================================= # To Rhino @@ -253,8 +249,9 @@ def cone_to_compas(cone): :class:`compas.geometry.Cone` """ - plane = Plane(cone.BasePoint, vector_to_compas(cone.Plane.Normal).inverted()) - return Cone(Circle(plane, cone.Radius), cone.Height) + frame = plane_to_compas_frame(cone.Plane) + frame.point = point_to_compas(cone.BasePoint) # invert the z-axis? + return Cone(radius=cone.Radius, height=cone.Height, frame=frame) def cylinder_to_compas(cylinder): @@ -269,10 +266,10 @@ def cylinder_to_compas(cylinder): :class:`compas.geometry.Cylinder` """ - plane = plane_to_compas(cylinder.BasePlane) + frame = plane_to_compas_frame(cylinder.BasePlane) height = cylinder.TotalHeight - plane.point += plane.normal * (0.5 * height) - return Cylinder(Circle(plane, cylinder.Radius), height) + frame.point += frame.normal * (0.5 * height) + return Cylinder(radius=cylinder.Radius, height=height, frame=frame) def torus_to_compas(torus):