Update All Clusters in a GH Script

When working with a large script with many clusters, is there any way to update all clusters at once, as opposed to having to comb through the script and update one-by-one?

If not, any ideas for strategies to approach this issue with?

Thanks

are they all the same?

No there will be a number of unique clusters in most cases

this throws an error message for each updated cluster, but it works:

   if (update)
    {
      for (int i = 0; i < GrasshopperDocument.ObjectCount; i++)
      {

        if (GrasshopperDocument.Objects[i] is Grasshopper.Kernel.Special.GH_Cluster)
        {
          var cluster = GrasshopperDocument.Objects[i] as Grasshopper.Kernel.Special.GH_Cluster;
          cluster.CreateFromFilePath(cluster.FilePath); // "Update" cluster
        }
      }
      GrasshopperDocument.ExpireSolution();
    }

updateClusters.gh (2.7 KB)

1 Like

Probably if you delay this logic until after the solution is done you’ll get rid of those error messages.

I’ve upgraded @TomTom’s solution with some extra features we needed.

  1. Recursive mode to update clusters inside clusters
  2. Passwords can be provided if nessesary
  3. Cluster paths can sometimes be different depending on the user. You can submit local path to clusters’ folder and the script will try to find missing references if possible.

UpdateAllClusters.gh (5.7 KB)

10 Likes

Hey Max,

the Grasshopper file seems to miss the local Path Inputs. I cannot find the “…/” Component in Grasshopper. Without the localPath Inputs, the Script does not seem to work.
Where can I find this Component?

Best
Maximilian

Hi
It’s from metahopper plugin

1 Like

thanks!

Just made an improved version allowing to internalize clusters when needed.
See here : One click solution for internalising all cluster - #11 by Laoky

1 Like