Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.55 KB | None | 0 0
  1. --Author: Carl Balajadia 08/19/19
  2. --Updated by Jayson Barateta : 04/12/19 Sprint 7.3 - Minor update
  3. --Updated by Jayson Barateta : 09/12/19 Sprint 7.4 - Minor update
  4.  
  5. local json = require("json");
  6.  
  7. function main()
  8. CheckEngine.SetCheckType("Building")
  9. CheckEngine.BindCheckFunc("checkRule")
  10. CheckEngine.RunCheckPipeline()
  11. end
  12.  
  13. function checkRule(Building)
  14. local ok, path = pcall(FXPUB.GetFilePath())
  15. local parsedXml = FXPUB.ParseXml(path(), "SSW_1_2_3_C_DRAINLINES_FOR_MULTIPLE_LOTS")
  16. local systemTypes = FXRule.ParseValues(parsedXml, "SystemType")
  17. local tblValues = FXRule.FilterTableValuesNew(parsedXml)
  18. local conditionValues1 = FXRule.ParseValues(parsedXml,'Condition1')
  19. local conditionValues2 = FXRule.ParseValues(parsedXml,'Condition2')
  20. local conditionValues3 = FXRule.ParseValues(parsedXml,'Condition3')
  21. local conditionValues4 = FXRule.ParseValues(parsedXml,'Condition4')
  22.  
  23. local Bridgeinitialized = FXBIMRL.InitializeBridge(Building)
  24. local FedID = FXBIMRL.GetFedID(Building)
  25. local drainLineStr = conditionValues1[2]
  26. local publicSewerStr = conditionValues1[4]:lower()
  27. local strYJunction = conditionValues2[2]
  28. local sitePset = conditionValues3[1];
  29. local json = require("json")
  30. local hasError = false
  31. local isObjsComplete = true
  32. local hasYjunctionResult = false
  33. local strIfcTypeIC
  34. local strPredefinedIC
  35. local strIfcTypeDrainLine
  36. local strPredefinedDrainLine
  37. local strIfcTypeJunction
  38. local strPredefinedJunction
  39. local strIfcTypeManhole
  40. local strPredefinedManhole
  41. local nonCompliantIC = {}
  42. local nonCompliantSite = {}
  43. local nonCompliantNIC = {}
  44. local nonCompliantDrainLine = {}
  45.  
  46. for k,v in pairs(tblValues) do
  47. --table data for drain-line
  48. if k == "Pipe" then
  49. for k1,v1 in pairs (v) do
  50. for k2,v2 in pairs (v1) do
  51. if type(v2) == "table" then
  52. strPredefinedDrainLine = v2["operator"]
  53. else
  54. if k2 == "type" then
  55. strIfcTypeDrainLine = v2;
  56. end
  57. end
  58. end
  59. end
  60. end
  61.  
  62. --table data for inspection chamber
  63. if k == "IC" then
  64. for k1,v1 in pairs (v) do
  65. for k2,v2 in pairs (v1) do
  66. if type(v2) == "table" then
  67. strPredefinedIC = v2["operator"]
  68. else
  69. if k2 == "type" then
  70. strIfcTypeIC = v2;
  71. end
  72. end
  73. end
  74. end
  75. end
  76.  
  77. --table data for manhole
  78. if k == "Manhole" then
  79. for k1,v1 in pairs (v) do
  80. for k2,v2 in pairs (v1) do
  81. if type(v2) == "table" then
  82. strPredefinedManhole = v2["operator"]
  83. else
  84. if k2 == "type" then
  85. strIfcTypeManhole = v2;
  86. end
  87. end
  88. end
  89. end
  90. end
  91.  
  92. --table data for junctions
  93. if k == "Junction" then
  94. for k1,v1 in pairs (v) do
  95. for k2,v2 in pairs (v1) do
  96. if type(v2) == "table" then
  97. strPredefinedJunction = v2["operator"]
  98. else
  99. if k2 == "type" then
  100. strIfcTypeJunction = v2;
  101. end
  102. end
  103. end
  104. end
  105. end
  106. end
  107.  
  108. local inspectionChamberStr = FX_OUTPUTSTRING.GetResourceString(strPredefinedIC)
  109. local manholeStr = FX_OUTPUTSTRING.GetResourceString(strPredefinedManhole)
  110. local yJunctionStr = strYJunction;
  111.  
  112. local CheckedPipe = {};
  113.  
  114. if FX_OUTPUTSTRING.CheckInResourceList( inspectionChamberStr ) == false or FX_OUTPUTSTRING.CheckInResourceList( manholeStr ) == false then
  115. FXLOGGER.LogSystemError(debug.getinfo(1,'S').source.." (".. debug.getinfo(1).currentline.."): Invalid set value found.")
  116. hasError = true;
  117. end
  118.  
  119. if not Bridgeinitialized then
  120. FXLOGGER.LogSystemError(debug.getinfo(1,'S').source.." (".. debug.getinfo(1).currentline.."): Initialize bridge failed.")
  121. hasError = true;
  122. end
  123.  
  124. if not FedID then
  125. FXLOGGER.LogSystemError(debug.getinfo(1,'S').source.." (".. debug.getinfo(1).currentline.."): No federated ID found.")
  126. hasError = true;
  127. end
  128.  
  129. if not hasError then
  130. FXBIMRL.initSystemGraphVariables(FedID);
  131. FXBIMRL.initFullSystemGraphs();
  132. FXBIMRL.excludeElementID("Dummy Port Element");
  133. FXBIMRL.setSystemFlowDirection(0);
  134. FXBIMRL.generateGraph();
  135.  
  136. local querySite = "SELECT DISTINCT obj.elementid, prop.propertyvalue AS reference \n"..
  137. "FROM \n"..
  138. "bimrl_element obj \n"..
  139. "LEFT JOIN bimrl_elementproperties prop \n"..
  140. "ON obj.elementid = prop.elementid \n"..
  141. "WHERE \n"..
  142. "obj.elementtype = 'IFCSITE' \n"..
  143. "AND prop.propertygroupname SIMILAR TO 'PUBPset_IfcSite|PUBPset_Site' \n"..
  144. "AND lower(prop.propertyname) LIKE lower('"..sitePset.."')";
  145. print(querySite)
  146. local jsonSite = FXBIMRL.GetQueryByFederatedId(querySite)
  147. print("querySite")
  148. print(jsonSite)
  149. if jsonSite == nil then
  150. FXUtility.DisplaySolid_Attention(Building, "Site is not provided.")
  151. isObjsComplete = false
  152. return
  153. end
  154.  
  155. local PDevSet = Building:GetAuxAttri(conditionValues4[1]);
  156. local PDevList = FXPUB.Split(conditionValues4[2],",");
  157. local PDevFlag = false;
  158.  
  159. if PDevSet ~= nil then
  160. for _,vPDL in pairs(PDevList) do
  161. if FXUtility.HasPatterInString( PDevSet, vPDL) then
  162. PDevFlag = true;
  163. end
  164. end
  165. else
  166. FXUtility.DisplaySolid_Attention(Building,"Project development type is not provided.");
  167. return;
  168. end
  169.  
  170. if not PDevFlag then
  171. FXUtility.DisplaySolid_Attention(Building,"Project development type does not match.");
  172. return;
  173. end
  174.  
  175. local queryManhole = "SELECT DISTINCT obj.elementid \n"..
  176. "FROM \n"..
  177. "bimrl_element obj, \n"..
  178. "bimrl_type type \n"..
  179. "WHERE \n"..
  180. "obj.elementtype = 'IFCDISTRIBUTIONCHAMBERELEMENT' \n"..
  181. "AND obj.typeid = type.elementid \n"..
  182. "AND type.ifctype = '"..strIfcTypeManhole:upper().."' \n"..
  183. "AND type.predefinedtype = '"..strPredefinedManhole:upper().."'";
  184. print(queryManhole)
  185. print("queryManhole")
  186. local grpManhole, tblManhole_ID = ReturnQuery( queryManhole )
  187.  
  188. if grpManhole == nil then
  189. FXUtility.DisplaySolid_Attention(Building, manholeStr.." is not provided")
  190. isObjsComplete = false
  191. return
  192. end
  193. print(isObjsComplete)
  194. if isObjsComplete then
  195. local tblSite = json:decode(jsonSite)["Table1"]
  196.  
  197. if #tblSite > 0 then
  198. for i=1, #tblSite do
  199. local siteID = tblSite[i]["elementid"]
  200. local siteReference = tblSite[i]["reference"]
  201.  
  202. if siteReference ~= nil and siteReference ~= "nil" then
  203. local hasICConnectedToManhole = false
  204. local targetExcluded
  205. local grpIC, tblIC_ID = GetSiteIC(siteID, strIfcTypeIC, strPredefinedIC)
  206.  
  207. if grpIC == nil or #grpIC == 0 then
  208. FXUtility.DisplaySolid_Attention(Building, inspectionChamberStr.." is not provided")
  209. else
  210. for i=1, #tblIC_ID do
  211. local IC_ID = tblIC_ID[i]["elementid"]
  212.  
  213. local targetTblManhole = {strIfcTypeManhole:upper(), strPredefinedManhole:upper()}
  214. local targetTblIC = {strIfcTypeIC:upper(), strPredefinedIC:upper()}
  215. local targetTbl1 = {targetTblManhole}
  216. local targetTbl2 = {targetTblIC}
  217. local target = json:encode(targetTbl1)
  218. targetExcluded = json:encode(targetTbl2)
  219. local initResult = FXBIMRL.findPathToSpecificTypeObjectWithNegativeCondition(IC_ID, target, targetExcluded, 0)
  220. local lastICObjs = {}
  221. print(initResult)
  222. if initResult ~= nil and initResult ~= '[["No path found"]]' then
  223. local tbl = FXRule.DecodeJSONToTable(initResult)
  224. local IC_Obj = FXMeasure.GetElementbyGUID(IC_ID)
  225. local hasYJunction = false;
  226. local hasJunction = false;
  227. local hasManhole = false;
  228. local connManhole
  229. local connJunction
  230.  
  231. for k, v in pairs(tbl) do
  232. for k1, v1 in pairs (v) do
  233. table.insert(lastICObjs, v1);
  234.  
  235. local obj = FXMeasure.GetElementbyGUID(v1)
  236. local preDef = FXRule.NewGetPredefinedType(obj, "IFCPIPEFITTINGTYPE")
  237.  
  238. if connJunction == nil and FXUtility.HasPatterInString(obj.Type, "FlowFitting") and (preDef ~= nil and FXUtility.HasPatterInString(preDef, "JUNCTION")) then
  239. connJunction = obj
  240. else
  241. connManhole = obj
  242. end
  243. end
  244. end
  245.  
  246. if #lastICObjs > 0 then
  247. hasICConnectedToManhole = true
  248.  
  249. local yJunctionVal
  250. if connJunction ~= nil then
  251. hasJunction = true
  252. yJunctionVal, hasBackdrop = checkFittingAngle(connJunction, IC_Obj, connManhole)
  253.  
  254. if yJunctionVal == 1 then
  255. hasYJunction = true
  256. end
  257. end
  258.  
  259. if connManhole ~= nil then
  260. local drainLine, tempjunction;
  261. local Grp, Tbl = FXPUB.FindPath(IC_ID,connManhole:GetAttri("GlobalId"));
  262. Grp:ForEach(function(element )
  263. if element.Type == 'FlowSegment' and tempjunction == nil then
  264. drainLine = element;
  265. end
  266.  
  267. if element.Type == 'FlowFitting' and tempjunction == nil then
  268. local preDef = FXRule.NewGetPredefinedType(element, "IFCPIPEFITTINGTYPE")
  269. if preDef == 'JUNCTION' then
  270. tempjunction = element;
  271. end
  272. end
  273. end)
  274.  
  275. if hasJunction then
  276. if hasYJunction then
  277. FXUtility.DisplaySolid_Compliant(IC_Obj, "Individual "..drainLineStr:lower().." connection from last IC to "..publicSewerStr:lower().." via "..yJunctionStr.." to "..manholeStr:lower()..".")
  278. CheckReport.AddRelatedObj(connManhole, connManhole:GetAttri("Name"))
  279. CheckReport.AddRelatedObj(connJunction, connJunction:GetAttri("Name"))
  280. else
  281. FXUtility.DisplaySolid_Error(IC_Obj, tblSite[i]["reference"].." unit "..drainLineStr:lower().." connection from last IC to "..publicSewerStr:lower().." via "..yJunctionStr.." is not provided.")
  282. CheckReport.AddRelatedObj(connManhole, connManhole:GetAttri("Name"))
  283. CheckReport.AddRelatedObj(connJunction, connJunction:GetAttri("Name"))
  284. end
  285. else
  286. FXUtility.DisplaySolid_Compliant(IC_Obj, drainLineStr.." connection from last IC to "..publicSewerStr:lower().." is provided.")
  287. CheckReport.AddRelatedObj(connManhole, connManhole:GetAttri("Name"))
  288. end
  289.  
  290. if drainLine ~= nil then
  291. CheckReport.AddRelatedObj(drainLine, drainLine:GetAttri("Name"))
  292. end
  293. end
  294. end
  295. end
  296. end
  297. end
  298.  
  299. if not hasICConnectedToManhole then
  300. local lastICNotConnected = {}
  301. local drainLineTbl = {}
  302. local neigborICTbl = {}
  303. local grpIC, neighborIC_ID = GetSiteIC(tblSite, strIfcTypeIC, strPredefinedIC, siteID)
  304. print("neighborIC_ID")
  305. print(neighborIC_ID)
  306. if neighborIC_ID ~= nil then
  307. neighborIC_ID = checkSameICTbl(tblIC_ID, neighborIC_ID)
  308.  
  309. for i=1, #tblIC_ID do
  310. local tblIC = tblIC_ID
  311. local newTbl = {}
  312.  
  313. for j=1, #tblIC do
  314. if not FXUtility.HasPatterInString(tblIC[j]["elementid"], tblIC_ID[i]["elementid"]) then
  315. table.insert(newTbl, tblIC[j]["elementid"])
  316. end
  317. end
  318.  
  319. FXBIMRL.resetGraph()
  320. FXBIMRL.initSystemGraphVariables(FedID)
  321. FXBIMRL.initFullSystemGraphs()
  322. table.insert(newTbl,"Dummy Port Element")
  323. local targetExTbl = {newTbl}
  324. local targetEx = json:encode(targetExTbl)
  325. FXBIMRL.excludeElementID(targetEx)
  326. FXBIMRL.setSystemFlowDirection(2)
  327. FXBIMRL.generateGraph()
  328.  
  329. local isConnectedToOtherIC = false;
  330. local neighborICObjs = {}
  331. local prevObjs = {}
  332.  
  333. for j=1, #neighborIC_ID do
  334. local objsBetween = FXBIMRL.findPathWithNegativeCondition(tblIC_ID[i]["elementid"], neighborIC_ID[j], targetEx, 0)
  335. if objsBetween ~= nil then
  336. local tbl = FXRule.DecodeJSONToTable(objsBetween)
  337. if #prevObjs == 0 or #prevObjs > #tbl then
  338. for k, v in pairs(tbl) do
  339. for k1, v1 in pairs (v) do
  340. if not FXUtility.HasPatterInString(v1,"No path found") then
  341. prevObjs = tbl
  342. end
  343. end
  344. end
  345. end
  346. end
  347. end
  348.  
  349. if prevObjs ~= nil and #prevObjs > 0 then
  350. print("prevObjs")
  351. print(#prevObjs)
  352. for k, v in pairs(prevObjs) do
  353. for k1, v1 in pairs (v) do
  354. isConnectedToOtherIC = true
  355.  
  356. if not FXUtility.HasPatterInString(v1, tblIC_ID[i]["elementid"]) then
  357. table.insert(neighborICObjs, v1)
  358. end
  359. end
  360. end
  361. end
  362.  
  363. local x = 0
  364. print("isConnectedToOtherIC")
  365. print(isConnectedToOtherIC)
  366. if isConnectedToOtherIC then
  367. x = x+1
  368.  
  369. table.insert(lastICNotConnected, tblIC_ID[i]["elementid"])
  370. neigborICTbl[x] = neighborICObjs
  371. local drainLine = getConnectedDrainLine (FedID, tblIC_ID[i]["elementid"], neighborICObjs, strIfcTypeDrainLine, strPredefinedDrainLine, systemTypes)
  372. table.insert(drainLineTbl, drainLine)
  373. end
  374. end
  375. end
  376.  
  377. if #lastICNotConnected > 0 then
  378. for i=1, #lastICNotConnected do
  379. table.insert(nonCompliantIC, FXMeasure.GetElementbyGUID(lastICNotConnected[i]))
  380. table.insert(nonCompliantNIC, neigborICTbl[i])
  381. table.insert(nonCompliantSite, siteReference)
  382. table.insert(nonCompliantDrainLine, drainLineTbl[i])
  383. end
  384. else
  385. FXUtility.DisplaySolid_Attention(Building, "No last IC to check in "..siteReference..".")
  386. end
  387.  
  388. end
  389.  
  390. else
  391. FXUtility.DisplaySolid_Attention(Building, "Site reference is not provided.")
  392. end
  393. end
  394.  
  395. if #nonCompliantIC > 0 then
  396. for i=1, #nonCompliantIC do
  397. if hasYjunctionResult then
  398. FXUtility.DisplaySolid_Error(nonCompliantIC[i], nonCompliantSite[i].." "..drainLineStr:lower().." connection from last IC to "..publicSewerStr:lower().." via "..yJunctionStr.." is not provided.")
  399. for j=1, #nonCompliantNIC[i] do
  400. local obj = FXMeasure.GetElementbyGUID(nonCompliantNIC[i][j])
  401. CheckReport.AddRelatedObj(obj, obj:GetAttri("Name"))
  402. end
  403. else
  404. FXUtility.DisplaySolid_Error(nonCompliantIC[i], drainLineStr.." connection from last IC to "..publicSewerStr:lower().." is not provided in "..nonCompliantSite[i])
  405. for j=1, #nonCompliantNIC[i] do
  406. if j < 3 then
  407. local obj = FXMeasure.GetElementbyGUID(nonCompliantNIC[i][j])
  408. CheckReport.AddRelatedObj(obj, obj:GetAttri("Name"))
  409. end
  410. end
  411. end
  412. end
  413. end
  414. end
  415. end
  416. else
  417. FXUtility.DisplaySolid_Attention(Building, "Unable to complete rule checking due to system error.")
  418. end
  419. end
  420.  
  421. function getConnectedDrainLine (FedID, IC_ID, lastICObjs, strIfcTypeDrainLine, strPredefinedDrainLine, systemTypes)
  422. local drainLine
  423. local queryIC = "SELECT DISTINCT obj.elementid \n"..
  424. "FROM \n"..
  425. "bimrl_element obj \n"..
  426. "WHERE \n"..
  427. "obj.elementid = '"..IC_ID.."'";
  428.  
  429. local queryDrainLine = "SELECT DISTINCT obj.elementid \n"..
  430. "FROM \n"..
  431. "bimrl_element obj, \n"..
  432. "bimrl_element sys, \n"..
  433. "bimrl_type type, \n"..
  434. "bimrl_relgroup grp \n"..
  435. "WHERE \n"..
  436. "obj.typeid = type.elementid \n"..
  437. "AND type.ifctype = '"..strIfcTypeDrainLine.."' \n"..
  438. "AND type.predefinedtype SIMILAR TO lower('"..strPredefinedDrainLine.."|NOTDEFINED') \n"..
  439. "AND lower(sys.name) SIMILAR TO lower('%("..FXUtility.ConcatStringTable(systemTypes)..")%') \n"..
  440. "AND sys.elementid = grp.groupelementid \n"..
  441. "AND obj.elementid = grp.memberelementid";
  442.  
  443. local collidedObjTbl = FXUtility.CheckCollidedFromObjSet(FedID, queryIC, queryDrainLine, true);
  444.  
  445. if collidedObjTbl ~= nil and #collidedObjTbl ~= 0 then
  446. for i=1, #collidedObjTbl do
  447. if not FXUtility.HasPatterInTable(collidedObjTbl[i][2], lastICObjs) then
  448. drainLine = FXMeasure.GetElementbyGUID(collidedObjTbl[i][2]);
  449. end
  450. end
  451. end
  452.  
  453. return drainLine
  454. end
  455.  
  456. function checkSameICTbl ( tblIC_ID, neighborIC_ID )
  457. local newICTbl = {}
  458.  
  459. for j=1, #neighborIC_ID do
  460. local isEqual = false
  461. for i=1, #tblIC_ID do
  462. if FXUtility.HasPatterInString(neighborIC_ID[j]["elementid"], tblIC_ID[i]["elementid"] ) then
  463. isEqual = true
  464. end
  465. end
  466.  
  467. if not isEqual then
  468. table.insert(newICTbl, neighborIC_ID[j]["elementid"])
  469. end
  470. end
  471.  
  472. return newICTbl
  473. end
  474.  
  475. function checkSiteIDTbl( siteID, currentSiteID )
  476. local newSiteTbl = {}
  477. for i=1, #siteID do
  478. if not FXUtility.HasPatterInString(siteID[i]["elementid"], currentSiteID) then
  479. table.insert(newSiteTbl, siteID[i]["elementid"] )
  480. end
  481. end
  482.  
  483. return newSiteTbl
  484. end
  485.  
  486. function GetSiteIC(siteID, strIfcTypeIC, strPredefinedIC, currentSiteID)
  487. if type(siteID) == "table" and currentSiteID ~= nil then
  488. local newSiteTbl = checkSiteIDTbl( siteID, currentSiteID )
  489. if newSiteTbl ~= nil and #newSiteTbl > 0 then
  490. siteID = FXUtility.ConcatStringTable(newSiteTbl)
  491. else
  492. siteID = siteID[1].elementid;
  493. end
  494. end
  495.  
  496. local querySiteIC = "SELECT DISTINCT e2.elementid, e2.elementtype \n"..
  497. "FROM bimrl_element e,bimrl_spatialindex i, \n"..
  498. "bimrl_element e2 \n"..
  499. "WHERE e.elementid SIMILAR TO '"..siteID.."' \n"..
  500. "AND e.elementid = i.elementid \n"..
  501. "AND EXISTS \n"..
  502. "(SELECT FROM bimrl_element e1 \n"..
  503. "LEFT JOIN bimrl_spatialindex i1 on e1.elementid = i1.elementid \n"..
  504. "LEFT JOIN bimrl_type t on t.elementid = e1.typeid \n"..
  505. "WHERE \n"..
  506. "t.ifctype = '"..strIfcTypeIC:upper().."' AND \n"..
  507. "t.predefinedtype = '"..strPredefinedIC:upper().."' \n"..
  508. "AND (i.yminbound = i1.yminbound or i.ymaxbound = i1.ymaxbound) \n"..
  509. "AND (i.xminbound = i1.xminbound or i.xmaxbound = i1.xmaxbound) \n"..
  510. "AND e1.elementid = e2.elementid) ";
  511. print(querySiteIC)
  512. print("querySiteIC")
  513. local grpIC, tblIC_ID = ReturnQuery( querySiteIC )
  514. return grpIC, tblIC_ID
  515. end
  516.  
  517. function checkFittingAngle(junction, IC_Obj, connManhole)
  518. --[[
  519. 1 = Y junction
  520. 2 = Other junction
  521. ]]--
  522.  
  523. local val
  524. local pipeA
  525. local pipeB
  526. local faceA
  527. local faceB
  528. local pipeGrpConnManhole = FXGroup.new()
  529. local isConnectedToManhole = false
  530. local isConnectedToIC = false
  531. local connToICAndManhole = false
  532.  
  533. if junction ~= nil then
  534. if (FXPUBSeriesSSW.getPipeFittingType(junction) == 1) then
  535. val = 1
  536. if #pipeGrpConnManhole > 0 then
  537. pipeGrpConnManhole:ForEach(function ( pipe )
  538. if FXClashDetection.IsCollided(pipe, connManhole) then
  539. isConnectedToManhole = true
  540. end
  541.  
  542. if FXClashDetection.IsCollided(pipe, IC_Obj) then
  543. isConnectedToIC = true
  544. end
  545. end)
  546. end
  547.  
  548. if isConnectedToManhole and isConnectedToIC then
  549. connToICAndManhole = true
  550. end
  551. else
  552. val = 2
  553. end
  554. end
  555.  
  556. return val, connToICAndManhole
  557. end
  558.  
  559. function getFace(face, junction)
  560. local tempFace
  561. local faceFace
  562. local temp
  563. local finalFace
  564. local juncMidPos = FXGeom.GetBoundingBox(junction):MidPos()
  565. for i = 1, #face do
  566.  
  567. if face[i]:GetVoidFaceNumber() == 0 then
  568.  
  569. local diam = FXMeasure.GetOuterDiameterLines(face[i])
  570. local centerPoint = FXUtility.CenterPoint(diam:GetStartPoint(), diam:GetEndPoint())
  571. local length = Line3D(centerPoint, juncMidPos):Length()
  572.  
  573. if temp == nil then
  574. temp = length
  575. tempFace = face[i]
  576. else
  577. faceFace = face[i]
  578.  
  579. if temp < length then
  580. finalFace = tempFace
  581. else
  582. finalFace = faceFace
  583. end
  584. end
  585. end
  586. end
  587.  
  588. return finalFace
  589. end
  590.  
  591. function ReturnQuery( query )
  592. local grpA, grpB;
  593. local retVal = FXBIMRL.GetQueryByFederatedId(query);
  594. print(retVal)
  595. if retVal ~= nil and FXUtility.HasPatterInString(retVal,"Table1") then
  596. grpA, grpB = FXPUB.GrpElementbyGUID(retVal);
  597. end
  598.  
  599. return grpA, grpB;
  600. end
  601.  
  602. function GetPathToSpecificObj( TargetIFCtype, TargetPtype, NotMeetIFCtype, NotMeetPtype, BaseId, Count )
  603. local CountS = 0
  604. if Count ~= nil then
  605. CountS = Count;
  606. end
  607. local BetweenObjsGrp = FXGroup.new();
  608. local BetweenObjsGrp2 = {};
  609.  
  610. local table1 = {TargetIFCtype, TargetPtype}
  611. local table11 = {table1}
  612. local target = json:encode(table11)
  613.  
  614. local table2 = {NotMeetIFCtype, NotMeetPtype}
  615. local table22 = {table2}
  616. local notmeet = json:encode(table22)
  617.  
  618. local initResult = FXBIMRL.findPathToSpecificTypeObjectWithNegativeCondition(BaseId , target, notmeet, CountS)
  619. if initResult ~= nil then
  620. local tbl = FXRule.DecodeJSONToTable(initResult)
  621. for k6,v6 in pairs(tbl) do
  622. for k7 , v7 in pairs (v6) do
  623. if not FXUtility.HasPatterInString(v7,"No path found") then
  624. local Obj = FXMeasure.GetElementbyGUID(v7)
  625. BetweenObjsGrp:Add(Obj);
  626. table.insert(BetweenObjsGrp2,v7);
  627. end
  628. end
  629. end
  630. end
  631.  
  632. return BetweenObjsGrp, BetweenObjsGrp2;
  633. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement