Hello everyone, I am hoping if anyone could help me with a problem I have stumbled upon and tryinf to fix for ca couple of days now.
I am working on a project that consists of automating a series of grasshopper definitions. The python scripts open the grasshopper definitions, places data, sets slider values, gets the final data and places it an another definition and so on…
One of my definitions uses anemone, processes data in a loop and takes quite some time to process.
However, even though the definition hasn’t arrived at the final state, the script keeps on going, placing wrong data in the ouput component and thus breaking the rest of the automation process.
I have spent days trying to find a solution such as trying to schedule a solution, using events to trigger the rest of the code, changing the grasshopper definition to buffer data at some point and so on, but I haven’t made any progress in solving this problem… I have alrady explored a lots of existing topics on the forum attempting to solve the problem.
Could someone look at my code and tell me if there are any possible solutions and how to correct my code? Your help would be very much appreciaited
Here is my code, before doing any alterations on my side:
Here is where the code is supposed to wait for the grasshopper definition to finish processing
# Set config sliders
config_sliders = self.get_sliders(self.config.master_plan_sliders)
self.set_slider_values(self.config.master_plan_sliders, config_sliders)
# Place data in input
self.place_data('COMPONENT_NAME', block_data.main_data)
# Code keeps on going here before the previous line has finished processing
This is what the def place_data looks like:
# Get the component object
# This function returns the component that has a particular nickname
inputComponent = self.find_by_nickname(component_name)
# Clear the component data if needed
if clear_data:
inputComponent.PersistentData.Clear()
inputComponent.ExpireSolution(True)
inputComponent.SetPersistentData(data)
inputComponent.ExpireSolution(True)
Thank you for your time and attention and looking forward to speaking with you