Skip to content

Conversation

@jwwang0-0
Copy link

What type of change is this?

  • Bug fix in a backwards-compatible manner.
  • New feature in a backwards-compatible manner.
  • Breaking change: bug fix or new feature that involve incompatible API changes.
  • Other (e.g. doc update, configuration, etc)

This PR fixes an issue where plane_to_rhino() constructed a Rhino.Geometry.Plane with only two arguments (origin point + x-axis). Rhino’s Plane constructor requires three arguments:

  • origin point
  • x-axis
  • y-axis

The current code will direct to another constructor :

public Plane(
[Point3d ] origin
[Vector3d ] normal
)

And will cause troubles like

image

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

  • I added a line to the CHANGELOG.md file in the Unreleased section under the most fitting heading (e.g. Added, Changed, Removed).
  • I ran all tests on my computer and it's all green (i.e. invoke test).
  • I ran lint on my computer and there are no errors (i.e. invoke lint).
  • I added new functions/classes and made them available on a second-level import, e.g. compas.datastructures.Mesh.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added necessary documentation (if appropriate)

"""
return Rhino.Geometry.Plane(point_to_rhino(plane[0]), vector_to_rhino(plane[1]))
return Rhino.Geometry.Plane(point_to_rhino(plane[0]), vector_to_rhino(plane[1]), vector_to_rhino(plane[2]))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a COMPAS plane only has a point and a normal (it is not a frame). index 0 will return the base point, and index 1, the normal.

accessing index 2 on a plane object will raise a KeyError.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the redirection to the constructor that uses a point and a normal is correct. i think the functionality you are looking for is frame_to_rhino...

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR attempts to fix a bug in the plane_to_rhino() function by adding a third argument (y-axis vector) to the Rhino.Geometry.Plane constructor. The PR author correctly identifies that the Rhino.Geometry.Plane constructor with 3 arguments requires (origin, xaxis, yaxis) rather than using the 2-argument constructor (origin, normal).

However, the proposed fix is critically flawed and will cause a runtime error. COMPAS Plane objects only contain 2 elements: a point and a normal vector. The fix attempts to access plane[2], which doesn't exist and will raise a KeyError. The correct approach requires converting the COMPAS Plane to a Frame first using Frame.from_plane(), which computes the xaxis and yaxis from the normal, then passing those to the Rhino constructor as demonstrated in the existing frame_to_rhino_plane() function.

Key Issues

  • The code will crash with a KeyError when trying to access plane[2]
  • COMPAS Plane has __len__() = 2 and __getitem__() only supports indices 0 (point) and 1 (normal)
  • The fix needs to compute xaxis/yaxis from the plane's normal using Frame.from_plane()

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants