Skip to content

Commit

Permalink
add casts to rhino (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamhathcock authored Jun 20, 2024
1 parent 72aa048 commit 137c6ac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
17 changes: 15 additions & 2 deletions Rhino/Speckle.Rhino.Api/IRhinoCurve.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using Rhino;
using Rhino.Collections;
using Rhino.DocObjects;
Expand Down Expand Up @@ -26,6 +26,19 @@ public partial class RhinoDocProxy
[Proxy(typeof(Curve), new[] { "Duplicate" })]
public partial interface IRhinoCurveProxy : IRhinoCurve;

public partial class CurveProxy
{
public IRhinoPolyCurve? ToPolyCurve() => A.Call<IRhinoPolyCurve>(() => _Instance as PolyCurve);

public IRhinoArcCurve? ToArcCurve() => A.Call<IRhinoArcCurve>(() => _Instance as ArcCurve);

public IRhinoPolylineCurve? ToPolylineCurve() => A.Call<IRhinoPolylineCurve>(() => _Instance as PolylineCurve);

public IRhinoLineCurve? ToLineCurve() => A.Call<IRhinoLineCurve>(() => _Instance as LineCurve);

public IRhinoNurbsCurve? ToNurbsCurveReflection() => A.Call<IRhinoNurbsCurve>(() => _Instance as NurbsCurve);
}

[Proxy(typeof(GeometryBase), new[] { "Transform" })]
public partial interface IRhinoGeometryBaseProxy : IRhinoGeometryBase;

Expand Down Expand Up @@ -249,7 +262,7 @@ public IEnumerator<IRhinoBrepEdge> GetEnumerator()
[Proxy(typeof(BrepEdge))]
public partial interface IRhinoBrepEdgeProxy : IRhinoBrepEdge;

[Proxy(typeof(CurveProxy))]
[Proxy(typeof(Rhino.Geometry.CurveProxy))]
public partial interface IRhinoCurveProxy2Proxy : IRhinoCurveProxy2;

[Proxy(typeof(BrepTrimList), new[] { "AddSingularTrim", "GetEnumerator" })]
Expand Down
7 changes: 6 additions & 1 deletion Rhino/Speckle.Rhino.Interfaces/RhinoCurve.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Drawing;
using System.Drawing;

namespace Speckle.Rhino7.Interfaces;

Expand Down Expand Up @@ -33,6 +33,11 @@ bool keepStartPoint
int Degree { get; }
bool IsPeriodic { get; }
IRhinoCurve Trim(IRhinoInterval interval);
IRhinoPolyCurve? ToPolyCurve();
IRhinoArcCurve? ToArcCurve();
IRhinoPolylineCurve? ToPolylineCurve();
IRhinoLineCurve? ToLineCurve();
IRhinoNurbsCurve? ToNurbsCurveReflection();
}

public interface IRhinoGeometryBase : IRhinoCommonObject
Expand Down
2 changes: 1 addition & 1 deletion Speckle.Host.Apis.sln
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,6 @@ Global
{EB2B9350-BE2B-4197-ACA8-3963EAE3B6C9} = {BC12C4CA-7065-4B76-9787-E8DA4745AD4E}
{5F678DE0-AAE7-4FA9-9A7F-C3C0B0E3E3D7} = {BC12C4CA-7065-4B76-9787-E8DA4745AD4E}
{E1C43415-3200-45F4-8BF9-B4DD7D7F2ED6} = {3B0D8F6E-C701-446E-BAE3-B6FDF1812901}
{E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6} = {72DEFF6C-31DE-4050-8692-AEE8224E9925}
{E1C43415-3200-45F4-8BF9-A4DD7D7F2ED6} = {8F540B7F-7548-46E9-BDEC-4DAB99367908}
EndGlobalSection
EndGlobal

0 comments on commit 137c6ac

Please sign in to comment.