Dynamically updating geometry during curve point editing

So I’ve been mucking about learning about conduits, with the end goal of dynamically drawing some stuff during the control-point editing of a curve. What events to I need to latch on to to be able to do that?


Dynamic drawing should occur on the “overlay” channel. Does this help?

I think so but I’m not ready to draw yet, just wrapping my head around events, which I haven’t dealt with since working on my website sometime last decade… If I want to do something when a particular object is modified, do I set up a ‘global’ sort of handler that has to check if the object I want is what triggered it, or can I attach something directly to the target object?

Okay I think I’m figuring out the event stuff, and getting the dynamic-dragging part to work isn’t exactly the top priority…a bigger issue I think is, if I have some geometry in the model that I want to have change when some other geometry gets changed…what do I have to do(if anything) to make sure that undo/redo keep working as expected?

When using our event watchers, when you detect an event, you should set a flag of some kind (denoting that the event has occurred) and then quickly return out of your handler, keeping in mind that your plug-in is not the only think watching for the event.

Then at an appropriate time, such as when Rhino is idle (Rhino.RhinoApp.Idle), check the flag and, if dirty, take the appropriate action. This is referred to as lazy evaluation. By doing this, Rhino will run quickly (as others might be watching the event too) and the risk of crashing Rhino will be reduced (again, as other might be watching the event and, thus, also incorrectly modifying the document).

Also, remember that Undo is command based. But since you code is not running a command, you will have to create an Undo record yourself, when modifying document objects. Below is an example of how you can do this.

def SampleAddCircle():
    plane = Rhino.Geometry.Plane.WorldXY
    circle = Rhino.Geometry.Circle(plane, 5.0)
    undo_record_sn = sc.doc.BeginUndoRecord("SampleAddCircle")
    if undo_record_sn > 0: