Grasshopper

algorithmic modeling for Rhino

Hi Everyone,

I am trying to draw a preview of a brep within a GH Python component. I was hoping that by creating an instance of the GH_PreviewUtil class and then using the .AddBrep method like so.

preview = Grasshopper.Kernel.GH_PreviewUtil()

preview.AddBrep(brep)

The user would be able to see this brep when they select the GH python component. What I get instead is that the code preview.AddBrep(brep) returns None.

What is wrong with my logic here and how could I actually achieve this functionality within the python component?

Views: 488

Replies to This Discussion

AddBrep doesn't return anything, it just stores the brep wireframe as curves.

What you do is create a new GH_PreviewUtil (but only once), then inside your component call Clear() on it to remove all old geometry, then add your brep and any other bits you want to show.

But note that GH_PreviewUtil will keep drawing even if your component isn't selected, or even when your component isn't even loaded. You'll have to Enable=false and Enable=true the object yourself. This can be rather involved as you have to take into account lots of events.

The C# and VB components provide overrides to directly participating in the component preview drawing. I do not know if Python offers the same functionality.

Thanks David!

Could you please also answer my question here: http://www.grasshopper3d.com/forum/topics/properly-override-gh-acti...

I sent you an email about it long ago. Let me know if you can't find it in your inbox.

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