GetPlane in RhinoCommon

Hi there,

I just saw this way to let the user define a plane and I think it’s very nice. Actually I have been looking for this. It let’s one chose an Xaxis and then consecutively Y. The nice thing is that you pretty much see the outcome of the operation in advance.

I did not find this in the Rhino.Input namespace.
Any ideas here?

Thanks,
T.

image

Where did you find this @tobias.stoltmann?

@csykes in a plugin for rhino called Acapulco.
So it might be the case that this is a feature developed for the plugin, right?

@tobias.stoltmann, I don’t personally recognise the screenshot, so I’d guess so. You may be able to de-compile the plugin with ilspy and find the answers in there :slight_smile:

Hi @tobias.stoltmann,

it is likely a point picker with a dynamic display override to draw geometries. Below is a simple python example which might help. Use _EditPythonScript to open and run it. If you pick the third point with elevation (hold CTRL) before you pick, you’ll see the geometries follow dynamically.

GetPlaneRectangle

GetPlaneRectangle.py (2.9 KB)

_
c.

4 Likes

Fantastic work @clement !
Thank you for the code!

1 Like

@clement
This is indeed fantastic work! Thanks a lot!

1 Like

@clement, a question though.

When you do the following:

def OnMouseMove(self, e):
    Rhino.Input.Custom.GetPoint.OnMouseMove(self, e)

what kind is “e” in this case.
I am trying to reproduce this in C# and I have to admit that I am not very profound with events.
(I’d like to learn though.)

As later in the code you refer to

e.Display.DrawArrow(x_line, self.XColor, 15, 0)
e.Display.DrawArrow(y_line, self.YColor, 15, 0)
e.Display.DrawArrow(z_line, self.ZColor, 15, 0)

I assume that during the event (e.g. OnMouseMove) you refer to the current viewport?

Thanks in advance,
T.

Hi Tobias,

it is Rhino.Input.Custom.GetPointMouseEventArgs but in this delegate it is just calling the base class, so it is unused. The script will work the same if you remove the whole function.

I’ve left it in for reference because usually it is a bad habit to perform calculations directly in the OnDynamicDraw function (it is meant for display and called for every frame). The code would be technically better if it makes all calucations in the OnMouseMove function and stores the data in class wide variables which are then accessed from OnDynamicDraw.

OnMouseMove is called but empty. But OnDynamicDraw is called in all views by default on every frame, eg. If you change your view orientation. You can get the view it draws at a time from e.Viewport. Does this help ?

_
c.

@clement, thanks for the detailed explanation first of all.

    public void OnDynamicDraw(??? e)

I think basically I am struggling with the type of event that is passed into the function. Sorry if I am not able to articulate myself more specific, I am kind of lost in this topic.

I think once I have understood what event and more specifically which even type is called I can make up my mind about what you epxlained.

Thanks,
T.

Hi Tobias,

i am really no C# expert but guess for OnMouseMove you would do this:

protected override void OnMouseMove(GetPointMouseEventArgs e)
    {
      //Your code here
     
      // call the base class
      base.OnMouseMove(e);
    }

And for OnDynamicDraw you would do this:

protected override void OnDynamicDraw(GetPointDrawEventArgs e)
    {
      // Your code here

     // call the base class
     base.OnDynamicDraw(e);
    }

_
c.