i am coding a component by c#,which has several input(such as num slider),as we all know,if one drags or change the value of numslider,the component will refresh it self and do solveInstance().so ,when the component go to solveInstance,how to know which input(slider) raise this?
Thank you!
Save the value that was input into the component class. Then run a check during solveinstance on which value has changed.
i have tried your method before,it is not so perfect ,because before you are draging slider,when you release the mouse,the component will excute onetime “solveInstance”,this is not i want.
Are you trying to calculate for all values of the slider as it changes?
Or do you want to abort the solving process if the value being changed is not the one it is looking for?
i just want to recognize which slider(A slider and B slider), if i am draging and release A slider,the component can recognize there is A slider draging and release.your method i have tried,just can recognize when draging,but if i release,the component cannot recognize this "mouse release " happened on which slider .
@DavidRutten might have more insight into the slider component as I don’t know if the release will schedule a new solution or not.
this is my code(when draging,component can recognize,but release no,you can see when i drag N1 slider,the output “N” doesnot change,but when i release mouse ,the “N” add one)
I don’t quite understand what you’d like to achieve.
N
isn’t increased when oldn1 != n1
yes,but when you release mouse after draging n1,the N will add one.i am seeing your code,thank you
By testing with the following:
The recorder component does not trigger when you release the mouse, ie your component will never trigger on mouse release.
Because if it did trigger out mouse release, the list of recorded value would double up the 0.239.
The only solution I can think of is to override the custom attributes.
Example here:
https://developer.rhino3d.com/api/grasshopper/html/8a7974ab-7b2b-4f48-84d0-6e81b184e6b0.htm
You need to override the mouse up event.
https://developer.rhino3d.com/api/grasshopper/html/M_Grasshopper_GUI_Canvas_IGH_ResponsiveObject_RespondToMouseUp.htm
Check the mouse location is on top of a connected slider and the right slider. Then run your increment.
Thank you Christopher,i am seeing
i have tried your code,and your code is good,but the i tried same code with yours in C# componnet instead of C# script component,still add one when release mouse.
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddNumberParameter("N1", "", "", GH_ParamAccess.item);
}
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddNumberParameter("N", "", "", GH_ParamAccess.item);
}
double n1 = 0;
double oldn1 = 0;
double sum = 0;
protected override void SolveInstance(IGH_DataAccess DA)
{
DA.GetData("N1", ref n1);
if (oldn1 != n1) //slider value change
{
oldn1 = n1;
DA.SetData("N", sum);
return;
}
sum++; //DO something
DA.SetData("N", sum);
}
i tried your data recoder experiment,in my case,it still add one!because i use rhino5,so i change to rhino6,the result is the same with yours.so the answer is :rhino5 slider trigger a refresh and rhino6 no.