Grasshopper

algorithmic modeling for Rhino

I am developing a custom component by C#.

I added custom MenuItems to the context menu.

When a MenuItem is clicked, a state of the component is changed and so, SolveInstance should be called.

Now I am struggling with this problem, calling the SolveInstance from an event handler.

How can I get an appropriate Grasshopper.Kernel.IGH_DataAccess object for my custom component?

Views: 411

Replies to This Discussion

Don't call SolveInstance. Even if you managed to provide a valid IGH_DataAccess object it still wouldn't work. You need to call ExpireSolution(true) when you want the component to recompute.

Basically, your event handler should look something like this:

private void MenuHandler(object sender, EventArgs e)

{

   RecordUndoEvent("Relevant Property Name");

   RelevantProperty = !RelevantProperty;

   ExpireSolution(true);

}

 

--

David Rutten

david@mcneel.com

Tirol, Austria

ThanksDavid. I will try.

wow, it worked finally.

ExpireSolution(true) was a member function of the GH_Component.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service