SpeckleGrasshopper/UserDataUtils/QuerySpeckleObjectComponent.cs
/// <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>
This is the method that actually does the work.
This is the method that actually does the work .
protected override void SolveInstance(IGH_DataAccess DA)
    {
      GH_SpeckleObject GHspeckleObject = null;
      if (!DA.GetData(0, ref GHspeckleObject))
        return;
      var dict = GHspeckleObject.Value.Properties;
      if (DA.Iteration == 0)
      {
        var allData = Params.Input.OfType<Param_String>()
               .First()
               .VolatileData.AllData(true)
               .OfType<GH_String>()
               .Select(s => s.Value);
        if (!allData.Any())
        {
          return;
        }
        properties = new HashSet<string>();
        foreach (var p in allData)
        {
          properties.Add(p);
        }
      }
      if (OutputMismatch() && DA.Iteration == 0)
      {
        OnPingDocument().ScheduleSolution(5, d =>
        {
          AutoCreateOutputs(false);
        });
      }
      else if(!OutputMismatch())
      {
        int o = 0;
        foreach (var p in properties)
        {
          var temp = dict;
          var keys = p.Split('.');
          object target = null;
          for (int i = 0; i < keys.Length; i++)
          {
            if (i == keys.Length - 1)
              if (temp.ContainsKey(keys[i]))
              {
                target = temp[keys[i]];
              }
              else
              {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Parameter {o + 1} is missing data at [{i}]{keys[i]}");
                break;
              }
            else
            {
              if (temp.ContainsKey(keys[i]))
              {
                var t = temp[keys[i]];
                if (t is Dictionary<string, object> d)
                  temp = d;
                else if (t is SpeckleObject speckleObject)
                  temp = speckleObject.Properties;
              }
              else
              {
                AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, $"Parameter {o + 1} is missing data at {keys[i]}");
                break;
              }
            }
          }
          if (target is List<object> myList)
          {
            DA.SetDataList(o, myList);
          }
          else if (target is object)
          {
            DA.SetDataList(o, new List<object> { target });
          }
          o++;
        }
      }
    }
protected override void SolveInstance ( IGH_DataAccess DA ) { GH_SpeckleObject GHspeckleObject = null ; if ( ! DA . GetData ( 0 , ref GHspeckleObject ) ) return ; var dict = GHspeckleObject . Value . Properties ; if ( DA . Iteration == 0 ) { var allData = Params . Input . OfType < Param_String > ( ) . First ( ) . VolatileData . AllData ( true ) . OfType < GH_String > ( ) . Select ( s => s . Value ) ; if ( ! allData . Any ( ) ) { return ; } properties = new HashSet < string > ( ) ; foreach ( var p in allData ) { properties . Add ( p ) ; } } if ( OutputMismatch ( ) && DA . Iteration == 0 ) { OnPingDocument ( ) . ScheduleSolution ( 5 , d => { AutoCreateOutputs ( false ) ; } ) ; } else if ( ! OutputMismatch ( ) ) { int o = 0 ; foreach ( var p in properties ) { var temp = dict ; var keys = p . Split ( ' ' ) ; object target = null ; for ( int i = 0 ; i < keys . Length ; i ++ ) { if ( i == keys . Length - 1 ) if ( temp . ContainsKey ( keys [ i ] ) ) { target = temp [ keys [ i ] ] ; } else { AddRuntimeMessage ( GH_RuntimeMessageLevel . Warning , $" Parameter  { o + 1 }  is missing data at [ { i } ] { keys [ i ] } " ) ; break ; } else { if ( temp . ContainsKey ( keys [ i ] ) ) { var t = temp [ keys [ i ] ] ; if ( t is Dictionary < string , object > d ) temp = d ; else if ( t is SpeckleObject speckleObject ) temp = speckleObject . Properties ; } else { AddRuntimeMessage ( GH_RuntimeMessageLevel . Warning , $" Parameter  { o + 1 }  is missing data at  { keys [ i ] } " ) ; break ; } } } if ( target is List < object > myList ) { DA . SetDataList ( o , myList ) ; } else if ( target is object ) { DA . SetDataList ( o , new List < object > { target } ) ; } o ++ ; } } }
This is the method that actually does the work.
This is the method that actually does the work .
//First Pass on Iteration 0 //Get All the Paths, even if on a tree
DA
IGH_DataAccess
The DA object is used to retrieve from inputs and store in outputs.
The DA object is used to retrieve from inputs and store in outputs .