-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathQuerySelectedGhComponentInput.cs
More file actions
53 lines (46 loc) · 1.41 KB
/
QuerySelectedGhComponentInput.cs
File metadata and controls
53 lines (46 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Collections.Generic;
using System.Linq;
using Rhino;
using Grasshopper;
using Grasshopper.Kernel;
using GraphHop2.Utilities;
//Query list of "input", components within the selection
//Components (or params) with no input parameters,
//Or all inputs are unconnected,
//Or at least one input is connected to a source outside the selection.
void RunScript()
{
if (Grasshopper.Instances.ActiveCanvas == null)
{
RhinoApp.WriteLine("Grasshopper is not loaded or no canvas is active!");
return;
}
var ghDoc = Grasshopper.Instances.ActiveCanvas.Document;
if (ghDoc == null)
{
RhinoApp.WriteLine("No active Grasshopper document found!");
return;
}
var selectedObjects = ghDoc.SelectedObjects();
if (selectedObjects.Count == 0)
{
RhinoApp.WriteLine("No Grasshopper components selected!");
return;
}
var inputLikeObjects = SelectionToInputUtility.GetInputLikeObjects(selectedObjects);
if (inputLikeObjects.Count == 0)
{
RhinoApp.WriteLine("No input-like components found in selection.");
}
else
{
RhinoApp.WriteLine("Input-like components in selection (zero or external input):");
foreach (var obj in inputLikeObjects)
{
string name = obj.GetType().Name + ": " + (obj as IGH_Component)?.Name;
RhinoApp.WriteLine(name);
}
}
}
RunScript();