Grasshopper

algorithmic modeling for Rhino

Hello,

I've recently started working in C# and I'm realizing what a lazy coder I've been; I've got what is probably a simple problem. I'm attempting to split a Brep with multiple Breps, which is simple in Python:

cnt=0
while cnt<len(inlet_outlet_geometry):
    base_geometry = Rhino.Geometry.Brep.Split(base_geometry, inlet_outlet_geometry[cnt], tol)
    base_geometry = base_geometry[1]
    cnt+=1

In this Python case, there are two surfaces (inlet_outlet_geometry) that are cutting (base_geometry). The loop iterates through each inlet_outlet surface and cuts the base_geometry once. Between cutting, the Open Brep index [1] is selected. Basically I'm cutting windows in a box, iterating one by one.

When I move to C#:

for(int i = 0;i < inlet_outlet_geometry.Count();i++){
    base_geometry_out = base_geometry.Split(inlet_outlet_geometry[i], Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance);
    base_geometry = base_geometry[1];
}

I get the error "Cannot apply indexing with [] to an expression of type 'Rhino.Geometry.Brep". Are Brep objects immutable? Can I not overwrite the value of this brep? What am I missing? I have the type hints and parameter access set correctly.

thanks for your help,

Views: 524

Replies to This Discussion

Thanks for the reply, I did declare the variable as a list access in the input param, so at the private Void RunScript level, I pass these in as Brep<List>. Is that not enough?

Ok, great thanks. I did try it out, and I'm only getting the one hole to cut however. This is what I'm getting with your script.

but this is what I'm inputting:

I've also attached the file. Thanks for your help.

Attachments:

Ha, no worries, thanks again for your help. I just learned a lot. 

Could you briefly explain the IF statement?

Ok, actually I think I got it. You're saying if the range is greater than 1 (meaning there is a trimmed surface and an open brep), then set the base brep to result index 1 (which is the open brep). 

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