# Grasshopper -Irregular Flat Surface Division by Dimension (spacing)

hii, I am currently working on a project which calculates the tiling waste in the floorplan, I have created a simple C# script for dividing the irregular surface into grids, But what I want to do is to divide the surface with fixed dimension instead of count

this is what I had now,
and also I would like to keep the division vertical or horizontal rather than this

Really appreciate someone can help me with it!! (c#, ghpython, gh) all should be good!!,
Thanks!!

Regards
Blair

Hello
what I understand is you have a tile of (w, l) or (width length) and you want to put that on any shape.
If shape bounding box is W L (Width Length) the max number is

• nw = Ceiling(W/w)
• nl = Ceiling(L/l)

You can get W and H doing that, W is X of deconstruct component, L is Y.

In a way â€¦

BrepFace_DivideToXYLengths_V1.gh (114.8 KB)

PS: Modify things (i.e. the output, the input etc etc) accordingly

Simple rectangle will do. I want to create this series of extrusion or sweep. My reference line is already parametric for some reason my solid model didnâ€™t follow. I use sweep in this case

Shape of extrusion be something like this.

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:

1. Control the output: Meshes (faster) or Breps (general case - see PS2)?
2. Elaborate other filters as well (for instance testing all points for inclusion etc etc).
3. 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).
4. Include an option: get things inside or outside the BrepFace.
5. 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.

sorry for being silly here, emm but if I want the same square like this

How can I get the points and create the same rectangle based on your previous script? Thank you!!

The â€śareaâ€ť sketched (Nothing to do with some Inside/Outside filter) is not a rectange: is the Intersection of the candidate Rectangle as Curve (if is valid according to some criterium) VS the BrepLoops as Curves. This means NO MESHES as output (general case).

For getting the Loops:

``````List< Curve > loops = new List< Curve >();
``````

That said: 1 to 10 what is your rate about your C# level? (question related with various things that this case requires in order to be the complete thingy)

maybe only 3 or 4 hahaha, I used to use python a lot, just begin to use last two months

2 months means minus 1 (min), he he. You can hope for 1 after 6 months (min). Then â€¦ youâ€™ll need ~ 5 years to get the gist of C# (and several more in order to do anything imaginable). Then â€¦ is kinda martial arts: the zone state of things and the likes, blah, blah.

1 Like

hahaha thatâ€™s true, but what you mean before is about getting the intersections of those two lines and get the curve? maybe I need to find an alternative way in gh to do that (sad tho hhhhh)
like this

Jesus C ! You are lost in space I guess (life sucks).

1. For a given quad of a candidate module (Rectangle) points .
2. If no point is inside the face > adios amigos > add null (thatâ€™s handy for other type of â€śpostâ€ť things).
3. Get the Rectange and then a Curve out of it (rect.ToNurbsCurve()).
4. Test for ccx events (Curve.Intersection(s)) between that Curve and each of the Curve loops (as above).
• If some Curves (general case) are found add the resulting Breps (Brep.CreatePlanarBreps(crvs)) to the result Tree.

• If no ccx events occured add the Rectange Curve as Brep.

Note: a given Rectangle MAY have all the 4 corner points inside a face while thereâ€™s still potential ccx events (but you may use a test by finding the min prox distance between the center and the loops > if this is greater than the half diagonal > NO ccx test is required [ just add the Rectangle]).

That said C# is a thingy for the brave. Thus I added some stuff BUT not the code for the â€śpieces as aboveâ€ť.

Moral: be brave, never give-up.

BrepFace_DivideToXYLengths_V1A.gh (118.9 KB)

Offset your curves with the max dimension of your tile. You will have enough tiles. Use Clipper Offset it will union shapes.

And a more Sioux Method using Peter Definition

BrepFace_DivideToXYLengths_LD.gh (15.2 KB)

2 Likes

Er â€¦ you know what this means (general case : weird/freaky/odd PolyCurves etc etc) in real life.

Thank youuu, i have a long way to go hahaha , but donâ€™t give up !!

Hi @reny.w, are you lost? You can make your own question without polluting this one.

@Blair_Huang I updated my answer and put a definition.

Thank you! Its pretty straightforward

Offset from Clipper is not weird, freaky or whatever. There are drawbacks because it is polyline. But is the Nature really continuous ? At the end everything is atoms, quark â€¦ light â€¦ So in real life good polyline is better than bad Nurbs/Bezier curve.
Whatever it is good to see you Peter @PeterFotiadis , you are always a bit â€ścrypticâ€ť but you always bring nice solutions.

I mean situations like these: