JimYuan's Blog

Sharing the things I learned

0%

SelectGeometryInSameLayer_GH

Preface

Just as another regular work day, I memo down some new things along the task I am facing. Recently I have been crazy about the Voronoi diagram. Although as bad as I wanted to implement the sweepline algorithm, I found the best practice might be patient and learn thing little by little. Also, I am kinds into “Study with me” series on youtube. I feel clam with someone’s company alongside.

Reference

https://discourse.mcneel.com/t/c-select-objects-by-layer/84420/6
Appreciate the help from username Mahdiyar.

Two things are different

  • select object in Rhino DocView
  • select object in GH
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
var ghobjs = new List<object>();
var selectedLayer = RhinoDoc.ActiveDoc.Layers.FindName(layerName);
var layers = new List<Rhino.DocObjects.Layer>(){selectedLayer};
if(subLayer)
{
foreach(var layer in RhinoDoc.ActiveDoc.Layers)
if(layer.IsChildOf(selectedLayer))
layers.Add(layer);
}
B = layers;
foreach(var layer in layers)
{
var rhobjs = doc.Objects.FindByLayer(layer);
foreach (var rhObj in rhobjs)
ghobjs.Add(rhObj.Geometry);
}
A = ghobjs;

SelectInSameLayer