Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2020
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.24 KB | None | 0 0
  1.  
  2. function Get1DayRequirement( Water_supply )
  3. local Capacity;
  4. local centerObb = FXGeom.GetBoundingOBB(Water_supply):GetPos().z
  5. local NegNormTbl = {}
  6. local pnt = (centerObb + 250) /1000
  7. local dist1, dist2
  8. local sideFacesQry = "SELECT tf.centroid as cntr, tf.normal as norm\n"..
  9. "FROM bimrl_topo_face tf\n"..
  10. "WHERE tf.type = 'BODY'\n"..
  11. "AND tf.elementid = '"..Water_supply:GetAttri("GlobalId").."'\n"..
  12. "AND tf.orientation = 'SIDE'\n"..
  13. "AND (tf.centroid::Point3D).z <= "..pnt.."\n"..
  14. "ORDER BY tf.area DESC LIMIT 8\n"
  15.  
  16. local retValQuery = FXBIMRL.GetQueryByFederatedId(sideFacesQry)
  17. if(retValQuery ~= nil) then
  18. local retjson = FXRule.DecodeJSONToTable(retValQuery);
  19. for k,v in pairs(retjson) do
  20. for k2,v2 in pairs(v) do
  21. local VectXPos = v2["norm"]["X"]
  22. local VectYPos = v2["norm"]["Y"]
  23. local VectZPos = v2["norm"]["Z"]
  24.  
  25. local vectTbl = {VectXPos,VectYPos,VectZPos}
  26.  
  27. local VectXCntrPos = v2["cntr"]["X"]*1000
  28. local VectYCntrPos = v2["cntr"]["Y"]*1000
  29. local VectZCntrPos = v2["cntr"]["Z"]*1000
  30.  
  31. local vectCntr = {VectXCntrPos,VectYCntrPos,VectZCntrPos}
  32.  
  33. local tbl = {vectTbl, vectCntr}
  34.  
  35. table.insert(NegNormTbl, tbl)
  36. end
  37. end
  38. end
  39.  
  40. local centerObb = FXGeom.GetBoundingOBB(Water_supply):GetPos().z
  41.  
  42. local negPointTbl, CentroidTbl3 = filterPointsFromTable(NegNormTbl)
  43. local num = 0
  44. local lineTbl, numTbl, numTbl2 = {},{},{}
  45.  
  46. for k2,negPoint in pairs(negPointTbl) do
  47. for k,posPoint in pairs(negPointTbl) do
  48. local ResDotProduct = Vector(negPoint[1],negPoint[2],negPoint[3]):Dot(Vector(posPoint[1],posPoint[2],posPoint[3]))
  49.  
  50. if ResDotProduct <= -0.9 then
  51. local pnt1 = Point3D(CentroidTbl3[k][1], CentroidTbl3[k][2], centerObb + num)
  52. local pnt2 = Point3D(CentroidTbl3[k2][1], CentroidTbl3[k2][2], centerObb + num)
  53.  
  54. local line = Line3D(pnt1,pnt2)
  55. local lineVector = line:GetVector()
  56.  
  57. local ResDotProduct2 = lineVector:Dot(Vector(negPoint[1],negPoint[2],negPoint[3]))
  58.  
  59. if ResDotProduct2 < 0 then
  60. local flag = true
  61. for num,val in pairs(numTbl) do
  62. if val == k or val == k2 or numTbl2[num] == k or numTbl2[num] == k2 then
  63. flag = false
  64. end
  65. end
  66.  
  67. if flag then
  68. num = 100
  69. table.insert(lineTbl, line)
  70. table.insert(numTbl, k)
  71. table.insert(numTbl2, k2)
  72. end
  73. end
  74. end
  75. end
  76. end
  77.  
  78. if #lineTbl > 1 then
  79. dist1 = FXUtility.Round(lineTbl[1]:Length())
  80. dist2 = FXUtility.Round(lineTbl[2]:Length())
  81.  
  82. local arrow1 = DoubleArrow(lineTbl[1]:GetStartPoint(),lineTbl[1]:GetEndPoint())
  83. local arrow2 = DoubleArrow(lineTbl[2]:GetStartPoint(),lineTbl[2]:GetEndPoint())
  84. FXUtility.DisplaySolid_Error(Water_supply,"asd")
  85. CheckReport.AddRelatedGeometry_Info(arrow1)
  86. CheckReport.AddRelatedGeometry_Info(arrow2)
  87.  
  88. local query = "SELECT con.connectedelementid as elementid, con.connectedportlocation \n"..
  89. "FROM bimrl_relconnection con \n"..
  90. "WHERE con.connectingelementid = '"..Water_supply:GetAttri("GlobalId").."' \n"..
  91. "AND con.connectedelementid != 'Dummy Port Element' \n"..
  92. "AND con.connectedelementtype = 'IFCFLOWSEGMENT' \n"..
  93. "AND con.connectedelementattrvalue = 'SINK' \n"..
  94. "AND EXISTS ( \n"..
  95. "SELECT s.elementid FROM \n"..
  96. "bimrl_element s, bimrl_relgroup grp \n"..
  97. "WHERE s.elementtype = 'IFCSYSTEM' \n"..
  98. "AND lower(s.name) SIMILAR TO lower('%".. SystemTypes[1] .."%') \n"..
  99. "AND s.elementid = grp.groupelementid \n"..
  100. "AND con.connectedelementid = grp.memberelementid \n"..
  101. ")";
  102.  
  103. local Grp, Tbl = FXUtility.ReturnQuery( query );
  104. local PipePoint = {};
  105.  
  106. if #Tbl > 1 then
  107. for _,vT in pairs(Tbl) do
  108. local Pipe = FXMeasure.GetElementbyGUID( vT.elementid );
  109. if FXPUBSeriesSSW.getPipeAngle(Pipe) < 30 then
  110. --[[ LOWEST PIPE ]]
  111. if PipePoint[1] == nil then
  112. PipePoint[1] = vT.connectedportlocation;
  113. else
  114. if PipePoint[1]['Z'] > vT.connectedportlocation['Z'] then
  115. PipePoint[1] = vT.connectedportlocation;
  116. end
  117. end
  118.  
  119. --[[ HIGHEST PIPE ]]
  120. if PipePoint[2] == nil then
  121. PipePoint[2] = vT.connectedportlocation;
  122. else
  123. if PipePoint[2]['Z'] < vT.connectedportlocation['Z'] then
  124. PipePoint[2] = vT.connectedportlocation;
  125. end
  126. end
  127. end
  128. end
  129. end
  130.  
  131. local Top = FXUtility.Round( ( (PipePoint[2]['Z']*1000)-75) ,1);
  132. local Bot = FXUtility.Round( ( (PipePoint[1]['Z']*1000)+75) ,1);
  133.  
  134. local TopPoint = Point3D(PipePoint[2]['X']*1000, PipePoint[2]['Y']*1000, Top);
  135. local BotPoint = Point3D(PipePoint[2]['X']*1000, PipePoint[2]['Y']*1000, Bot);
  136.  
  137. local Depth = FXUtility.Round( Line3D(TopPoint, BotPoint):Length(), 1);
  138. local Arrow = DoubleArrow(TopPoint,BotPoint);
  139. CheckReport.AddRelatedGeometry_Info(Arrow)
  140.  
  141. print((dist1/1000))
  142. print((dist2/1000))
  143. print((Depth/1000))
  144.  
  145. Capacity = (dist1/1000) * (dist2/1000) * (Depth/1000);
  146. end
  147. ------------------------------------------------------------
  148.  
  149. return Capacity;
  150. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement