public static void SetEnum2D <T>(this Grasshopper.Kernel.IGH_DataAccess DA, int index, IEnumerable <IEnumerable <T> > data) { var tree = new DataTree <T>(); var basePath = DA.ParameterTargetPath(index); foreach (var entry in data.Select((o, i) => new { Index = i, Item = o })) { var path = basePath.AppendElement(entry.Index); tree.AddRange(entry.Item, path); } DA.SetDataTree(index, tree); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(GH.Kernel.IGH_DataAccess DA) { MeshGhData hE_MeshData = new MeshGhData(); if (!DA.GetData(0, ref hE_MeshData)) { return; } Paramdigma.Core.HalfEdgeMesh.Mesh hE_Mesh = hE_MeshData.Value; Paramdigma.Core.HalfEdgeMesh.MeshTopology topo = new Paramdigma.Core.HalfEdgeMesh.MeshTopology(hE_Mesh); topo.ComputeFaceAdjacency(); GH.DataTree <int> fvTopo = new GH.DataTree <int>(); GH.DataTree <int> feTopo = new GH.DataTree <int>(); GH.DataTree <int> ffTopo = new GH.DataTree <int>(); foreach (int key in topo.FaceVertex.Keys) { fvTopo.AddRange(topo.FaceVertex[key], new GH.Kernel.Data.GH_Path(key)); } foreach (int key in topo.FaceVertex.Keys) { feTopo.AddRange(topo.FaceVertex[key], new GH.Kernel.Data.GH_Path(key)); } foreach (int key in topo.FaceFace.Keys) { ffTopo.AddRange(topo.FaceFace[key], new GH.Kernel.Data.GH_Path(key)); } DA.SetDataTree(0, fvTopo); DA.SetDataTree(1, feTopo); DA.SetDataTree(2, ffTopo); }