-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathQuerySelectedGhComponentOutput.cs
More file actions
51 lines (44 loc) · 1.38 KB
/
QuerySelectedGhComponentOutput.cs
File metadata and controls
51 lines (44 loc) · 1.38 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
using System;
using Rhino;
using Grasshopper;
using Grasshopper.Kernel;
using GraphHop2.Utilities;
//Query list of output like components within the selection
//Components (or params) with no output parameters,
//Or all outputs are unconnected,
//Or at least one output is connected to a recipient 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 outputLikeObjects = SelectionToOutputUtility.GetOutputLikeObjects(selectedObjects);
if (outputLikeObjects.Count == 0)
{
RhinoApp.WriteLine("No output-like components found in selection.");
}
else
{
RhinoApp.WriteLine("Output-like components in selection (zero or external output):");
foreach (var obj in outputLikeObjects)
{
string name = obj.GetType().Name + ": " + (obj as IGH_Component)?.Name;
RhinoApp.WriteLine(name);
}
}
}
RunScript();