Grasshopper

algorithmic modeling for Rhino

I searched around and didn't find anything specific to this question in past threads, but I apologize if I've missed a previous answer to this question.

 

Is it possible to get the position of the mouse as a point in rhino space with a scripting component? How would one access the coordinates that show at the bottom of the Rhino viewport indicating the position of the mouse in the model? I don't really care about using a mouse listener to update the information in the model when the mouse moves or clicks (although if this is easy it would be nice also...).

 

Thanks,

 

Andrew

Views: 4155

Replies to This Discussion

Any thoughts anyone? I can get the position of the mouse on screen from Windows.Forms.Cursor.Position but I don't know how to map this onto coordinates in the world XYZ. Since it's already in the Rhino display I know the value exists somewhere, I just haven't been able to track down how to get at it in the SDK.

I tried for about an hour or so but didn't get anywhere. I've done this sort of thing before from within a GetPoint operation, but I don't know how to do it without it. I'm still about as mystified by the RhinoView/RhinoViewport/Frustrum/Camera bits in the SDK as I was before RhinoCommon.

 

--

David Rutten

david@mcneel.com

Poprad, Slovakia

well thanks for taking a look - if you can't figure out how then I don't feel so bad that I can't!

Here's a sample python script that gets the 3d points on the near and far frustum planes for a given viewport. It should be pretty easy to convert to VB or C#

 

https://gist.github.com/1023456

 

-Steve

I added some functions/properties for the next WIP which hopefully will make this clearer... hopefully;)

 

On RhinoView and RhinoViewport, I added

ClientToScreen and ScreenToClient which help convert a 2D point between screen coordinates and client window coordinates of the view and viewport. These act just like PointToScreen and PointToClient on the Control class in Windows.Forms

http://msdn.microsoft.com/en-us/library/system.windows.forms.contro...

 

On RhinoView I also added WorldToClient and ClientToWorld for converting between a 2d pixel coordinate on the viewport and a point or line in the world cordinates.

public Line ClientToWorld(System.Drawing.Point clientPoint);

public Line ClientToWorld(Point2d clientPoint);

public Point2d WorldToClient(Point3d worldPoint);

 

Thanks,

-Steve

Heyo!

Steve,

Are these available when using GH with Rhino 4? Intellisense picks them up, so I guess I get confused when they're not working.  If they do work, can you point me in the right direction to implement the

ClientToWorld(System.Drawing.Point clientPoint )...

the client point is 'System.Windows.Forms.Cursor.Position'  and it returns a 2D point in world coordinates, right?

Thanks!

Hi,steve How to create a viewport?

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service