Hi,
I try to develop a component, which is able to controll sliders, can trigger the solution process and is able to read updated number parameters after a solution run. It worked quite fine with Rhino 5 - but due to the update to version 6, I have got some trouble.
Aim:
- Update some slider values
- Perform solution once
- Read number values
Current behavior in v6:
After each slider change the solution is calculating
Current code example:
// Update some slider values
var doc = component.OnPingDocument();
foreach (var guid in guids)
{
var sliderObject = doc.FindObject(guid, true);
if (sliderObject is Grasshopper.Kernel.Special.GH_NumberSlider)
{
Grasshopper.Kernel.Special.GH_NumberSlider slider = (Grasshopper.Kernel.Special.GH_NumberSlider)sliderObject;
slider.Slider.Value = (decimal)para.Value;
slider.ExpireSolution(false);
}
}
// Perform Solution
doc.NewSolution(false);
// Read values
double value = Double.NaN;
var numberObject = doc.FindParameter(guid);
if (numberObject is Grasshopper.Kernel.Parameters.Param_Number)
{
Grasshopper.Kernel.Parameters.Param_Number number = (Grasshopper.Kernel.Parameters.Param_Number)numberObject;
if (number.VolatileData.PathCount > 0)
{
value = ((GH_Number)number.VolatileData.get_Branch(number.VolatileData.Paths[0])[0]).Value;
}
}
I thought I would get this behavior:
ExpireSolution(True): It sets the ‘expired’ flag on the component you call this method on and all objects that depend on that component. Basically everything downstream of it. When it’s done setting all these ‘expired’ flags, it will place a call to GH_Document.NewSolution(False).
ExpireSolution(False): Does the same as the previous one, except it doesn’t tell the document to re-solve itself. Use this method if you want to expire a bunch of different components before attempting a new solution.
NewSolution(True): This will set the ‘expired’ flags of all components inside the document and resolves everything. This is carpet bombing, rarely should you use this method.
NewSolution(False): This will only resolve those objects that have their ‘expired’ flags set.
Looking forward to get any help. Thanks!
Cheers,
Daniel