Grasshopper

algorithmic modeling for Rhino

I am creating some components to speed up testing.  A suggestion was made (here) to include a component that could quickly/automatically regenerate wires when a component is added to canvas.

I have a little test working that is using this function to create the wire from a "sender" component: 

private void updateOutput(string name, int num)
{
ghDocument = this.OnPingDocument();
List<Grasshopper.Kernel.GH_Component> comps = ghDocument.Objects.OfType<Grasshopper.Kernel.GH_Component>().Where(cp => cp.Name.Equals(name)).ToList<Grasshopper.Kernel.GH_Component>();

foreach (Grasshopper.Kernel.GH_Component cp in comps)
{
if (cp.Params.Input[num] != null)
{
cp.Params.Input[num].AddSource(this.Params.Output[0]);
}
}
}

This works, but I get an error: "An object Expired during a solution".  Could this be because I am adding the wire as the solution is calculating?  I will try adding after solution is complete and see if that helps.

Views: 280

Replies to This Discussion

ok so that fixed it, just had to add the wires after solution completed. 

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service