Pipeline by selected objects?

Hi,

In Grasshopper, instead of using Pipeline to get the objects from a layer is it possible to use something to get the objects that are currently selected and have them as input?

Thank you!

private void RunScript(ref object A)
  {
    if(!_init)
    {
      Rhino.RhinoDoc.SelectObjects -= RhinoDocOnSelectObjects;
      Rhino.RhinoDoc.SelectObjects += RhinoDocOnSelectObjects;
      Rhino.RhinoDoc.DeselectObjects -= RhinoDocOnSelectObjects;
      Rhino.RhinoDoc.DeselectObjects += RhinoDocOnSelectObjects;
      Rhino.RhinoDoc.DeselectAllObjects -= RhinoDocOnDeselectAllObjects;
      Rhino.RhinoDoc.DeselectAllObjects += RhinoDocOnDeselectAllObjects;
      _init = true;
    }
    A = objs;
  }

  // <Custom additional code> 
  private bool _init = false;
  List<GeometryBase> objs = new List<GeometryBase>();
  private void RhinoDocOnSelectObjects(object sender, RhinoObjectSelectionEventArgs e)
  {
    foreach(var rhObj in RhinoDoc.ActiveDoc.Objects.GetSelectedObjects(false, false))
      objs.Add(rhObj.Geometry);
    Component.ExpireSolution(true);
  }
  private void RhinoDocOnDeselectAllObjects(object sender, RhinoDeselectAllObjectsEventArgs e)
  {
    objs.Clear();
    Component.ExpireSolution(true);
  }

SelectedObjects.gh (13.3 KB)

3 Likes

Wow, this is so useful for quick geometry evaluation, checking areas, sketching. And fun to have such instant input.
Should be part of the Pipeline component. In GH2 maybe?