algorithmic modeling for Rhino
SolveInstance may be called (more than once) during any solution. These are the conditions:
So assuming the component is all hooked up, enabled and expired (i.e. something happened to it since the last solution that caused it to go stale), then SolveInstance will be called. It may be called once, or many times depending on the access flags of the input parameters and the datatree layout inside those parameters.
If you want to do something one once per solution (i.e., the first time SolveInstance is called within any given solution) then you can use the DA.Iteration field. If the iteration=0 then SolveInstance was just called for the first time within the current solution.
If you only want to do something once (ever!) then you should probably define a class level boolean that keeps track of this:
private bool m_didTheSpecialThing = false;
SolveInstance(blahblah)
{
if (!m_didTheSpecialThing)
{
m_didTheSpecialThing = true;
DoSpecialThing();
}
...
}
There are also methods to do with the objects movement through documents that you may find interesting to override:
--
David Rutten
david@mcneel.com
Poprad, Slovakia
Thanks a lot David. Very helpful as usual!
The code is working again with an `if(variable==null){do the stuff once}` statement within the SolveInstance() method which allows a specific method to run only once.
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
© 2024 Created by Scott Davidson. Powered by