Conver Ioncurve to GH_Curve?


#1

I want create a make2d commpont with RMA SDK. But I don’t know how to conver Ioncurve to GH_curve. See the code below

    Protected Overrides Sub RegisterInputParams(ByVal pManager As GH_Component.GH_InputParamManager)
 pManager.AddGeometryParameter("G", "Geo", "要拍平的几何对象" & vbCrLf & "(The Geometry will make2d)", GH_ParamAccess.list)
 pManager.AddPlaneParameter("Plane", "P", "几何对象的主视图平面" & vbCrLf & "(plane the Geometry's Main view )", GH_ParamAccess.item, Plane.WorldXY)
 pManager.AddNumberParameter("DisTolarance", "T", "Make2d的距离精度" & vbCrLf & "(DisTance Tolarance of Make2d)", GH_ParamAccess.item, RhinoDoc.ActiveDoc.ModelAbsoluteTolerance)
 pManager.AddNumberParameter("AngTolarance", "A", "Make2d的角度精度" & vbCrLf & "(Angle Tolarance of Make2d)", GH_ParamAccess.item, RhinoDoc.ActiveDoc.ModelAngleToleranceRadians)
 pManager.HideParameter(1)
 End Sub


 Protected Overrides Sub RegisterOutputParams(ByVal pManager As Kernel.GH_Component.GH_OutputParamManager)
 pManager.AddGenericParameter("ProjectCrv", "PC", "投影线" & vbCrLf & "(Project Curves)", GH_ParamAccess.list)
 pManager.AddGenericParameter("HiddenCrv", "HC", "隐藏线" & vbCrLf & "(Hidden Curves)", GH_ParamAccess.list)
 End Sub


 Protected Overrides Sub SolveInstance(ByVal DA As Kernel.IGH_DataAccess)
 If Banner.astrict.showmessage Then Return
 Dim Geo As New List(Of IGH_GeometricGoo), Pln As Plane = Plane.WorldXY, disT As Double = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance
 Dim angT As Double = RhinoDoc.ActiveDoc.ModelAngleToleranceRadians
 If Not DA.GetDataList(0, Geo) Then Return
 DA.GetData(1, Pln)
 DA.GetData(2, disT)
 DA.GetData(3, angT)
 Dim irhobjs As New List(Of RMA.Rhino.IRhinoBrepObject)
 For Each ge As IGH_GeometricGoo In Geo
 If Not ge.IsReferencedGeometry Then
 AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "引入的物件必须在文档中已经存在!")
 Return
 End If
 Dim mf As New RMA.Rhino.MRhinoObjRef(ge.ReferenceID)
 
Dim brep_obj As RMA.Rhino.IRhinoBrepObject = RMA.Rhino.MRhinoBrepObject.ConstCast(mf.Object)
 irhobjs.Add(brep_obj)
 Next
 Dim pcobj As RMA.Rhino.MRhinoCurveObject() = Nothing, hcobj As RMA.Rhino.MRhinoCurveObject() = Nothing
 
Dim Ionpts As New RMA.OpenNURBS.On3dPoint(Pln.Origin.X, Pln.Origin.Y, Pln.Origin.Z)
 Dim Ionvx As New RMA.OpenNURBS.On3dVector(Pln.XAxis.X, Pln.XAxis.Y, Pln.XAxis.Z)
 Dim Ionvy As New RMA.OpenNURBS.On3dVector(Pln.YAxis.X, Pln.YAxis.Y, Pln.YAxis.Z)
 Dim Ionpln As New RMA.OpenNURBS.OnPlane(Ionpts, Ionvx, Ionvy)
 RMA.Rhino.RhUtil.RhinoBrepGet2dProjection(irhobjs.ToArray, Ionpln, pcobj, hcobj, disT, angT)
 Dim pcrv As New List(Of RMA.OpenNURBS.IOnCurve), Hcrv As New List(Of RMA.OpenNURBS.IOnCurve)
 For Each pobj As RMA.Rhino.MRhinoCurveObject In pcobj
 pcrv.Add(pobj.Curve)
 Next
 For Each pobj As RMA.Rhino.MRhinoCurveObject In hcobj
 Hcrv.Add(pobj.Curve)
 Next
 DA.SetDataList(0, pcrv)
 DA.SetDataList(1, Hcrv)
 End Sub

#2

Got it.Runtime.Interop.FromOnCurve
I am so excited!