Sorry I wasn’t able to run through the edits. Please see below:

def subcode(dai:var,n:var)

{

return=[Imperative]

{

if(n==1)

{

rad=dai/2;

p=(1+Math.Sqrt(5))/2;

a=Point.ByCoordinates({0,0,0,0,p,-p,-p,p,1,-1,-1,1},{1,-1,-1,1,0,0,0,0,p,p,-p,-p},{p,p,-p,-p,1,1,-1,-1,0,0,0,0});

b={{a[0],a[8],a[9]},{a[0],a[9],a[5]},{a[0],a[5],a[1]},{a[0],a[1],a[4]},{a[0],a[4],a[8]},

{a[1],a[5],a[10]},{a[1],a[10],a[11]},{a[1],a[11],a[4]},{a[2],a[3],a[7]},{a[2],a[7],a[11]},

{a[2],a[11],a[10]},{a[2],a[10],a[6]},{a[2],a[6],a[3]},{a[3],a[6],a[9]},{a[3],a[9],a[8]},

{a[3],a[8],a[7]},{a[4],a[11],a[7]},{a[4],a[7],a[8]},{a[5],a[9],a[6]},{a[5],a[6],a[10]}};

tri=Surface.ByPerimeterPoints(b);

crv1=tri.PerimeterCurves();

len1=List.GetItemAtIndex(crv1<1>,0).Length;

len2=len1/n;

pnt1=List.GetItemAtIndex(crv1<1>,0).StartPoint;

pnt2=List.GetItemAtIndex(crv1<1>,1).StartPoint;

pnt3=List.GetItemAtIndex(crv1<1>,2).StartPoint;

dir1=Vector.ByTwoPoints(pnt1,pnt2);

dir2=Vector.ByTwoPoints(pnt1,pnt3);

dir3=Vector.ByTwoPoints(pnt2,pnt3);

pnt4=pnt1.Translate(dir1,len2);

pnt5=pnt1.Translate(dir2,len2);

sub1=Polygon.ByPoints(Transpose({pnt1,pnt4,pnt5}));

n2=(0…(n-1))*len2<1>;

sub2=sub1.Translate(dir1,n2);

n3=List.TakeItems(n2<1>,1…n);

sub3=sub2.Translate(dir3,n3);

pnt6=pnt4.Translate(dir2,len2);

sub4=Polygon.ByPoints(Transpose({pnt4,pnt5,pnt6}));

n4=(0…(n-2))*len2<1>;

sub5=sub4.Translate(dir1,n4);

n5=List.TakeItems(n4<1>,1…n);

sub6=sub5.Translate(dir3,n5);

plPnt1=Flatten({sub3,sub6}).Points;

plDir1=Vector.ByTwoPoints(Point.Origin(),plPnt1);

sph=Sphere.ByCenterPointRadius(Point.Origin(),rad);

plPnt21=Flatten(sph.ProjectInputOnto(plPnt1,plDir1)<1>);

pl1=Polygon.ByPoints(plPnt21);

sr1=pl1.Patch();

{

return=crv1;

}

else

{

return=sr1;

}

}

};