Walden

//Tank Position
TankCen=Point.ByCoordinates(0,0,720.5);
Vantage=TankCen.Translate(Vector.ZAxis(),5.5);
Base=TankCen.Translate(Vector.ZAxis(),2);
//Shrine positions
Anjanaya=Point.ByCoordinates(64.982,224.412,741.821);
Ganesha=Point.ByCoordinates(7.910,200.187,742.974);
ShivaLinga=Point.ByCoordinates(-3.873,42.791,722.440);
Subramanya=Point.ByCoordinates(-101.993,227.327,750.097);
Shiva=Point.ByCoordinates(-516.424,-23.435,678.037);
Dhanwanthari=Point.ByCoordinates(-88.529,-21.002,713.843);
Buddha=Point.ByCoordinates(-508.277,-149.171,661.635);
Nagas=Point.ByCoordinates(-385.322,-165.240,680.901);
Vanadevatha=Point.ByCoordinates(-360.374,-177.952,684.753);
Jesus=Point.ByCoordinates(-144.263,-97.897,711.005);
Krishna=Point.ByCoordinates(-21.942,-36.820,720.496);
Shrines=[Krishna,Jesus,Vanadevatha,Nagas,Buddha,Dhanwanthari,Shiva,Subramanya,ShivaLinga,Ganesha,Anjanaya];
ShrineConnect=Line.ByStartPointEndPoint(Vantage,Shrines);
GridSpacing=1;
GridMinRadius=6;
GridMaxRadius=16;
//BaseGrid
BaseGrid=Point.ByCoordinates((-20..20..GridSpacing)<1>,(-20..20..GridSpacing)<2>,Base.Z);
BaseDist=BaseGrid.DistanceTo(Base);
Cyl1=Cylinder.ByPointsRadius((Point.ByCoordinates(0,0,600)),(Point.ByCoordinates(0,0,800)),GridMaxRadius);
Cyl2=Cylinder.ByPointsRadius((Point.ByCoordinates(0,0,600)),(Point.ByCoordinates(0,0,800)),GridMinRadius);
Cyl=Cyl1.Difference(Cyl2);
ShrineRidges=Flatten(Cyl.Intersect(ShrineConnect));
ShrineConnectSurf=Surface.ByRuledLoft(ShrineRidges);
ShrineConnectSurfExp=ShrineConnectSurf.Explode();
//Extents of Walls
ShrineSurfPnts1=ShrineConnectSurfExp<1>.Intersect(Flatten(BaseGrid.Project(ShrineConnectSurf,Vector.ZAxis()))<2>);
ShrineSurfPnts=Flatten(ShrineSurfPnts1<1>);
GrdBndBx=(BoundingBox.ByGeometry(Flatten(ShrineSurfPnts1)));
GrdBndBxMx=GrdBndBx.MaxPoint;
GrdBndBxMn=GrdBndBx.MinPoint;
//Extent of Roof
ShrineRf=Flatten([(Point.ByCoordinates(110.499,-206.013,701.623)),Shrines,(Point.ByCoordinates(207.827,121.375,710.844))]);
ShrineRfConnect=Line.ByStartPointEndPoint(Vantage,ShrineRf);
CylRf=Cylinder.ByPointsRadius((Point.ByCoordinates(0,0,600)),(Point.ByCoordinates(0,0,800)),(GridMaxRadius+2));
ShrineRfRidges=Flatten(CylRf.Intersect(ShrineRfConnect));
ShrineRfConnectSurf=Surface.ByLoft(ShrineRfRidges);
//Group by Height Range-Walls
h1=[725.00,726.30];
h2=[725.62,727.50];
PnGrBl1=(ShrineSurfPnts<1>.Z)>h1<2>&&(ShrineSurfPnts<1>.Z)<h2<2>;
PntGrp1=List.FirstItem(List.FilterByBoolMask(ShrineSurfPnts,PnGrBl1<1>)<1>);
PntGrp=Transpose(PntGrp1);
SldDivsPnt=Flatten(PntGrp);
SldDivsPntsGrd=Point.ByCoordinates(SldDivsPnt.X,SldDivsPnt.Y,Base.Z);
SldDivsBasePln=Plane.ByOriginNormal(Base,Vector.ZAxis());
SldDivsBasePro=Rectangle.ByWidthLength(CoordinateSystem.ByOrigin(SldDivsPntsGrd),GridSpacing,GridSpacing);
SldDivsBaseSol1=SldDivsBasePro.ExtrudeAsSolid(Vector.ZAxis(),1);
SldDivsBaseSol2=Solid.ByUnion(SldDivsBaseSol1);
SldDivsBaseSurf=SldDivsBaseSol2.IntersectAll(SldDivsBasePln);
SldDivsBasePerCrv=SldDivsBaseSurf.PerimeterCurves();
SldDivsBasePerPnt=SldDivsBasePerCrv.StartPoint;
SldDivsBasePerNur=NurbsCurve.ByControlPoints(SldDivsBasePerPnt,1,true);
SldDivs1=SldDivsBasePerNur.ExtrudeAsSolid(Vector.ZAxis(),3);
SldDivs=Solid.ByUnion(List.Clean(Flatten(SldDivs1),false));
SldDivsFlr=SldDivs.IntersectAll(Plane.ByOriginNormal(Base,Vector.ZAxis()));
BasePerCrv=SldDivsFlr.PerimeterCurves();
BasePerPnt=BasePerCrv.StartPoint;
BasePerNur=NurbsCurve.ByControlPoints(BasePerPnt,9,true);
BaseSol1=BasePerNur.ExtrudeAsSolid(Vector.ZAxis(),6);
BaseSol2=BasePerNur.ExtrudeAsSolid(Vector.ZAxis(),[-0.75,-0.3,-3.0]);
BaseSol3=BaseSol1.Union(BaseSol2);
BaseSol4=(List.Transpose(BaseSol3.Split(ShrineRfConnectSurf)))[0];
//Frames and Stilts
PntsParm=[(0.275..0.475..#5),(0.145..0.3..#4),(-0.01..0.35..#4)];
StltHt=[3.6,3,0.25];
FrmIntPln=BasePerNur.PlaneAtParameter(PntsParm);
frminoff=0.30;
frmoutoff=0.15;
frmthk=0.3;
SolThnShl=BaseSol4.ThinShell(frminoff,frminoff);
FrmSur=Flatten(SolThnShl.Intersect(FrmIntPln)<1>);
FrmSol1=FrmSur.Thicken(frmthk,true);
FrmSol2=Solid.ByUnion(FrmSol1);
SolCutPnt=(BoundingBox.ByGeometry(BaseSol4).MinPoint).Translate(Vector.ZAxis(),frminoff+3);
SolCutPln=Plane.ByOriginNormal(SolCutPnt,Vector.ZAxis());
StltSur=FrmSol2.Intersect(SolCutPln);
StltSol=StltSur.Thicken(-(0.1+StltHt),false);
FrmSol3=FrmSol2.UnionAll(StltSol);
Frms=FrmSol3.Translate(Vector.ZAxis(),-(frminoff));
BaseSol5=BaseSol4.DifferenceAll(Frms);
//Floor Area
SldDivsAre=Flatten(SldDivsFlr.Area);
//Roofs
Rfh1=[725.00];
Rfh2=[727.50];
RfPnGrBl1=(ShrineSurfPnts<1>.Z)>Rfh1<2>&&(ShrineSurfPnts<1>.Z)<Rfh2<2>;
RfPntGrp1=List.FirstItem(List.FilterByBoolMask(ShrineSurfPnts,RfPnGrBl1<1>)<1>);
RfPntGrp=Transpose(RfPntGrp1);
RfDivsPnt=Flatten(RfPntGrp);
RfDivsPntsGrd=Point.ByCoordinates(RfDivsPnt.X,RfDivsPnt.Y,Base.Z);
RfDivsBasePln=Plane.ByOriginNormal(Base,Vector.ZAxis());
RfDivsBasePro=Rectangle.ByWidthLength(CoordinateSystem.ByOrigin(RfDivsPntsGrd),GridSpacing,GridSpacing);
RfDivsBaseSol1=RfDivsBasePro.ExtrudeAsSolid(Vector.ZAxis(),1);
RfDivsBaseSol2=Solid.ByUnion(RfDivsBaseSol1);
RfDivsBaseSurf=RfDivsBaseSol2.IntersectAll(RfDivsBasePln);
RfDivsBasePerCrv=RfDivsBaseSurf.PerimeterCurves();
RfDivsBasePerPnt=RfDivsBasePerCrv.StartPoint;
RfDivsBasePerNur=NurbsCurve.ByControlPoints(RfDivsBasePerPnt,1,true);
RfDivs1=RfDivsBasePerNur.ExtrudeAsSolid(Vector.ZAxis(),3);
RfDivs=Solid.ByUnion(Flatten(List.Clean(RfDivs1,false)));
RfDivsFlr=RfDivs.IntersectAll(Plane.ByOriginNormal(Base,Vector.ZAxis()));
RfPerCrv=RfDivsFlr.PerimeterCurves();
RfPerPnt=RfPerCrv.StartPoint;
RfPerNur=NurbsCurve.ByControlPoints(RfPerPnt,10,true);
RfPerCur=RfPerNur.Offset(1.5);
RfSol1=RfPerCur.ExtrudeAsSolid(Vector.ZAxis(),6);
RfSur=Flatten(RfSol1.IntersectAll(ShrineRfConnectSurf));
RfSol=RfSur.Thicken(-0.1);
//RfSur=PolySurface.ByJoinedSurfaces(RfSur1);
//Extent of Openings
/*
FilPth="E:\\Projects\\India\\2015-AR01-WAL\\Dynamo\\SolarData\\Walden-";
OpnExt1=InsValOpn(120000,200000,4.5,5.0,723.0,1.5,1.5,FilPth+"1.csv");
OpnExt2=InsValOpn(120000,200000,4.5,4.0,721.0,1.5,1.5,FilPth+"2.csv");
OpnExt3=InsValOpn(120000,225000,4.5,4.0,723.5,1.5,1.5,FilPth+"3.csv");
OpnExt={OpnExt1,OpnExt2,OpnExt3};
BaseSol6=BaseSol5.DifferenceAll(OpnExt);
BaseSol7=BaseSol5.DifferenceAll(BaseSol6);
Elements=Flatten({BaseSol6,BaseSol7,Frms,RfSol});
*/;
//Function-Openings based on solar insolation values
def InsValOpn(InsMin,InsMax,RecWidFac,RecLenFac,BaseMin,WidPow,LenPow,FlPth)
{
InsPnt=ImportFromCSV(FlPth);
InsolationValue=InsPnt[0];
InsRefPnt=Point.ByCoordinates(InsPnt[1]/3.28084,InsPnt[2]/3.28084,InsPnt[3]/3.28084);
InsRefDir=Vector.ByCoordinates(InsPnt[4]/3.28084,InsPnt[5]/3.28084,InsPnt[6]/3.28084);
//Filter points based on Z coordinate
MaskZ=(InsRefPnt.Z)>BaseMin;
InsValBas=List.FilterByBoolMask(InsolationValue,MaskZ)["in"];
InsPntBas=List.FilterByBoolMask(InsRefPnt,MaskZ)["in"];
InsDirBas=List.FilterByBoolMask(InsRefDir,MaskZ)["in"];
//Filtering points based on Insolation Values range
Mask=InsValBas>InsMin&&InsValBas<InsMax;
InsValFil=List.FilterByBoolMask(InsValBas,Mask)["in"];
InsPntFil=List.FilterByBoolMask(InsPntBas,Mask)["in"];
InsDirFil=List.FilterByBoolMask(InsDirBas,Mask)["in"];
//Rectangular Opening
RecBndSin=Rectangle.ByWidthLength(Plane.ByOriginNormal(InsPntFil,InsDirFil),RecWidFac/Math.Pow(InsValFil/100000,WidPow),RecLenFac/Math.Pow(InsValFil/100000,LenPow));
RecSurSin=Surface.ByPatch(RecBndSin);
RecSldSin=RecSurSin.Thicken(1,true);
OpnSldCom=Solid.ByUnion(RecSldSin);
return=OpnSldCom;
};