Getting a component to watch a point

Bit obscure, but how does the point parameter component actually work?

i’ve got a point in Rhino and I have a python component that queries it and returns its attributes - however, when the point is moved or changed, this doesn’t signal the component to recompute - which makes sense, cause I haven’t asked it to. Is there a way to do this?

I.e. Is there a way to embed the point parameter components ‘listener’ functions in a custom python component?

Thanks in advance.

Mattew.

I probably don’t understand your question… Maybe I’m not the only one?

When I move the Rhino point, both the standard and Python components update when I stop moving the point, i.e., ‘onMouseUp’ event.

ptsPython_2019Jul21a
ptsPython_2019Jul21a.gh (7.7 KB)

Maybe you want a ‘onMouseMove’ event instead?

https://discourse.mcneel.com/search?q=mousemove%20event%20python

Thanks for your reply Joseph.

my component gets its points input via the following function for example,

LayerName = "Default"
objects = Rhino.RhinoDoc.ActiveDoc.Objects.FindByLayer(LayerName)

So it isn’t being driven by a GH point parameter component as in your example. I’m just wondering if there is a way that I could add on something that tells the component to run the script again when something on that layer is moved (i.e. like the point parameter component)

I will have a go seeing if there is something in the Rhino.UI library that helps out.

Cheers.

Matthew.

The Geometry Pipeline does that, with updates. If you don’t want to use that you’ll have to handle a bunch of Rhino document events, figure out if the change affects your script and then trigger an update some (brief) time later.

If you only care about changes to existing objects rather than also the addition of new objects to your layer, you may be able to get away with using the Grasshopper object ID tracking+expiration api. But that requires having your own component, I don’t think you can make that work from a script.

Thanks David. I’ll look into it. :smiley: