Grasshopper

algorithmic modeling for Rhino

Accessing Rhinocommon DisplayPipeline methods from another function

Dear Members.

This is my first post. I am not entirely familiar with this portal. All I know is that is a really cool place with a lot of really smart people hanging around. So forgive me for my naive questions; I am at very early stages of learning Grasshopper and Rhino SDK. I am somewhat familiar with programming but mostly for web using Javascript and PHP. However, with the new Rhinocommon libraries out, there are really trace amounts of information regarding this new API. This place might actually be the most valuable resource since Grasshopper was completely rewritten against the new API.

So here is a thing I really do not understand in Rhinocommon:

Let's say I am building a plugin which involves a panel with a button. When I press the button, I want a sphere to be drawn. As far as I understand, I have to write a function which would create a sphere and draw in the viewport. I also assume that the drawing is handled by DisplayPipeline method DrawSphere(). So the function would look something like this (I am using c#):

public static void AddSphere(Rhino.Display.DisplayPipeline doc) {
            
            Color color = Color.Bisque;
            Rhino.Geometry.Point3d center = new Rhino.Geometry.Point3d(0, 0, 0);
            const double radius = 5.0;
            Rhino.Geometry.Sphere sphere = new Rhino.Geometry.Sphere(center, radius);
            doc.DrawSphere(sphere, color);
            }

Now, if I want to call that function from a button_click or, for the that matter, any other method, how do I call it?

private void button1_Click(object sender, EventArgs e) {

            AddSphere(???);

            }

Am I on the right track at all?

Any help would be greatly appreciated.

Views: 852

Replies to This Discussion

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