algorithmic modeling for Rhino
There is no xyz coordinate. The mouse is an XY coordinate on the screen, which means there is a whole family of xyz coordinates 'under' the mouse.
In Rhino.UI there's a MouseCallback class, that's probably what you need.
--
David Rutten
david@mcneel.com
Tirol, Austria
Hi Pepe,
As we discussed yesterday, here's an example of the DynamicDraw event inside a C# component. Using this method you are limited from this point forward to generate all geometry within the script.
Steve Baer posted an example written in Python on the Rhino forum:
http://discourse.mcneel.com/t/dynamic-drawing-of-lines-based-on-cho...
There's a small issue. For the GH canvas to become responsive again you have to run the script twice.
hey vicente. sorry for the delay. Im on now !
ok.
I think I have an overview of your code.
first: is a brilliant solution. I m learning a lot !.
some questions:
the key is to handle an event.
I suppouse which is the sender class : Rhino.Input.Custom.GetPoint
I suppouse where the event store data : Rhino.Input.Custom.GetPointDrawEventArgs
but what about the delegate ?
Im not familiar with that classes in rhinocommon, but Icant make out the delegate.
however it works!
( something like public delegate void pointEventHandler (... , ...)
by other hand when you use Point3d and when Point3f?
and finally
in your iteration
Mesh m = meshes[i].DuplicateMesh();
mean you duplicate the rectangle i . is a copy. four vertex.
so when you call 5th and 7th index .... how they do exist ?
First, check the eventmousemoveonsrf.gh definition I posted at the end of this thread.
I wasn't aware of this when I posted the definition that uses the getpoint class, but some methods had been added that help you easily convert the mouse pointer coords (that you get with the MouseCallback class or Forms.Cursor.Position, for example) to world coords. Not relying on getpoint allows you to have a more interactive definition, you are not limited to script everything you want to be interactive on one component, but wont allow you to use the built in snaps (you have to create your own).
We just need to handle the event, the code for raising the event is already done for us, delegates and all. We just need the line "gp.DynamicDraw += Draw;" to tell it that when DynamicDraw event is raised Draw will be called.
Point3d uses double precision numbers, Point3f (f comes from float, I presume) uses single precision numbers. Meshes usually use single precision numbers to store its vertex coordinates since they consume less memory and are faster. NURBS surfaces and curves use double precision since they don't require so many (control) points and therefore can afford to be more accurate.
My input meshes already have holes in them (scaled 50% to the perimeter) therefore they already have 8 vertices. The script just scales the inner vertices, depending on the distance to the pointer, in a range from 200% to a number that tends to 0% (but never reaches it unless the distance is infinite).
Also, there's info here and here to get the mouse position without having to use the GetPoint class. Steve Baer added some methods to convert it to 3d space (well, to create a line from the camera to the point that you then have to intersect with something to get a 3d point, like the view's cplane). This won't work with snaps.
Using System.Windows.Forms.Cursor.Position you have to update the component every time you want to get the mouse position (rather than using an event that triggers when the mouse moves). Having to update the component can be useful if you have something continuous running, like a Kangaroo simulation. See attached.
Hi Vicente nice stuff, it's amazing! there any way to activate and stop the boolean toggle with just a click in the viewport?
The attached file will toggle the boolean when double clicking on a viewport.
In this case I use an event that only updates the component when the double click happens (I used part of the code posted in the second thread to create the event).
You could modify this to override OnMouseMove if you want the grabbing of the cursor position to also be event based.
thanks Vicente!
regards,
E.
Last one, this does the same thing as the first one but allows to generate all geometry using components, no scripting. The component updates only when the mouse moves.
Ok, last one for real. This time when the mouse is over the surface it snaps to it (like the OnSrf snap). When it's not it goes back to returning a point on the XY plane.
Hi,
why it does not work anymore when i change the code?
http://www.grasshopper3d.com/forum/topics/mousecallback-failed
Panda.
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by