Grasshopper

algorithmic modeling for Rhino

Trying to force myself to use C# in a effort to learn more.  I'm trying to recreate the Solid difference component and I'm running in to some logical errors.  Can anyone point me in the right direction or show me what I'm doing wrong?

Im getting the following errors:

1. Error (CS0136): A local variable named 'stk' cannot be declared in this scope because it would give a different meaning to 'stk', which is already used in a 'parent or current' scope to denote something else (line 75)

2. Error (CS0029): Cannot implicitly convert type 'Rhino.Geometry.Brep[]' to 'Rhino.Geometry.Brep' (line 75)

Code below:

private void RunScript(List<Brep> x, Brep y, ref object A)
{
List<Rhino.Geometry.Brep> myBreplist = x;

Brep stk = y;

int i = 0;

while(i < myBreplist.Count){
Brep brepA = myBreplist[i];
Brep stk = Brep.CreateBooleanDifference(brepA, stk, .01);
i++;
}

A = stk;

Views: 1282

Replies to This Discussion

You declare stk twice. If you wish to reassign the stk variable, you need to remove the 'Brep' in front if it the second time.

But you can't simply reassign because CreateBooleanDifference returns an array of breps, not a single brep. When you perform iterated boolean operations, you must handle the possibility that you get more and more breps over the course of the iteration.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2025   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service