I've got a problem when working with C# Component in Grasshopper. I'm not familiar with it, so I cannot understand the logic. For example, I have introduced a class:
public class MyClass
{
public void TestFoo()
{
Print("it works!");
}
}
It contains the only method, that has to use the "Print" function and show the string message. But I get an error: Error (CS0038): Cannot access a non-static member of outer type 'Script_Instance' via nested type 'Script_Instance.MyClass' (line 762). As I understand I can't use Rhino's function within my own class. But how can I fix it? Thank you! I ask this question because I need to write the class that contains method of NurbsSurface creation, but I also cannot use Rhino's method doc.Objects.AddSurface
...
I tried to implement C# inheritance from Rhino's methods, but it doesn't work...
The issue with accessing the
Script_Instance
from your custom class is independent of accessing the Rhino libraries from a custom class.To access the
Script_Instance
methods, you can pass the object into your method and add thestatic
tag.For accessing rhino libraries there is no special inheritance.
The example blow demonstrates both implementations: