BHoM / Rhinoceros_Toolkit

Set of functionalities for communication with Rhinoceros
GNU Lesser General Public License v3.0
6 stars 2 forks source link

Rhinoceros_Engine: add convert methods for Extrusion #204

Closed alelom closed 3 years ago

alelom commented 3 years ago

Issues addressed by this PR

Closes #182

Test files

Create any BHoM Extrusion, then try to convert it ToRhino(), and then FromRhino().

To test the FromRhino() from a script, you may want to temporarily modify the IFromRhino method as below:

```cs public static BHG.IGeometry IFromRhino(this object geometry) { // Code to force testing of Extrusion: first convert toRhino, then fromRhino. if (geometry is BH.oM.Geometry.Extrusion) return Convert.FromRhino((geometry as BH.oM.Geometry.Extrusion).ToRhino()); return (geometry == null) ? null : Convert.FromRhino(geometry as dynamic); } ```

otherwise, due to the Goo casting being enforced for BHoM components, you'll never be able to pass a Rhino object to FromRhino() using Grasshopper components.

Changelog

Additional comments

alelom commented 3 years ago

@rolyhudson @al-fisher Because Rhino is enforcing perpendicularity btw base curve and extrusion direction, while BHoM gives more freedom, I quickly added a feature to return a Sweep in case that condition is not met.

image

The method works by extrapolating the sweep rail from the centroid of the base curve (or middle point, if it is open).

For some reason, the sweep is interrupted a bit before the top of the provided direction line, see below. I guess this feature can be improvable, but I'd rather raise a separate issue on this than keeping this PR open, which is already useful as it is for our applications.

image

al-fisher commented 3 years ago

Good approach returning sweep for not perpendicular BHoM.Extrusions. Agreed. Also agree on current limitation on Sweep cut off - worth raising separate issue on that

Standard extrude working well for me now in preview Although can not recreate your skewed Sweep behaviour? Have you missing commits? Or have I messed up my end? @alelom

alelom commented 3 years ago

Although can not recreate your skewed Sweep behaviour? Have you missing commits? Or have I messed up my end? @alelom

Sorry yes I was missing to save the file then commit!

al-fisher commented 3 years ago

/azp run Rhinoceros_Toolkit.CheckInstaller

azure-pipelines[bot] commented 3 years ago
Azure Pipelines successfully started running 1 pipeline(s).
alelom commented 3 years ago

Thanks @al-fisher , I had to push https://github.com/BHoM/Rhinoceros_Toolkit/pull/204/commits/4acbbf09fcbcaec2069e50d392c663704dfeba8a to fix build not working for Grasshopper as highlighted by CheckInstaller.

alelom commented 3 years ago

/azp run Rhinoceros_Toolkit.CheckInstaller

azure-pipelines[bot] commented 3 years ago
Azure Pipelines successfully started running 1 pipeline(s).