SetPersistentData issue - Grasshopper2024-03-29T00:58:53Zhttps://www.grasshopper3d.com/forum/topics/setpersistentdata-issue?commentId=2985220%3AComment%3A1244220&feed=yes&xn_auth=noYes, you were right, converti…tag:www.grasshopper3d.com,2015-03-18:2985220:Comment:12447432015-03-18T09:44:45.314ZDaniel Gebreiterhttps://www.grasshopper3d.com/profile/DanielGebreiter
<p>Yes, you were right, converting my list of doubles to a GH_Structure first has done the trick.</p>
<p>As desired, the input is now disconnected, new persitent data is set and the solution recomputes using the new data. </p>
<p>Following your comments about this not exactly being best practice has made me a bit nervous about this being the correct approach though. I'll see how it behaves in practice!</p>
<p></p>
<p>Many thanks!</p>
<p></p>
<p>For reference, here's the corrected…</p>
<p>Yes, you were right, converting my list of doubles to a GH_Structure first has done the trick.</p>
<p>As desired, the input is now disconnected, new persitent data is set and the solution recomputes using the new data. </p>
<p>Following your comments about this not exactly being best practice has made me a bit nervous about this being the correct approach though. I'll see how it behaves in practice!</p>
<p></p>
<p>Many thanks!</p>
<p></p>
<p>For reference, here's the corrected code:</p>
<p></p>
<p>GH_Structure<GH_Number> data = new GH_Structure<GH_Number>();<br/>foreach(double d in myData)</p>
<p>data.Append(new GH_Number(d));<br/> }</p>
<p></p>
<p></p>
<p><span>IGH_Component c = GHDocument.FindComponent(guid); </span><span><br/></span></p>
<p>GH_PersistentParam<GH_Number> myParam = c.Params.Input[1] as GH_PersistentParam<GH_Number>;<br/><br/> myParam.PersistentData.Clear();<br/> myParam.SetPersistentData(data);<br/> myParam.RemoveAllSources();<br/> myParam.VolatileData.Clear();</p>
<p></p>
<p>c.ExpireSolution(false);</p>
<p>GHDocument.NewSolution(false);</p>
<p></p> How is it different from manu…tag:www.grasshopper3d.com,2015-03-18:2985220:Comment:12446672015-03-18T09:07:45.510ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<blockquote><p><span>How is it different from manually unplugging an input source and entering the values into the "set multiple numbers" field?</span></p>
</blockquote>
<p></p>
<p>When you do it manually it doesn't happen during solutions. Because during solutions the UI is locked. </p>
<p></p>
<p>I think if you supply a List of doubles, it uses the SetPersistentData(params object[] values) overload, and that indeed won't work.</p>
<p></p>
<p>To be absolutely on the safe side, I'd recommend…</p>
<blockquote><p><span>How is it different from manually unplugging an input source and entering the values into the "set multiple numbers" field?</span></p>
</blockquote>
<p></p>
<p>When you do it manually it doesn't happen during solutions. Because during solutions the UI is locked. </p>
<p></p>
<p>I think if you supply a List of doubles, it uses the SetPersistentData(params object[] values) overload, and that indeed won't work.</p>
<p></p>
<p>To be absolutely on the safe side, I'd recommend getting the GH_Structure<GH_Number> from the PersistentData property and dealing with it directly.</p> oh I see what you mean now wi…tag:www.grasshopper3d.com,2015-03-18:2985220:Comment:12448102015-03-18T09:02:04.251ZDaniel Gebreiterhttps://www.grasshopper3d.com/profile/DanielGebreiter
<p>oh I see what you mean now with doing this "during a solution":</p>
<p>I presume you mean that I am expiring components and forcing a recompute while I'm still inside the SolveInstance of a component?</p>
<p>oh I see what you mean now with doing this "during a solution":</p>
<p>I presume you mean that I am expiring components and forcing a recompute while I'm still inside the SolveInstance of a component?</p> Hi guys,
thanks for your rep…tag:www.grasshopper3d.com,2015-03-18:2985220:Comment:12445752015-03-18T07:58:04.393ZDaniel Gebreiterhttps://www.grasshopper3d.com/profile/DanielGebreiter
<p>Hi guys,</p>
<p></p>
<p>thanks for your replies.</p>
<p></p>
<p>@David: myData ist simply a list of doubles. Would I have to convert to a list of GH_Number first?</p>
<p></p>
<p>@David and Giulio: Out of curiosity, why is it a bad idea? </p>
<p>How is it different from manually unplugging an input source and entering the values into the "set multiple numbers" field?</p>
<p></p>
<p>I thought of this as a very simple way to achieve a feedback loop. </p>
<p>My solution:</p>
<p>Initial data…</p>
<p>Hi guys,</p>
<p></p>
<p>thanks for your replies.</p>
<p></p>
<p>@David: myData ist simply a list of doubles. Would I have to convert to a list of GH_Number first?</p>
<p></p>
<p>@David and Giulio: Out of curiosity, why is it a bad idea? </p>
<p>How is it different from manually unplugging an input source and entering the values into the "set multiple numbers" field?</p>
<p></p>
<p>I thought of this as a very simple way to achieve a feedback loop. </p>
<p>My solution:</p>
<p>Initial data -> SOLUTION -> adjusted data</p>
<p>After the fist computation, the initial (volatile) data is disconnected from the solution inputs. Instead, the adjusted data inserted as persitent data into my special input component (by finding the component in the document, as above). The solution then recomputes with the adjusted data.</p>
<p></p>
<p>I guess thinking about it now I could simply put the initial values into a separate input node.</p>
<p>I'll give this a go now but I guess I'll fall on my face yet again if the persistent data doesnt update...</p> What's the type of myData in…tag:www.grasshopper3d.com,2015-03-17:2985220:Comment:12443272015-03-17T18:34:15.927ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>What's the type of myData in the first block of code?</p>
<p></p>
<p>Also you should not be doing this during a solution. When is this code triggered?</p>
<p>What's the type of myData in the first block of code?</p>
<p></p>
<p>Also you should not be doing this during a solution. When is this code triggered?</p> Hi Daniel
where are you tryin…tag:www.grasshopper3d.com,2015-03-17:2985220:Comment:12442202015-03-17T17:06:05.971ZGiulio Piacentinohttps://www.grasshopper3d.com/profile/GiulioPiacentino
<p>Hi Daniel</p>
<p>where are you trying to do this? The Grasshopper SDK does not allow this to happen at solution time. But you could make these adjustments at other points in time, for example from another form.</p>
<p>Giulio<br/>--<br/>Giulio Piacentino<br/>for Robert McNeel & Associates<br/>giulio@mcneel.com</p>
<p>Hi Daniel</p>
<p>where are you trying to do this? The Grasshopper SDK does not allow this to happen at solution time. But you could make these adjustments at other points in time, for example from another form.</p>
<p>Giulio<br/>--<br/>Giulio Piacentino<br/>for Robert McNeel & Associates<br/>giulio@mcneel.com</p>