> For the complete documentation index, see [llms.txt](https://gitbook.testingwaters.in/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gitbook.testingwaters.in/motion/cloth.md).

# Cloth

Approximation of cloth draped over a surface

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MC2mHzV-_3nC2oRvupr%2F-MC2mUEIqcUdjmbqunTY%2Fcloth.gif?alt=media\&token=3090c320-63dc-484f-be5e-5357dfd7d49a)

```d
obmx = obj1.BoundingBox.MaxPoint;
obmn = obj1.BoundingBox.MinPoint;
obcn = Point.ByCoordinates((obmx.X + obmn.X)/2 , (obmx.Y + obmn.Y)/2 , obmx.Z);

clt2 = clt1.Translate(Vector.ZAxis(), obmx.Z).PerimeterCurves();
clt3 = clt2.PointAtParameter(0..1..#(clt2.Length/2));

cll1 = Line.ByStartPointEndPoint(clt3<1>,obcn);
cll2 = PolyCurve.ByJoinedCurves(obj1.ProjectInputOnto(cll1,Vector.ByCoordinates(0,0,-1)));
cll3 = Line.ByStartPointDirectionLength(cll2.StartPoint,Vector.ZAxis(),cll2.Length-cll1.Length);

cld1 = NurbsCurve.ByPoints(cll3.EndPoint).Length/(clt2.Length/2);
cld2 = Math.Sqrt(Math.Pow(clt2.Length/(clt2.Length/2),2)-Math.Pow(cld1,2));

cld3 = List.Shuffle(List.Flatten(List.Transpose(List.Transpose([List.Cycle(0,Math.Floor(List.Count(cll3.EndPoint<1>)/2)),List.Cycle(cld2<1>,Math.Ceiling(List.Count(cll3.EndPoint<1>)/2)<1>)])<1>)<1>,-1)<1>);
dis1 = Vector.ByTwoPoints(Point.ByCoordinates(obcn.X,obcn.Y,List.MinimumItem(List.Flatten(cll3.EndPoint,-1).Z)),cll3.EndPoint);

clc1 = PolyCurve.ByJoinedCurves(obj1.PerimeterCurves());

clc2 = NurbsCurve.ByPoints(List.Clean(List.Flatten(cll3.EndPoint.Translate(dis1,cld3),-1),false),true);

srf1 = PolySurface.ByJoinedSurfaces(List.Flatten([obj1,Surface.ByLoft([clc1,clc2])],-1));
```

![](https://1430428134-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ld8QK19sjP1I9rhLouo%2F-MC1izlOAdUUW5jauqY9%2F-MC1jmMaU1higHlVJtls%2Fcloth1_2020-07-12_04-46-54.png?alt=media\&token=1282ffcd-edac-4d76-afbd-36e12f4baede)

{% file src="/files/-MC1juXCro2\_qZBqxA2X" %}
Dynamo ver 2.8
{% endfile %}
