Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Get1DayRequirement( Water_supply )
- local Capacity;
- local centerObb = FXGeom.GetBoundingOBB(Water_supply):GetPos().z
- local NegNormTbl = {}
- local pnt = (centerObb + 250) /1000
- local dist1, dist2
- local sideFacesQry = "SELECT tf.centroid as cntr, tf.normal as norm\n"..
- "FROM bimrl_topo_face tf\n"..
- "WHERE tf.type = 'BODY'\n"..
- "AND tf.elementid = '"..Water_supply:GetAttri("GlobalId").."'\n"..
- "AND tf.orientation = 'SIDE'\n"..
- "AND (tf.centroid::Point3D).z <= "..pnt.."\n"..
- "ORDER BY tf.area DESC LIMIT 8\n"
- local retValQuery = FXBIMRL.GetQueryByFederatedId(sideFacesQry)
- if(retValQuery ~= nil) then
- local retjson = FXRule.DecodeJSONToTable(retValQuery);
- for k,v in pairs(retjson) do
- for k2,v2 in pairs(v) do
- local VectXPos = v2["norm"]["X"]
- local VectYPos = v2["norm"]["Y"]
- local VectZPos = v2["norm"]["Z"]
- local vectTbl = {VectXPos,VectYPos,VectZPos}
- local VectXCntrPos = v2["cntr"]["X"]*1000
- local VectYCntrPos = v2["cntr"]["Y"]*1000
- local VectZCntrPos = v2["cntr"]["Z"]*1000
- local vectCntr = {VectXCntrPos,VectYCntrPos,VectZCntrPos}
- local tbl = {vectTbl, vectCntr}
- table.insert(NegNormTbl, tbl)
- end
- end
- end
- local centerObb = FXGeom.GetBoundingOBB(Water_supply):GetPos().z
- local negPointTbl, CentroidTbl3 = filterPointsFromTable(NegNormTbl)
- local num = 0
- local lineTbl, numTbl, numTbl2 = {},{},{}
- for k2,negPoint in pairs(negPointTbl) do
- for k,posPoint in pairs(negPointTbl) do
- local ResDotProduct = Vector(negPoint[1],negPoint[2],negPoint[3]):Dot(Vector(posPoint[1],posPoint[2],posPoint[3]))
- if ResDotProduct <= -0.9 then
- local pnt1 = Point3D(CentroidTbl3[k][1], CentroidTbl3[k][2], centerObb + num)
- local pnt2 = Point3D(CentroidTbl3[k2][1], CentroidTbl3[k2][2], centerObb + num)
- local line = Line3D(pnt1,pnt2)
- local lineVector = line:GetVector()
- local ResDotProduct2 = lineVector:Dot(Vector(negPoint[1],negPoint[2],negPoint[3]))
- if ResDotProduct2 < 0 then
- local flag = true
- for num,val in pairs(numTbl) do
- if val == k or val == k2 or numTbl2[num] == k or numTbl2[num] == k2 then
- flag = false
- end
- end
- if flag then
- num = 100
- table.insert(lineTbl, line)
- table.insert(numTbl, k)
- table.insert(numTbl2, k2)
- end
- end
- end
- end
- end
- if #lineTbl > 1 then
- dist1 = FXUtility.Round(lineTbl[1]:Length())
- dist2 = FXUtility.Round(lineTbl[2]:Length())
- local arrow1 = DoubleArrow(lineTbl[1]:GetStartPoint(),lineTbl[1]:GetEndPoint())
- local arrow2 = DoubleArrow(lineTbl[2]:GetStartPoint(),lineTbl[2]:GetEndPoint())
- FXUtility.DisplaySolid_Error(Water_supply,"asd")
- CheckReport.AddRelatedGeometry_Info(arrow1)
- CheckReport.AddRelatedGeometry_Info(arrow2)
- local query = "SELECT con.connectedelementid as elementid, con.connectedportlocation \n"..
- "FROM bimrl_relconnection con \n"..
- "WHERE con.connectingelementid = '"..Water_supply:GetAttri("GlobalId").."' \n"..
- "AND con.connectedelementid != 'Dummy Port Element' \n"..
- "AND con.connectedelementtype = 'IFCFLOWSEGMENT' \n"..
- "AND con.connectedelementattrvalue = 'SINK' \n"..
- "AND EXISTS ( \n"..
- "SELECT s.elementid FROM \n"..
- "bimrl_element s, bimrl_relgroup grp \n"..
- "WHERE s.elementtype = 'IFCSYSTEM' \n"..
- "AND lower(s.name) SIMILAR TO lower('%".. SystemTypes[1] .."%') \n"..
- "AND s.elementid = grp.groupelementid \n"..
- "AND con.connectedelementid = grp.memberelementid \n"..
- ")";
- local Grp, Tbl = FXUtility.ReturnQuery( query );
- local PipePoint = {};
- if #Tbl > 1 then
- for _,vT in pairs(Tbl) do
- local Pipe = FXMeasure.GetElementbyGUID( vT.elementid );
- if FXPUBSeriesSSW.getPipeAngle(Pipe) < 30 then
- --[[ LOWEST PIPE ]]
- if PipePoint[1] == nil then
- PipePoint[1] = vT.connectedportlocation;
- else
- if PipePoint[1]['Z'] > vT.connectedportlocation['Z'] then
- PipePoint[1] = vT.connectedportlocation;
- end
- end
- --[[ HIGHEST PIPE ]]
- if PipePoint[2] == nil then
- PipePoint[2] = vT.connectedportlocation;
- else
- if PipePoint[2]['Z'] < vT.connectedportlocation['Z'] then
- PipePoint[2] = vT.connectedportlocation;
- end
- end
- end
- end
- end
- local Top = FXUtility.Round( ( (PipePoint[2]['Z']*1000)-75) ,1);
- local Bot = FXUtility.Round( ( (PipePoint[1]['Z']*1000)+75) ,1);
- local TopPoint = Point3D(PipePoint[2]['X']*1000, PipePoint[2]['Y']*1000, Top);
- local BotPoint = Point3D(PipePoint[2]['X']*1000, PipePoint[2]['Y']*1000, Bot);
- local Depth = FXUtility.Round( Line3D(TopPoint, BotPoint):Length(), 1);
- local Arrow = DoubleArrow(TopPoint,BotPoint);
- CheckReport.AddRelatedGeometry_Info(Arrow)
- print((dist1/1000))
- print((dist2/1000))
- print((Depth/1000))
- Capacity = (dist1/1000) * (dist2/1000) * (Depth/1000);
- end
- ------------------------------------------------------------
- return Capacity;
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement