NodeInCode C#

Hi all,

I have started trying out NodeInCode in C#, which seems promising and kind of works but currently not the way I hoped.

I like to use the “CapHoles” component in my code, and it works to access it but it seem to return objects instead of breps? I need the have breps for later operations, and haven’t find any way to convert the Object to a Brep. However, I also can’t save the result as a array of breps, as the function returns objects. I have the code below, which don’t work because I can’t add the objects to a list with breps. Do anyone know how get out breps instead, since the component instead actually put out breps? Or, otherwise, do anyone know how to convert Object to a Brep?

var capHoles = Rhino.NodeInCode.Components.FindComponent("CapHoles");

if(capHoles == null) Print("CapHoles could not be found");

      string [] warnings;
      object [] result = capHoles.Evaluate(breps, false, out warnings);

      if (warnings!= null) foreach(var w in warnings) Print(w);

        foreach (object r in result) breps.Add(r);

Hi @jmhannu,

Any reason not to just use Brep.CapPlanarHoles?

– Dale

Hi @dale ,

Thanks for your quick response! Not really, I just wanted to test using “NodeInCode” in C# since I’ve used the ghpythonlib.components in Python and it’s pretty handy.

However, the “Evaluate” function always seem to return a list of Object, which is almost never what I need unless I want to base my whole code on NodeInCode-functions. So, do you or anyone else know if there any way around this? Or, how can I, for example, cast Object to Brep or other GeometryBase-objects?

Hi again @dale ,

Actually realised the function Brep.CapPlanarHoles gives me a different result then the “Cap Holes”-component. Is it suppose to work the same? The component caps it the way I like, while the function adds an extra surface on the side that I do not want. Tried changing the tolerance and put it to numbers between 1.0 and 0.0001 but it didn’t make any difference.

Still haven’t gotten around the casting-problem, tried to cast the object to a Brep straight of but get the error that “Unable to cast object of type “IronPython.Runtime.List” to type Rhino.Geometry.Brep”. Which I do not fully understand because as far as I see it, the object I am trying to cast is not a list. But if anyone have any casting tips - please let me know!