Grasshopper

algorithmic modeling for Rhino

Visual Studio namespace errors "doc.Objects.FindByLayer", c#

I'm having trouble using the code segment "doc.Objects.FindByLayer" in Visual Studio. The code worked perfectly in the native c# component environment.  

Help is certainly welcome.

// Working code in native c# component

Rhino.DocObjects.Layer lyr = doc.Layers[index];

Rhino.DocOjbects.RhinoObject[] objs = doc.Objects.FindByLayer(lyr);

// Code that was attempted in Visual Studio, c# (namespace errors)

Rhino.DocObjects.Layer lyr = Rhino.DocObjects.ActiveDoc.Layers[index];

Rhino.DocOjbects.RhinoObject[] objs = Rhino.DocObject.Tables.ObjectTable.FindByLayer(lyr);

Views: 1100

Replies to This Discussion

Maybe try to define "doc" first...

var doc = RhinoDoc.ActiveDoc;

In the component its defined within the Script_Instance class

Michael,

Defining "doc" did the trick - thanks!

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service