Mouse Click Event Handler

Hello All…

Let me start by saying that this is my first Rhino plugin and there is a lot about how plugins work that I probably havent grasped yet. The project at hand is a simple 2D digitizing plugin. It is for drawing 2D curves only. Basically, the user will select a tool, such as a poly Line in Rhino. After that a plugin containing a mouse click event handler will listen for a left mouse click. When it detects one, it will emulate a left mouse click at a screen coordinate determined by data input from encoders. The encoder data is not a problem and is available inside or VB.net. A right mouse click will end the command.

The input devices will be 2 encoders feeding X and Y position data and a pendant with 2 buttons. One button will emulate a left mouse click and one will emulate a right mouse click. The simplest solution I can come up with is an event handler inside a plugin. Another option would be for the plugin to just move the mouse based on position data…if that is possible.

Problem is that since I’m new to plugins, I don’t know where to start or even if this is the right approach. Any push in the right direction would be greatly appreciated.

Thanks

Hi Ross,

Most mouse operations can be handled by a couple of RhinoCommon classes:

Rhino.Input.Custom.GetPoint
Rhino.Input.Custom.GetObject

There are a few variations of these in RhinoCommon. But these two classes are used in just about every command in Rhino.

Since you are interested in points, you might look at this sample, which demonstrates GetPoint.

Regarding passing in coordinates locations from a digitizer or encoder, the GetPoint class will receive this type of input automatically if send from a digitizer plug-in. I’m in the process of typing up a sample of this for you…

– Dale

Hi Ross,

I’ve uploaded a sample digitizing plug-in project for you to review.

If you notice, the plug-in class inherits from DigitizerPlugIn, not PlugIn. Thus, there are some additional virtual function you will need to deal with.

The real magic is that the plug-in contains a separate thread that receives in put from the digitizer. As input is obtained, it is forward to Rhino by way of SendPoint, which includes 3D location and button and keyboard states. It is this information that is used by Rhino’s GetPoint class (as if it were obtained from a mouse).

Let me know if you have questions…

– Dale

When I run the example it is trying to load Rhino4, which doesn’t exist and it fails. How do I fix it to reference Rhino5? I’ve looked through the files in the project and don’t see any reference to the Rhino exe.

Thanks

Hi Ross,

Rhino4.exe is the name of the executable for Rhino 5 32-bit.

RhinoCommon plug-in only work with Rhino 5.

http://www.rhino3d.com/download/rhino/5/latest?PageSpeed=noscript

I’ll try to grab a screen shot. I have Rhino5 64 bit. Some of the samples produce an error when debugging that the reference to Rhino4.exe can not be found. The plugin still runs in Rhino. I just have to build and install it every time. The projects I create from scratch all work fine, so I just created a new project and modified it according to your sample. I’m working on the encoder side of this now, but I’m sure I’ll have more questions regarding how to get the encoder position data over to Rhino. I’m guessing I would use GetPoint().