Grasshopper

algorithmic modeling for Rhino

From my understanding a Grasshopper component is executed every time that its inputs are changed.

I want to be able to count the number of times that a component has been executed using sticky, but I'm un-sure how to do it could anyone please give me some sample code in Python?

Thank you!

Views: 563

Replies to This Discussion

You want to count how often your own python components executes, or do you want to measure how often some other component executes?

This thread has a couple of approaches to this. I'm sure there probably are properties of the GHPython component itself which keeps track of how many times it has been executed etc. If so you can access it via ghenv.Component inside the GHPython code..

David thank you for your reply, yes I want to count the number of times my own python component executes.

That just requires a static integer that you increment at the start of your main def. I'm sorry but I don't know how to declare a static variable in Python.

David I believe I found the answer in this GH file for future reference Ive attached it here 

Attachments:

You could also do it with a static integer the approach below uses the sticky

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service