In the Curve.ClosestPoints() method of RhinoCommon, when I enter Surface as a list of GeometryBases and try to find the surfaces corresponding to the input curves, I can successfully I was able to get a combination of curves and surfaces, but when I build the component using the GrasshopperSDK, I cannot find the corresponding surfaces using the same interface methods below.
We would be grateful if someone could give us some advice. Thank you in advance.
The files for the above samples are attached. In addition, the code for the Grasshopper component is as follows.
public class Curve_ClosestPoints_Test_Component : GH_Component
{
public Curve_ClosestPoints_Test_Component()
: base("Curve_ClosestPoints_Test", "Curve_ClosestPoints_Test",
"Curve_ClosestPoints_Test",
"Tests", "Tests")
{
}
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddCurveParameter("Curve", "Curve", "Curve", GH_ParamAccess.item);
pManager.AddGeometryParameter("Geoms", "Geoms", "Geoms", GH_ParamAccess.list);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddGeometryParameter("Closest", "Closest", "Closest", GH_ParamAccess.item);
}
protected override void SolveInstance(IGH_DataAccess DA)
{
Curve crv = null;
DA.GetData(0, ref crv);
List<GeometryBase> geoms = new List<GeometryBase>();
DA.GetDataList(1, geoms);
bool found = crv.ClosestPoints(geoms, out Point3d pt_crv, out Point3d pt_geo, out int idx);
if (found) { DA.SetData(0, geoms[idx]); }
else { DA.SetData(0, null); }
}
protected override System.Drawing.Bitmap Icon => null;
public override Guid ComponentGuid => new Guid("5fd8b8ce-a9d0-4639-a1f9-29c08ecaa7a0");
}
sample.3dm (34.9 KB)
sample.gh (11.7 KB)