Hi @stevebaer , @piac , et al
Orginally written Here , but not been able to solve it, and would be great to keep the code in python if possible. So i don’t have to rewrite the main code in C# as still beginner there.
Is it possible to only run a portion of a code when one value changes, and not recompute the whole code again when another input changes in a python component ?
I am working with Cameras and i am trying to store the initial camera view, edit /add named views then return the initial camera view when the switch is returned to false.
It works to the level that it creates a named view based on the active viewport and the new view as required but when i move the slider to change the zoom on the new viewport/s it updated both so when it i am finished with the change and i switch it back it returns an updated view before deleting the temporary viewport and not the original named view i had saved.
I have a feeling this problem would also happen if i wrote the viewport info to an dictionary as it would still run the whole code again and update the dictionary as it currently written
Code
from Rhino.RhinoDoc import ActiveDoc as doc
import rhinoscriptsyntax as rs
def SetISO(vp):
rs.ViewRadius(vp.Id,Zoom,True)
doc.NamedViews.Add("Tester",vp.Id)
if Create == 1:
#Get Active Viewport
vp = doc.Views.ActiveView.ActiveViewport
current_vp = vp.Name
doc.NamedViews.Add(current_vp,vp.Id)
SetISO(vp)
else:
index = doc.NamedViews.FindByName(current_vp)
doc.NamedViews.Restore(index,vp,True)
doc.NamedViews.Delete(current_vp)
Just bake the Example Brep into Rhino File for reference Geometry to see if the Camera is working as expected. Note: (Modelled in Meters)
Since Posting this first question on the Grasshopper Forum i have found this list but not yet worked out how to implement any of them in the code
ghenv.Component.PingDocument
ghenv.Component.AttributesChanged
ghenv.Component.DisplayExpired
ghenv.Component.ObjectChanged
ghenv.Component.SolutionExpired
ghenv.Component.Params.ParameterChanged
The more i have worked on solving this the more i have found if i can understand how the logic work that if one input changed it done one thing once, even when another input changes it does not recompute the first action. Making some GH codes so much faster.
Run Part Script Question.gh (9.4 KB)
Thanks Matt