Grasshopper

algorithmic modeling for Rhino

Hiya,

I have a list of curves (polylines) that are input into a C# Script component. The script is attempting to change the layer of each curve. However, in order change the layer of the curve a Rhino.DocObjects.RhinoObject reference is needed. The only method I can see to locate the curve is the RhinoDoc.Objects.Find(GUID) method. How do I get the GUID for the curve ? Alternatively, is there a different way of obtaining the RhinoObject reference apart from Find(GUID) ?

private void RunScript(List<Polyline> TopoPlates, object y, ref object A)
{
// Sort topo plates based on Z values.
List<Polyline> sortedList = TopoPlates.OrderBy(p => p.Last.Z).ToList();

foreach(Polyline pline in TopoPlates)
{
// Get Z value
int zValue = (int) (pline.Last.Z);
Print("Z Value: " + zValue);

// Check if layer with Z value exists. Create new layer if not.
RhinoDoc doc;
doc = RhinoDoc.ActiveDoc;
int layerIndex = doc.Layers.Find("" + zValue + " m", true);

if( layerIndex < 0 )
{
Layer nLayer = new Layer();
nLayer.Name = "" + zValue + " m";
doc.Layers.Add(nLayer);

layerIndex = doc.Layers.Find("" + zValue + " m", true);
}

Print("Layer Index:" + layerIndex);

// HELP!!!

Rhino.DocObjects.RhinoObject plineObj = doc.Objects.Find( /* How do I get the GUID */ );

Views: 1675

Replies to This Discussion

Hi,

as this post is located in the "General Discussions" i can tell you something about the GH Plug-In "Horster".

With C# you need the object ID. You can go over all objects, check layer, then check if obj is a polyline and if true get ID.

Cheers,

RM

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service