static void CollectDataHelper <T>(IGH_DataAccess DA,
                                   string inputName,
                                   GH_ParamAccess access,
                                   ref int inputCount,
                                   DataTree <ResthopperObject> dataTree)
 {
     if (access == GH_ParamAccess.item)
     {
         T t = default(T);
         if (DA.GetData(inputName, ref t))
         {
             inputCount = 1;
             dataTree.Append(new ResthopperObject(t), "0");
         }
     }
     else if (access == GH_ParamAccess.list)
     {
         List <T> list = new List <T>();
         if (DA.GetDataList(inputName, list))
         {
             inputCount = list.Count;
             foreach (var item in list)
             {
                 dataTree.Append(new ResthopperObject(item), "0");
             }
         }
     }
     else if (access == GH_ParamAccess.tree)
     {
         var type = typeof(T);
         throw new Exception($"Tree not currently supported for type: {type}");
     }
 }
 static void CollectDataHelper2 <T, GHT>(IGH_DataAccess DA,
                                         string inputName,
                                         GH_ParamAccess access,
                                         ref int inputCount,
                                         DataTree <ResthopperObject> dataTree) where GHT : GH_Goo <T>
 {
     if (access == GH_ParamAccess.tree)
     {
         var tree = new Grasshopper.Kernel.Data.GH_Structure <GHT>();
         if (DA.GetDataTree(inputName, out tree))
         {
             foreach (var path in tree.Paths)
             {
                 string pathString = path.ToString();
                 var    items      = tree[path];
                 foreach (var item in items)
                 {
                     dataTree.Append(new ResthopperObject(item.Value), pathString);
                 }
             }
         }
     }
     else
     {
         CollectDataHelper <T>(DA, inputName, access, ref inputCount, dataTree);
     }
 }
示例#3
0
 static void CollectDataHelper <T>(IGH_DataAccess DA, string inputName, bool itemAccess, ref int inputCount, DataTree <ResthopperObject> dataTree)
 {
     if (itemAccess)
     {
         T t = default(T);
         if (DA.GetData(inputName, ref t))
         {
             inputCount = 1;
             dataTree.Append(new ResthopperObject(t), "0");
         }
     }
     else
     {
         List <T> list = new List <T>();
         if (DA.GetDataList(inputName, list))
         {
             inputCount = list.Count;
             foreach (var item in list)
             {
                 dataTree.Append(new ResthopperObject(item), "0");
             }
         }
     }
 }