That - entry level - C# divides a “rectangle” derived from the box (pts 0, 1, 2, 3) and then uses a BrepFace containment filter by testing the center of a given divided “module” (a rectangle in this case) for inclusion. Meaning that you should:
- Control the output: Meshes (faster) or Breps (general case - see PS2)?
- Elaborate other filters as well (for instance testing all points for inclusion etc etc).
- Elaborate a safety net (i.e. respect max N of divisions in X.Y: just imagine attempting to divide a 100 m long direction using a step like 0.001).
- Include an option: get things inside or outside the BrepFace.
- Use the BrepFace plane for the Box and thus use any BrepFace “rotated” in 3d space.
PS1: Other than that are you after some recursive loop for the remaining “spaces” ? I.e. If NOT an inclusion is found AND if at least one point is included … then use half x/y for the first pass (loop) and then half of the half … blah, blah. This means that the modules wouldn’t be equal (obviously) AND you may end with a BIG N of “mini” modules (up to some min size [ doc tolerance for instance]).
PS2: Obviously another way is to get the Curve intersection between the Rectangle (as Curve) and the prox BrepFace Loop. This means that the modules wouldn’t be rectangles AND you can’t use Meshes (for the general case: any planar BrepFace with curvy BrepLoops etc etc).
For the other thing (Linear alu/steel profiles extrusions) use the
Brep.CreatePlanarBreps (i.e. get the Face) and Brep.CreateFromOffsetFace (i.e. use the Face) Methods
Note: Rhino is a surface modeller … meaning that MAY become very slow when “solids” (closed Breps) are required. In general and if you are after solids (and most notably post operations like fillets etc) avoid using Rhino at any cost.