Retail Space Layout
Design Automation
Last updated
Design Automation
Last updated
// Functions
//
//Shift if obstructed
//
def aisles(clm:var,dir:var,dirShf:var,aisleEdg:var,aisleWid:var,
aisleMin:var,shiftInc:var,aisleGap:var,nos:var)
{
return=[Imperative]
{
cnt = 0;
aisle = [];
while (cnt<nos)
{
clm2 = [];
aisleSrf = [];
aisleSrf1 = [];
aisleStartEdg = [];
shft = 0;
clm1=clm.Translate(dirShf.Reverse(),aisleWid-aisleMin);
clm2=PolySurface.ByJoinedSurfaces(clm.Intersect(clm1));
aisleEndEdg = aisleEdg.Translate(dir,aisleWid);
aisleSrf = Surface.ByLoft([aisleEdg,aisleEndEdg]);
if (dir==dirShf)
{
while (clm2.DoesIntersect(aisleSrf))
{
shft = shft + shiftInc;
aisleSrf = aisleSrf.Translate(dirShf,shft);
aisleEndEdg = aisleEndEdg.Translate(dirShf,shft);
}
aisleStartEdg = aisleEdg;
aisleSrf1 = Surface.ByLoft([aisleStartEdg,aisleEndEdg]);
}
else
{
while (clm2.DoesIntersect(aisleSrf))
{
shft = shft + shiftInc;
aisleSrf = aisleSrf.Translate(dirShf,shft);
aisleEndEdg = aisleEndEdg.Translate(dirShf,shft);
}
aisleStartEdg = aisleEndEdg.Translate(dirShf,aisleWid);
aisleSrf1 = Surface.ByLoft([aisleStartEdg,aisleEndEdg]);
}
aisle[cnt] = [aisleStartEdg,aisleEndEdg,aisleSrf1];
aisleEdg = aisleEndEdg.Translate(dir,aisleGap);
cnt = cnt + 1;
}
return = aisle;
}
};
//
//
//
//Module stacking
//
def modTrn(clm,dir,strEdg,gdlWid1,gdlWid2,gdlCnt,endkDpt)
{
return = [Imperative]
{
edg002 = [];
bln001 = [];
bln002 = [];
edg004 = [];
edg011 = [];
c = 0;
edg00a = aisles(clm,dir,dir,strEdg,endkDpt,endkDpt,0.01,0,1);
edg00b = List.TakeItems(Flatten(edg00a),2);
edg00c = List.GetItemAtIndex(Flatten(edg00a),1);
edg001 = aisles(clm,dir,dir,edg00c,gdlWid1,gdlWid1,gdlWid2,0,gdlCnt);
for (i in edg001)
{
edg002[c] = List.GetItemAtIndex(i,0);
c = c+1;
}
c=0;
dis001 = strEdg.DistanceTo(edg002);
for (i in dis001)
{
bln001[c] = i < (gdlWid1*gdlCnt)+gdlWid1;
c = c+1;
}
c=0;
edg003 = List.FilterByBoolMask(edg001,bln001)["in"];
for (i in edg003)
{
edg004[c] = List.TakeItems(i,2);
c = c+1;
}
c=0;
edg005 = List.LastItem(Flatten(edg004));
edg006 = aisles(clm,dir,dir,edg005,endkDpt,endkDpt,gdlWid2,0,1);
edg007 = List.GetItemAtIndex(Flatten(edg006),1);
edg008 = edg007.Translate(dir.Reverse(),endkDpt);
edg0a8 = [edg008,edg005];
edg009 = [edg008,edg007];
edg010 = List.AddItemToEnd(edg009,List.AddItemToEnd(edg0a8,List.AddItemToFront(edg00b,edg004)));
for(i in edg010)
{
bln002[c] = List.GetItemAtIndex(i,0).DoesIntersect(List.GetItemAtIndex(i,1));
c = c+1;
}
edg011 = List.FilterByBoolMask(edg010,bln002)["out"];
return = edg011;
}
};
//
//
//
//Aisles and Modules
//
def modAsl(clm,dir,strEdg,endEdg,gdlWid1,gdlWid2,gdlCnt,endkDpt,aslWidIdl,aslWidMin)
{
return = [Imperative]
{
c = 0;
d = 0;
dis002 = 0;
gdlCnt01 = gdlCnt;
aslEdg1 = [];
aslEdg2 = [];
aslEdg3 = [];
dis001 = endEdg.DistanceTo(strEdg);
aslEdge = strEdg;
strEdg1 = strEdg;
while (dis002<dis001)
{
if ((dis001-dis002) > ((gdlWid1*gdlCnt)+(endkDpt*2)+aslWidIdl))
{
gdlCnt01 = gdlCnt;
}
else
{
gdlCnt01 = Math.Floor((dis001-dis002-(endkDpt*2)-aslWidIdl)/(gdlWid1));
}
aslEdg1[c] = modTrn(clm,dir,strEdg1,gdlWid1,gdlWid2,gdlCnt01,endkDpt);
aslEdg2[c] = List.LastItem(Flatten(aslEdg1[c]));
aslEdg3[c] = Flatten(aisles(clm,dir,dir,aslEdg2[c],aslWidIdl,aslWidMin,0.01,0,1))[1];
strEdg1 = aslEdg3[c];
dis002 = strEdg1.DistanceTo(strEdg);
c = c+1;
d = d+5;
}
return = aslEdg1;
}
};
//
//
//Alignment and Direction Control
flip = false;
frToRr = true;
lfToRg = true;
//Wall Fixture Depths
wallFxtRear = 0.48;
wallFxtLeft = 0.48;
wallFxtFrnt = 0.48;
wallFxtRght = 0.48;
//Gondola Dimensions
gndlWid001 = 1;
gndlWid002 = 0.5;
gndlDpt001 = 0.75;
gndlCntMax = 12;
endkDpt001 = 0.5;
//Aisle Widths
aslWidIdl = 2.4;
aslWidMin = 1.2;
//Boundary Perimeter
bnd001 = Rectangle.ByWidthLength(80,50);
//Columns
//clm001 = Rectangle.ByWidthLength(0.6,0.9);
clm001 = Rectangle.ByWidthLength(1,1);
clm002 = clm001.Translate(Vector.YAxis(),[-24,-13,0,12,24]);
clm003 = clm002<1>.Translate(Vector.XAxis(),(-36..36..12)<2>);
clm004 = Surface.ByPatch(Flatten(clm003));
clm005 = PolySurface.ByJoinedSurfaces(clm004);
//Boundary Edges
crv001 = bnd001.Explode();
rghtEdg0 = crv001[0];
rearEdg0 = crv001[1];
leftEdg0 = crv001[2];
frntEdg0 = crv001[3];
rghtEdg = flip?frntEdg0:rghtEdg0;
rearEdg = flip?leftEdg0:rearEdg0;
leftEdg = flip?rearEdg0:leftEdg0;
frntEdg = flip?rghtEdg0:frntEdg0;
//Directions
pnt001 = rearEdg.PointAtParameter(0.5);
pnt002 = frntEdg.PointAtParameter(0.5);
pnt003 = leftEdg.PointAtParameter(0.5);
pnt004 = rghtEdg.PointAtParameter(0.5);
dir001 = Vector.ByTwoPoints(pnt001,pnt002);
dir002 = Vector.ByTwoPoints(pnt002,pnt001);
dir003 = Vector.ByTwoPoints(pnt003,pnt004);
dir004 = Vector.ByTwoPoints(pnt004,pnt003);
//Trimmed Boundary Edges
rearEdg001 = Flatten(rearEdg.Trim(leftEdg.Translate(dir003,wallFxtLeft),rearEdg.Intersect(leftEdg)));
rearEdg002 = Flatten(rearEdg001.Trim(rghtEdg.Translate(dir004,wallFxtRght),rearEdg.Intersect(rghtEdg)));
frntEdg001 = Flatten(frntEdg.Trim(leftEdg.Translate(dir003,wallFxtLeft),frntEdg.Intersect(leftEdg)));
frntEdg002 = Flatten(frntEdg001.Trim(rghtEdg.Translate(dir004,wallFxtRght),frntEdg.Intersect(rghtEdg)));
leftEdg001 = Flatten(leftEdg.Trim(rearEdg.Translate(dir001,wallFxtRear),leftEdg.Intersect(rearEdg)));
leftEdg002 = Flatten(leftEdg001.Trim(frntEdg.Translate(dir002,wallFxtFrnt),leftEdg.Intersect(frntEdg)));
rghtEdg001 = Flatten(rghtEdg.Trim(rearEdg.Translate(dir001,wallFxtRear),rghtEdg.Intersect(rearEdg)));
rghtEdg002 = Flatten(rghtEdg001.Trim(frntEdg.Translate(dir002,wallFxtFrnt),rghtEdg.Intersect(frntEdg)));
//Rear Wall Fixtures
rearEdg003 = rearEdg002.Translate(dir001,wallFxtRear);
rearAsl001 = Flatten(aisles(clm005,dir001,dir001,rearEdg003,aslWidIdl,aslWidMin,0.01,0,1));
rearEdg004 = rearAsl001[1];
//Left Wall Fixtures
leftEdg003 = List.FirstItem(leftEdg002.Translate(dir003,wallFxtLeft));
//leftAsl001 = Flatten(aisles(clm005,dir003,dir003,leftEdg003,aslWidIdl,aslWidMin,0.01,0,1));
//leftEdg004 = leftAsl001[1];
//Front Wall Fixtures
frntEdg003 = frntEdg002.Translate(dir002,wallFxtFrnt);
frntAsl001 = Flatten(aisles(clm005,dir002,dir002,frntEdg003,aslWidIdl,aslWidMin,0.01,0,1));
frntEdg004 = frntAsl001[1];
//Right Wall Fixtures
rghtEdg003 = List.FirstItem(rghtEdg002.Translate(dir004,wallFxtLeft));
rghtAsl001 = Flatten(aisles(clm005,dir004,dir004,rghtEdg003,aslWidIdl,aslWidMin,0.01,0,1));
rghtEdg004 = rghtAsl001[1];
//Module Stacking - Longer
frRrMd001 = modAsl(clm005,dir002,frntEdg004,rearEdg,gndlWid001,gndlWid002,gndlCntMax,endkDpt001,1.8,1.2);
frntEdg006 = List.FirstItem(frRrMd001<1><2>);
//Module Stacking - Shorter
leftNos001 = ((leftEdg003.DistanceTo(rghtEdg003))/((gndlDpt001*2)+aslWidIdl))+1;
leftAsl002 = aisles(clm005,dir003,dir003,leftEdg003,aslWidIdl,aslWidMin,0.01,gndlDpt001*2,leftNos001);
leftEdg006 = List.TakeItems(leftAsl002<1>,2);
leftEdg007 = List.FirstItem(leftEdg006 <1>);
bln11 = leftEdg003.DistanceTo(leftEdg007)<leftEdg003.DistanceTo(rghtEdg003);
leftEdg008 = Transpose(List.FilterByBoolMask(leftEdg006,bln11)["in"]);
leftEdg009 = List.DropItems(List.LastItem(leftEdg008),-1).Translate(dir003,gndlDpt001);
//Module Placement Points
mdulPnt001 = Flatten((frntEdg006<1>.Intersect(leftEdg009<2>))<1><2>);
mdulPnt002 = List.DropItems(mdulPnt001<1><2>,1);
mdulPnt003 = List.DropItems(List.Sublists(mdulPnt002<1><2>,0..1,1)<1><2>,-1);
mdulPnt004 = List.FirstItem(mdulPnt003<1><2><3>);
mdulPnt005 = List.LastItem(mdulPnt003<1><2><3>);
mdulDis001 = Math.Round((mdulPnt004).DistanceTo(mdulPnt005),2);
mdulDis002 = List.Reverse((0..#(Math.Ceiling(mdulDis001))..gndlWid001)<1><2><3>);
mdulPnt008 = Flatten(mdulPnt005.Translate(dir001,mdulDis002)<1><2>);
//Module Start-End Points
mdulPnt009 = List.AddItemToFront(List.FirstItem(mdulPnt004<1><2>)<1><2>,mdulPnt008<1><2>);
mdulPnt010 = List.DropItems(List.Sublists(mdulPnt009<1><2>,0..1,1)<1><2>,-1);
mdulPnt011 = List.FirstItem(mdulPnt010<1><2><3>);
mdulPnt012 = List.LastItem(mdulPnt010<1><2><3>);
//Module Placement Points
mdulDis003 = Math.Round((mdulPnt011).DistanceTo(mdulPnt012),2);
mdulPnt013 = mdulDis003==gndlWid001?mdulPnt009.Translate(dir002,gndlWid001/2):mdulPnt009.Translate(dir002,gndlWid002/2);
//Placeholder Rectangles (To be deleted once Families are loaded)
mdulFml001 = Rectangle.ByWidthLength(Plane.ByOriginNormal(mdulPnt013,Vector.ZAxis()),gndlWid001,gndlDpt001*2);
mdulFml002 = Rectangle.ByWidthLength(Plane.ByOriginNormal(mdulPnt013,Vector.ZAxis()),gndlWid002,gndlDpt001*2);
mdulTyp001 = mdulDis003==gndlWid001?mdulFml001:mdulFml002;
//Module Rotation
mdulCir001 = Circle.ByCenterPointRadius(mdulPnt013,gndlDpt001);
mdulPnt014 = List.Clean((leftEdg009<1>.Intersect(mdulCir001<2>))<1><2>,false);
mdulDir001 = Vector.ByTwoPoints(List.FirstItem(mdulPnt014<1><2><3><4>),List.LastItem(mdulPnt014<1><2><3><4>));
mdulDir002 = Flatten(Transpose(mdulDir001)<1><2>);
mdulAng001 = Vector.XAxis().AngleWithVector(mdulDir002);
mdulTyp002 = mdulTyp001.Rotate(Plane.ByOriginNormal(mdulPnt013,Vector.ZAxis()),-mdulAng001);
mdulTyp003 = List.FilterByBoolMask(mdulTyp002,mdulTyp002.DoesIntersect(clm005))["out"];