Grasshopper

algorithmic modeling for Rhino

Hi,

This is a continuation of my comment here: (http://www.grasshopper3d.com/forum/topics/creating-a-component-with...)

So, based on David's comment here (http://www.grasshopper3d.com/forum/topics/create-radio-button-on-gr...), I've created a button that, upon click, within RespondToMouseDown, calls RegisterOutputParam, and modifies the number of parameters. This is all good and well.

However, the parameters don't actually change immediately; they change once I start moving the component in the Grasshopper canvas, or move the canvas itself. I'm assuming that I need to call some sort of redraw function for the component, or at least the parameters, so that the newly-added parameters are visible immediately in the canvas.

However, neither this.PerformLayout(), this.ExpireLayout(), nor this.Layout() seem to be doing anything much. The RenderComponentParameters() method in the SDK seems promising, but it's not clear how I can specify the canvas/graphics;  

Any advice or help would be much appreciated!

Views: 1574

Attachments:

Replies to This Discussion

You should call ExpireLayout() which will destroy any caches. They will be lazily rebuild when the next canvas draw happens. This usually happens during a solution (or a Pan/Zoom operation) but if you're not triggering a new solution after you add a parameter (if not, why not?) then you'll have to specifically tell the canvas to redraw. You can do this inside RespondToMouseDown() using sender.Invalidate(), or you can use Grasshopper.Instances.InvalidateCanvas()

But again, if you're adding a parameter I think you should call ExpireSolution(true) on the component itself which will make sure all this stuff happens automatically.

--

David Rutten

david@mcneel.com

That was it! Somehow I had overlooked ExpireSolution. Thanks again, David!

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service