Grasshopper

algorithmic modeling for Rhino

Hello

I am trying a C# component to be triggered by changes on a file stored in my computer.

The class FileSystemWatcher can check that and trigger a desired behavior on a function, but how can I make the FileSystemWatcher to continue tracking the desired file once the component has runned??

The FileSystemWatcher has to be a member of the component or can be declared on the code part of the component??

Thank you very much.

I am a bit confused with the topic, sorry if the question is not precise at all.

Views: 381

Reply to This

Replies to This Discussion

There is a nice class that David already added to the Grasshopper SDK called "GH_FileWatcher." Essentially, you can set up a new file watcher and attach it directly to a delegate method you want to call whenever the file changes. See the attached definition + C# script for an example. If you're writing a custom C# component (as opposed to a script object) you may need to adapt the behavior a little.. but most of the code should be valid. 

Attachments:

Thank you very much Andrew

Looks very straightforward.

Ooh, this is super useful for me too. Thanks Andrew!

glad it helped somebody else as well

Hi Andrew,

               Quick question regarding this code. Once 'something happened', how can we track the changed file log? Is there a way to read excel from the change log?

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2019   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service