Avoid recompute the component when change a parameter. - Grasshopper2024-03-29T10:38:02Zhttps://www.grasshopper3d.com/forum/topics/avoid-recompute-the-component-when-change-a-parameter?feed=yes&xn_auth=noPhase should be Blank if the…tag:www.grasshopper3d.com,2016-12-06:2985220:Comment:16529152016-12-06T00:19:28.186ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>Phase should be Blank if the parameter has expired, or Computed/Collected if it hasn't.</p>
<p>Phase should be Blank if the parameter has expired, or Computed/Collected if it hasn't.</p> Apparently this does not work…tag:www.grasshopper3d.com,2016-12-05:2985220:Comment:16527232016-12-05T22:46:45.212ZLionelhttps://www.grasshopper3d.com/profile/Lionel
<p>Apparently this does not work the same for custom GH_Goo<T>.</p>
<p></p>
<p>Having such a flag on Input sources that would tell which inputs are part of the recompute and which are not would be very helpful.</p>
<p></p>
<p>I don't know if it makes sens for a future revision ...</p>
<p>Apparently this does not work the same for custom GH_Goo<T>.</p>
<p></p>
<p>Having such a flag on Input sources that would tell which inputs are part of the recompute and which are not would be very helpful.</p>
<p></p>
<p>I don't know if it makes sens for a future revision ...</p> Hi there,
I've tested severa…tag:www.grasshopper3d.com,2016-12-05:2985220:Comment:16528232016-12-05T22:42:39.319ZLionelhttps://www.grasshopper3d.com/profile/Lionel
<p>Hi there,</p>
<p></p>
<p>I've tested several ways to achieve that. Mainly the "cache" solution and some "event based" solutions.</p>
<p>The matter with the event solution is that you need to proper register and unregister when a source is connected disconnected. So fare I have not been able to make it work properly.</p>
<p></p>
<p>Listen to Source changes</p>
<p>this.Params.ParameterSourcesChanged += OnSourceChanged</p>
<p></p>
<p>Decide or not to listen to a given…</p>
<p>Hi there,</p>
<p></p>
<p>I've tested several ways to achieve that. Mainly the "cache" solution and some "event based" solutions.</p>
<p>The matter with the event solution is that you need to proper register and unregister when a source is connected disconnected. So fare I have not been able to make it work properly.</p>
<p></p>
<p>Listen to Source changes</p>
<p>this.Params.ParameterSourcesChanged += OnSourceChanged</p>
<p></p>
<p>Decide or not to listen to a given source</p>
<p>this.Params.Input[i].Sources[j].SolutionExpired</p>
<p></p>
<p>I have just remarked that when you enter SolveInstance "this.Params.Input[i].Sources[j].Phase" seems to be set to :</p>
<p>- "Computed" for each parameter that has changed during the recompute.</p>
<p>- "Collected" if it has not changed.</p>
<p></p>
<p>So that migth be a proper way to achieve this kind of behaviour. Each time you enter solve instance check for every Input Param and for every Source their Phase flag.</p>
<p></p>
<p>Lionel</p>
<p></p>
<p></p>
<p></p> Isn't this normally done by s…tag:www.grasshopper3d.com,2016-01-13:2985220:Comment:14382172016-01-13T19:18:07.384ZNik Willmorehttps://www.grasshopper3d.com/profile/NikFromNYC
Isn't this normally done by splitting a program into separate Grasshopper script components?
Isn't this normally done by splitting a program into separate Grasshopper script components? This seems to work..
Private…tag:www.grasshopper3d.com,2016-01-11:2985220:Comment:14364362016-01-11T14:23:38.254ZDaniel González Abaldehttps://www.grasshopper3d.com/profile/DaniAbalde
<p>This seems to work..</p>
<p>Private Sub UpdateOutput()<br/> rhinoapp.WriteLine("Updated")<br/>Output.ClearData()<br/>Output.AddVolatileDataList(New gh_path(0), curvas)<br/>Output.CollectData()<br/>Output.ComputeData()<br/>Output.OnSolutionExpired(True)<br/> End Sub</p>
<p></p>
<p></p>
<p>This seems to work..</p>
<p>Private Sub UpdateOutput()<br/> rhinoapp.WriteLine("Updated")<br/>Output.ClearData()<br/>Output.AddVolatileDataList(New gh_path(0), curvas)<br/>Output.CollectData()<br/>Output.ComputeData()<br/>Output.OnSolutionExpired(True)<br/> End Sub</p>
<p></p>
<p></p> I meant, just update the curv…tag:www.grasshopper3d.com,2016-01-11:2985220:Comment:14361862016-01-11T12:29:40.642ZDaniel González Abaldehttps://www.grasshopper3d.com/profile/DaniAbalde
<p>I meant, just update the curve output without rebuild the class. The event wich trigger the update is irrelevant here, it can be anything.</p>
<p>This file contains the code with an event based in timer, only to facilitate the help.</p>
<p></p>
<p>Private Sub RunScript(ByVal x As Boolean, ByVal Ids As List(Of Guid), ByRef A As Object)</p>
<p>If x Then<br></br>BB = New BLABLA(ids)<br></br>A = BB.Curva<br></br>Else<br></br>If BB IsNot Nothing Then BB.timer.Stop()<br></br>End If</p>
<p>End Sub</p>
<p>'<Custom…</p>
<p>I meant, just update the curve output without rebuild the class. The event wich trigger the update is irrelevant here, it can be anything.</p>
<p>This file contains the code with an event based in timer, only to facilitate the help.</p>
<p></p>
<p>Private Sub RunScript(ByVal x As Boolean, ByVal Ids As List(Of Guid), ByRef A As Object)</p>
<p>If x Then<br/>BB = New BLABLA(ids)<br/>A = BB.Curva<br/>Else<br/>If BB IsNot Nothing Then BB.timer.Stop()<br/>End If</p>
<p>End Sub</p>
<p>'<Custom additional code></p>
<p>Dim BB As BlABLA</p>
<p><br/>Public Class BLABLA<br/>Public Curva As curve<br/>Private Cache As list(Of point3d)<br/>Private IDs As list(Of guid)</p>
<p>Sub New(_ids As list(Of guid))<br/>IDs = _ids<br/>Dim points As New list(Of point3d)<br/>For Each id As guid In ids<br/>Dim rh As rhinoobject = rhinodoc.ActiveDoc.Objects.Find(id)<br/>Dim pt As Rhino.Geometry.Point = DirectCast(rh.Geometry, rhino.Geometry.Point)<br/>If pt is Nothing Then Continue For<br/>points.add(pt.Location)<br/>Next<br/>cache = points<br/>curva = curve.CreateInterpolatedCurve(points, 3)<br/>timer = New system.Windows.Forms.Timer<br/>timer.Interval = 100<br/>timer.Start()</p>
<p>End Sub</p>
<p>Public WithEvents timer As system.Windows.Forms.Timer</p>
<p>Private Sub Tick(sender As Object, e As System.EventArgs) Handles timer.Tick</p>
<p>For i As int32 = 0 To ids.count - 1<br/>Dim rh As rhinoobject = rhinodoc.ActiveDoc.Objects.Find(ids(i))<br/>Dim pt As Rhino.Geometry.Point = DirectCast(rh.Geometry, rhino.Geometry.Point)<br/>If pt Is Nothing Then Continue For</p>
<p>If Not pt.Location.Equals(cache(i)) Then<br/>UpdateOutput()</p>
<p>End If<br/>cache(i) = pt.Location<br/>Next<br/>End Sub</p>
<p>Private Sub UpdateOutput()<br/>'HERE I NEED UPDATE THE A OUTPUT<br/>rhinoapp.WriteLine("Change")<br/>End Sub</p>
<p>End Class</p> Here is an example of the pro…tag:www.grasshopper3d.com,2016-01-11:2985220:Comment:14360012016-01-11T12:03:14.673ZDaniel González Abaldehttps://www.grasshopper3d.com/profile/DaniAbalde
<p>Here is an example of the problem in a few lines of code.</p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769085380?profile=original" target="_self"><img class="align-full" src="http://storage.ning.com/topology/rest/1.0/file/get/2769085380?profile=RESIZE_1024x1024" width="721"></img></a></p>
<p></p>
<p>Private Sub RunScript(ByVal x As Boolean, ByVal Ids As List(Of Guid), ByRef A As Object)</p>
<p>If x Then<br></br> BB = New BLABLA(ids)<br></br> A = BB.Curva<br></br> End If</p>
<p>End Sub</p>
<p>'<Custom additional code></p>
<p>Dim BB As BlABLA</p>
<p><br></br> Public Class BLABLA<br></br> Public Curva As…</p>
<p>Here is an example of the problem in a few lines of code.</p>
<p><a href="http://storage.ning.com/topology/rest/1.0/file/get/2769085380?profile=original" target="_self"><img width="721" src="http://storage.ning.com/topology/rest/1.0/file/get/2769085380?profile=RESIZE_1024x1024" width="721" class="align-full"/></a></p>
<p></p>
<p>Private Sub RunScript(ByVal x As Boolean, ByVal Ids As List(Of Guid), ByRef A As Object)</p>
<p>If x Then<br/> BB = New BLABLA(ids)<br/> A = BB.Curva<br/> End If</p>
<p>End Sub</p>
<p>'<Custom additional code></p>
<p>Dim BB As BlABLA</p>
<p><br/> Public Class BLABLA<br/> Public Curva As curve</p>
<p>Sub New(ids As list(Of guid))<br/> Dim points As New list(Of point3d)<br/> For Each id As guid In ids<br/> Dim rh As rhinoobject = rhinodoc.ActiveDoc.Objects.Find(id)<br/> Dim pt As Rhino.Geometry.Point = DirectCast(rh.Geometry, rhino.Geometry.Point)<br/> If pt is Nothing Then Continue For<br/> points.add(pt.Location)<br/> Next<br/> curva = curve.CreateInterpolatedCurve(points, 3)<br/> End Sub</p>
<p>End Class</p> Thanks guys, I think I unders…tag:www.grasshopper3d.com,2016-01-10:2985220:Comment:14358472016-01-10T21:32:52.540ZDaniel González Abaldehttps://www.grasshopper3d.com/profile/DaniAbalde
<p>Thanks guys, I think I understand the logic. I still have not tried because I have gone another way. Now I have the same problem but with an output, I think that here the cache does not help me, no?. I'm still developing in vb script component.</p>
<p></p>
<p>I have a network of lines defined by a few points. When the script is executed, it returns in an output that network of curves in its default form. But then, arise in rhino some interactive grips (like a gumball but in a personalized…</p>
<p>Thanks guys, I think I understand the logic. I still have not tried because I have gone another way. Now I have the same problem but with an output, I think that here the cache does not help me, no?. I'm still developing in vb script component.</p>
<p></p>
<p>I have a network of lines defined by a few points. When the script is executed, it returns in an output that network of curves in its default form. But then, arise in rhino some interactive grips (like a gumball but in a personalized way, using displayconduit), which are used to drag the position of the points (which define the curve network). So the problem is that I do not know how to get back the updated network in the output.</p>
<p></p>
<p>The role is something like:</p>
<p>Sub Runscript(...)</p>
<p>MiClase = new MyClass()</p>
<p>A = MiClase.Curves</p>
<p>end sub</p>
<p></p>
<p>'<Custom additional code> </p>
<p>Dim MiClase as MyClass()</p>
<p></p>
<p>Public Class MyClass</p>
<p>(...)</p>
<p>End class</p>
<p>'<Custom additional code> </p>
<p></p>
<p>So now the issue is, how I can resend data to the output? I already have the updated curves (because I can see him baking in rhino), I only need to get them out by the output.</p>
<p>I have to access the parameter and add the new data from within it? (addvolatiledata and this stuff) I've tried but without success.<br/>Somehow I feel that I have no control over the execution process of the code, it's something that bothers me.</p>
<p><br/>Is there any way to update the output without re-execute all?</p> It is possible to read params…tag:www.grasshopper3d.com,2016-01-09:2985220:Comment:14347652016-01-09T01:25:46.013ZJames Ramsdenhttps://www.grasshopper3d.com/profile/JamesRamsden
<p>It is possible to read params manually using Params.Input[0].VolatileData or similar (this reads the 0th input). This then returns an IGH_Structure, giving you the slightly awkward task of deconstructing to access your data.</p>
<p>But this isn't the way I'd recommend, since it is up to components upstream as to whether your component gets expired and recomputes anyway. Changing the way you access the params isn't going to help you solve the problem.</p>
<p>As David says, I would create some…</p>
<p>It is possible to read params manually using Params.Input[0].VolatileData or similar (this reads the 0th input). This then returns an IGH_Structure, giving you the slightly awkward task of deconstructing to access your data.</p>
<p>But this isn't the way I'd recommend, since it is up to components upstream as to whether your component gets expired and recomputes anyway. Changing the way you access the params isn't going to help you solve the problem.</p>
<p>As David says, I would create some class variables in your component to create a copy of your param data - the cache he said about. In your SolveInstance, use IGH_DataAccess DA to read your params into some local variables as usual. Then compare this with the data saved in your cache. Make sure your heavy calculations are wrapped inside an 'if' statement. You can use the comparison to decide whether you want to run the heavy calcs. You can then run the final phase as normal. Finally, make sure that your cache is up to date with the latest param data.</p> There's nothing in-build that…tag:www.grasshopper3d.com,2016-01-08:2985220:Comment:14346582016-01-08T19:27:14.952ZDavid Ruttenhttps://www.grasshopper3d.com/profile/DavidRutten
<p>There's nothing in-build that will allow for this. You'll have to cache your own data and quickly re-assign it if you think the cache is still valid.</p>
<p>There's nothing in-build that will allow for this. You'll have to cache your own data and quickly re-assign it if you think the cache is still valid.</p>