Grasshopper

algorithmic modeling for Rhino

Hi, 

I'm working on building a component which operates on a 3d Voronoi - to which end I'm investigating the Voronoi solver "Grasshopper.Kernel.Geometry.Voronoi.Solver.Solve_BruteForce", within a C# Scripting component for now. Having some trouble with data types/the IEnumerable interface, but I think I figured that out? Now the only errors I get are: 


0. Error (CS0534): 'Script_Instance' does not implement inherited abstract member 'Grasshopper.Kernel.GH_ScriptInstance.InvokeRunScript(Grasshopper.Kernel.IGH_Component, object, int, System.Collections.Generic.List<object>, Grasshopper.Kernel.IGH_DataAccess)' (line 34)

1. Error (CS0115): 'Node2s.InvokeRunScript(Grasshopper.Kernel.IGH_Component, object, int, System.Collections.Generic.List<object>, Grasshopper.Kernel.IGH_DataAccess)': no suitable method found to override (line 121)

Any advice would be awesome! My component currently takes in two Point3d lists, one of source points and one of polyline endpoints. 

Here's my code: (minus all the automatically-generated front/end matter)

 private void RunScript(List<Point3d> pts, List<Point3d> x, ref object A)

  {

    var nodes = new Grasshopper.Kernel.Geometry.Node2List();

    for (int i = 0; i < pts.Count; i++)

    {

      nodes.Append(new Grasshopper.Kernel.Geometry.Node2(pts[i].X, pts[i].Y));

    }

 

    var outline = new Node2s(Grasshopper.Kernel.Geometry.Node2);

 

    for (int j = 0; j < x.Count; j++) {

      outline.Add(x.X, x.Y);}

 

    A = Grasshopper.Kernel.Geometry.Voronoi.Solver.Solve_BruteForce(nodes, outline);}

  }

 

  // <Custom additional code>

public class Node2s : IEnumerable<Grasshopper.Kernel.Geometry.Node2>

{

  public List<Grasshopper.Kernel.Geometry.Node2> node2s;

 

  public Node2s()

  {

    node2s = new List<Grasshopper.Kernel.GeometryBase.Node2>();

  }

 

  public void Add(int x, int y)

  {

    node2s.Add(new Grasshopper.Kernel.Geometry.Node2);

  }

 

  public IEnumerator<Grasshopper.Kernel.Geometry.Node2> GetEnumerator()

  {

    return node2s.GetEnumerator();

  }

 

  IEnumerator IEnumerable.GetEnumerator()

  {

    return GetEnumerator();

  }

  // </Custom additional code>

}

Views: 705

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2026   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service