algorithmic modeling for Rhino
Hi all
I have a python component in grasshopper which processes some geometry on specific layers. So each time the component is called specific objects are processed and modified based on their layers. If I use a timer for this component and set it to a small interval (100ms), the user can add or modify objects on these layers and they are getting processed automatically.
However, this approach results in poor display performance for larger scenes and for longer sessions rhino eventually crashes. How can I run the component (only once) in case changes were made to the document (such as pasting or dragging objects)? Some kind of event watcher which triggers the python component specifically...
Best
Manuel
Tags:
Hi Manuel,
you have to listen for events on the Rhino document. You'll need to watch both for object events (in case objects are moved between layers, added or deleted) as well as LayerTable events. This involves a lot of code and is far from trivial.
I don't know how Python deals with events, or whether it's possible to figure out whether the code that is currently running is part of an active GH document. I'd recommend switching to C# and Visual Studio for something as code intensive as this.
--
David Rutten
david@mcneel.com
I haven't worked with events, but a possible workaround would be using document.Modify property (along with timer).
Hi,
I am using visual studio to work on my plug-in which includes the more advanced methods to control the layer content etc. These functions are com visible and thus callable using python. Thanks for pointing out the "document.Modify" property. I could "fake" an event watcher using this as recommended. You need to include time.sleep() and set back document.Modify = False to avoid endless looping (definition triggers itself again and again...).
Thanks
M
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
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by