Grasshopper

algorithmic modeling for Rhino

What should the OutputParam be if the code draws onto the Grasshopper canvas?

What should I be setting the "RegisterOutputParams()" be if it is an image painted onto the canvas? Specifically, the object being printed is a Bitmap object. 

I have tried DA.SetData(0, _heatmap), where _heatmap is an instance variable. 

Generic does not appear to draw onto the canvas either.

Views: 377

Replies to This Discussion

There's no output parameter for drawing images on the canvas. In fact no parameter draws anything on the canvas. If you want to draw something non-standard then you have to do it yourself.

Bitmaps are not a native Grasshopper data-type. If you want to draw the image with your compiled component like you did with the VB script component, you should either add the same canvas painting events as before, or you should override the attributes for your component and paint the image there. The latter option is much better, especially if you also override the layout so that the image is drawn inside the component rather than next to it. This will a fair amount of code but I can help out with that. The question I have though is what should happen when your components is used to create more than one heatmap image? Which one should be drawn? All of them? At the same time?

Finally, if you want to output the bitmap anyway, you can register a generic parameter and assign it a bitmap, but that seems quite pointless since nobody will be able to parse that data.

--

David Rutten

david@mcneel.com

When do you call the AddCanvasEventHandlers() method? Where do you set the _heatmap class level variable? What happens when your component runs more than once?

--

David Rutten

david@mcneel.com

What if your component generates more than one heatmap? For example when you supply two different image sizes?

But the question is answered by the code you posted. Whatever heatmap is computed last, wins.

I note though that in your Canvas_Prepaint handler you use 'Component' and 'GrasshopperDocument' variables. These are only available inside VB script components, not when you're making an actual component. That code shouldn't compile at all. Maybe you can post your entire component code so I can see if it compiled on my machine?

--

David Rutten

david@mcneel.com

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