How can i make rectangles, squares or triangles

Hello everyone, I would like some help on how to create rectangles, squares or even triangles within the hatched areas, all must be separated if this image has two rectangles or more inside the yellow area.


REV 01.dyn (57.8 KB)

A few nodes to build such a thing as you have described, though I feel your description may not match the intent just yet (as it’s never this simple):

  • Surface.CoordinateSystemAtParameter node
  • CoordinateSystem.Scale node and CoordinateSystem.Rotate node (as desired)
  • Rectangle.ByWidthLength (or some other regular polygon node)
  • Geometry.Transform node

It seems you want to make shapes for Area-Solution or something like that.
There can be lots of ways to achive your goal and the shapes can be various depending on logics.
Once I’ve created a dyn for generating Area-Solution, but on my dyn, I let a user draw lines for separating a shape and generate Area-Solutions from it. Because, if separaters are let automatically created, separated shapes can be ugly depending on the original shape or the logic.
Here is a video of mine.
https://youtu.be/Tb3Nl1Atndo

1 Like

good morning, actually i need model lines to create the described geometric shapes i.e. in this case two rectangles

Good morning kim I’m a big fan of yours, but my goal is not to remove areas but separate geometric shapes.

ModelCurve.ByCurve should work for that, once you draw the objects you are after. You may need to explode any polycurves to a curve list first.

I need something very close to the topic below, see that it generates separate rectangles but I don’t know how to do this in my scripty

Can you do a quick series of hand sketches to give us a bit more info on the goals and constraints? In the context of what you are after I am lost on how to guide you at the moment.

I added other image formats but the figures 95% of the time will be like figure 1,4,5

This is a very computationally complex problem, which may have a more attainable solution if you looked at the root problem differently. Why do you need to break the element down into these shapes in the first place?

Because of the complexity I wouldn’t tackle this with Dynamo, but start with some research into the core tools used to do similar. I say research as that is where this problem currently stands - in academia nor practice. This paper is a good read for a place to start: https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.21.4507&rep=rep1&type=pdf

You might be able to transition that into a bit of Python, but any solution I have seen always comes up as a ‘so close, yet not quite there’ outcome via the tools currently available.

1 Like

@Tiago in that case, you can make all logics using Python in Dynamo.
But it takes time to make scripts for all 5 of them.
I just simply created one for case #5 and attaching here.
Just a small gift for my fan. :smiling_face_with_three_hearts:
Hope this to be a start point for your work.
Enjoy. :slight_smile:

SurfaceSeparatorSample.dyn (13.1 KB)

Something like this?
divisions

Code available here

Related post

5 Likes

good morning friend, this error occurred described in the image.

The code works only for #5 shaped floor element.

Here is a standalone version (no Revit selection)
However this might fail with a completely irregular shape.
RectangularDivision.dyn (11.4 KB)

Code
def Rect(srf:var[]..[])
{
	srf01 = List.Flatten(srf.Explode(),-1);
	srf02 = List.FilterByBoolMask(srf01,List.Count(srf01.Vertices.PointGeometry<1>)>3)["in"];
	crv00 = srf02.PerimeterCurves();
	pcv01 = PolyCurve.ByJoinedCurves(crv00);
	vtx01 = List.Flatten(srf02.Vertices.PointGeometry,-1);

	//Offset Perimter Curves Outwards
	seg01 = 100;
	off01 = List.Flatten(crv00,-1)[0].Length/seg01;
	pcv02 = pcv01<1>.Offset([off01,-off01]);
	pcv03 = List.FirstItem(pcv02<1>);
	pcv04 = List.LastItem(pcv02<1>);
	pcv05 = pcv03.Length > pcv04.Length ? pcv03 : pcv04;

	//Inward Vectors
	acc01 = 8;
	pnt01 = crv00<1><2>.PointAtParameter((0..1..#acc01));
	vct00 = crv00<1><2>.NormalAtParameter((0..1..#acc01));
	vct01 = List.GetItemAtIndex(vct00<1><2>,Math.Floor(acc01/2));
	pnt02 = List.Flatten(pnt01.Project(pcv05,vct01)<1><2>,-1);
	bln01 = List.AllTrue((pnt01.DistanceTo(pnt02)!=off01)<1><2>);
	vct02 = bln01 ? vct01 : vct01.Reverse();

	//Rectangle aligned to Surface Boundaries
	pnt03 = List.Flatten(pnt01.Project(pcv05,vct02)<1><2>,-1);
	dis01 = Math.Round(pnt01.DistanceTo(pnt03)-off01,6);
	bln02 = List.DropItems(dis01<1><2>,-1)==List.DropItems(dis01<1><2>,1);
	fil01 = List.IndexOf(bln02<1><2>,true);
	fil02 = fil01==-1 ? acc01 : fil01;
	fil03 = List.DropItems(bln02<1><2>,fil02<1><2>);
	fil04 = List.IndexOf(fil03<1><2>,false);
	fil05 = fil04 == -1 ? acc01-1 : fil04+1;
	fil06 = List.DropItems(pnt01<1><2>,fil02<1><2>);
	pnt04 = List.TakeItems(fil06<1><2>,fil05<1><2>);
	fil07 = List.DropItems(pnt03<1><2>,fil02<1><2>);
	pnt05 = List.TakeItems(fil07<1><2>,fil05<1><2>);
	lin01 = List.Clean(Line.ByStartPointEndPoint(pnt04,pnt05).ExtendEnd(-off01),false);
	bln03 = List.Count(List.RemoveIfNot(lin01.Intersect(pcv01)<1><2><3>,"Point")<1><2><3>)>2;
	lin02 = List.FilterByBoolMask(lin01,bln03)["out"];
	lin03 = List.FirstItem(lin02<1><2>);
	lin04 = List.LastItem(lin02<1><2>);
	vct03 = Vector.ByTwoPoints(lin03.PointAtParameter(0.5),lin04.PointAtParameter(0.5));
	vct04 = Vector.ByTwoPoints(lin04.PointAtParameter(0.5),lin03.PointAtParameter(0.5));

	//Shift edge towards Closest Vertex
	pnt06 = List.Transpose(vtx01<3>.Project(lin03<1><2>,vct03<1><2>)<1>);
	bln04 = DSCore.Object.IsNull(List.Count(pnt06<1><2><3>)>0)?true:List.Count(pnt06<1><2><3>)>0;
	dis02 = lin03.DistanceTo(List.FilterByBoolMask(vtx01,bln04<1><2>)["in"]);
	lin05 = lin03.Translate(vct04,List.MinimumItem(dis02));
	pnt07 = List.Transpose(vtx01<3>.Project(lin04<2><1>,vct04<2><1>)<1>);
	bln05 = DSCore.Object.IsNull(List.Count(pnt07<1><2><3>)>0)?true:List.Count(pnt07<1><2><3>)>0;
	dis03 = lin04.DistanceTo(List.FilterByBoolMask(vtx01,bln05<1><2>)["in"]);
	lin06 = lin04.Translate(vct03,List.MinimumItem(dis03));

	//Largest Rectangle
	lin07 = List.Transpose([lin05,lin06]);
	edg01 = List.FirstItem(lin07<1>);
	edg02 = List.LastItem(lin07<1>);
	pnt08 = List.Transpose(List.Transpose([edg01.StartPoint,edg01.EndPoint,edg02.EndPoint,edg02.StartPoint])<1>);
	rct01 = List.Clean(Rectangle.ByCornerPoints(pnt08),false);
	are01 = rct01.Patch().Area;
	rct02 = List.LastItem(List.SortByKey(rct01<1>,are01<1>)["sortedList"]<1>);
	return rct02;
};

def Divs(srf:var[]..[])
{
	divs = [Imperative]
	{
		c = 0;
		r = [];
		n = true;
		s = [];
		while (n)
		{
			r [c] = Rect(srf);
			sld01 = Surface.ByPatch(List.Flatten(r[c],-1));
			sld02 = Solid.ByUnion(Surface.Thicken(sld01,10));
			s [c] = Surface.SubtractFrom(srf,sld02);
			srf = List.Flatten(s[c],-1);
			n = List.Count(List.Flatten(r[c],-1))>0;
			c = c+1;

		}
		rct01 = List.DropItems(List.Flatten(r,-1),-1);
		prm01 = (List.LastItem(List.DropItems(List.Flatten(s,-1),-1)).Explode());
		return [rct01,prm01];
	}
	crv01 = PolyCurve.ByJoinedCurves(divs[1].PerimeterCurves());
	crv02 = List.Flatten([divs[0],crv01],1);


	return crv02;
};
3 Likes

hello I used in format 5 and it didn’t give the expected result

Thank you very much, but the topic already starts saying that I need the perimeter of the floor to create the polygon and divide it into different shapes.