Is there a method in Rhinocommon to physically move the mouse pointer? The sketch command follows mouse movement. I want to use that command but control the mouse using x and y points input from an external device. The point data is already available in the plugin. Just not sure how to control the mouse pointer using that data.
What are you trying to achieve? There may be a more convenient way to get data from an external source into rhino.
Trying to move the mouse pointer using digitizer input. All of that works great and I can place a point using the digitizer, but the sketch command draws a line based on mouse movement, so I need to move the mouse programmatically.
What I mean is that you could set up a display conduit that shows like a preview of the digitizer input and after the user is finished you could put the resulting curve or poly line in the rhino document.
That would work. That way I could have the user select a point sample rate. No point in sampling 1000 points for a 3" line. The only problem is that there would be no way to tell which command to use to build the entity after the fact. You would either create strait lines between the points or create a curve through the points.
Another possibility would be to just start a poly_line command and place a new point every time a point is sampled. That may be how sketch basically works. The mouse wouldn’t move but the curve would draw in real time.
From a user perspective, it would have more wow factor if the mouse pointer just tracked the digitizer and drew the line in real time. In chatting with Dale, he did mention that the sketch command doesn’t draw a clean line, so this feature is more a sales gimmick than anything else. Anyone wanting any degree of precision would use the line, curve, circle, etc. commands rather than sketch.
Wouldn’t it be easier to just move the mouse rather than build a separate preview display?
It sure is simpler to just pretend-move the mouse, but the user “must behave”. That is, they must not move the actual mouse, nor must they alt-tab to another program, just to name a few things.
The way I see this is that the user starts a command “drawWithDigitizer”, then in the context of the command you capture the digitiser data and show a preview of the data drawn. The command ends when the user presses enter for example. Then you have the captured data in the context of the command and you can make a polyline, curve, or what ever else you would like to do.
Are you deriving your plug-in class from a DigitizerPlugIn class? There are virtual functions on that class that are specific for working with digitizers.
That makes sense. Trying to get an average user to behave would be more challenging than the software.
It is derived from the DigitizerPlugin class. I’m using SendPoint() to place points.
I noticed a Sketch command on the digitizer menu.
When executed, it prompts to “Hold the button down”.
Which button is that? Is there a method or command that gets called when “the button” is pressed/held? I tried holding the button that I have set up to place points and that didn’t do anything. I didn’t see anything obvious in the DigitizerPlugin class.
I’m not sure. @tim knows a lot more about digitizer plug-ins than I do. Unfortunately (or fortunately for Tim) he is out on vacation this upcoming week.
Tim is a lucky guy. I haven’t seen a vacation in years. I’ve got a custom sketch function working pretty well. It’s a little slow though. I may try something along the lines of what Menno suggested. Instead of building the line on the fly, save the points in an array, then build the line/object after the fact using the saved points. It wouldn’t build it on the fly, but it would be much faster.
I did get the _DigSketch to work, but because of the way I’m handling the digitizer data input, it may not be working like it’s supposed to.
Ah, I had no idea that such a thing as DigitizerPlugIn existed. Maybe there’s an even better way to do this than I suggested using the functionality offered in such a dedicated plug-in.
Rhino does not have function(s) to move the mouse cursor. The best method do to this, I guess, is to use p/invoke to call SetCursorPos().