Get list of all components in Visual Studio: How?

Hello
How to get the list of all components in Visual Studio without create a component?

using Grasshopper;
using Grasshopper.Kernel;
using Grasshopper.Kernel.Data;
using Grasshopper.Kernel.Types;

using Grasshopper.Kernel.Special;
using System.Collections.Generic;
using System.Drawing;

namespace ComponentsList
{
    public class ComponentList
    {
        public static IGH_Component owner ;

        public static List<string>  componentsList()
        {
            //List<PointF> pivots = new List<PointF>();
            List<string> objects = new List<string>();
            var doc = owner.OnPingDocument();
            if (doc != null)
            {
                var objs = doc.Objects;
                foreach (var o in objs)
                {
                    objects.Add(o.Name.ToString());
                    //pivots.Add(o.Attributes.Pivot);
                }
            }
            return objects;
        }

    }
}

If you want a list of all the names(since you are using List), something like this should work:
Grasshopper.Instances.ActiveCanvas.Document.Objects[i].Name;
Just guessing:You probably have to add an eventhandler to check if a new object is added.

Thanks @Baris

I change it like this

var doc = Instances.ActiveCanvas.Document;

1 Like