| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <?php
- include("connectSQL_Component.php");
- $componentGroups = [];
- $componentGroup = [];
- $componentNames = [];
- $categories = [];
- $oldFilepath = "../../assets/glb/Revit元件/Components/Arch/MEP/";
- $oldFilepaths = [];
- $old = [];
- $newFilepath = "../../assets/glb/Revit元件/Components/";
- $newFilepaths = [];
- $paths = array_diff(scandir($oldFilepath), array('.', '..', 'Thumbs.db'));
- foreach($paths as $path){
- array_push($oldFilepaths, $oldFilepath.$path);
- }
-
- for($i = 0; $i < count($oldFilepaths); $i++){
- $files = scandir($oldFilepaths[$i]);
- for($j = 0; $j < count($files); $j++){
- if(str_contains($files[$j], "glb")){
- array_push($old, $oldFilepaths[$i]."/".$files[$j]);
-
- }
- }
- }
-
-
- $sql = "SELECT [componentGroup], [componentName], [category] FROM [BIMComponents].[dbo].[Component_Info]";
- $fetchResult = sqlsrv_query($conn, $sql);
- while ($row = sqlsrv_fetch_array($fetchResult)) {
- array_push($componentGroups, $row["componentGroup"]);
- array_push($componentNames, $row["componentName"]);
- array_push($categories, $row["category"]);
- }
- for($i = 0; $i < count($componentGroups); $i++) {
- $componentGroup = explode(",", $componentGroups[$i]);
- for($j = 0; $j < count($componentGroup) - 1; $j++) {
- array_push($newFilepaths, $newFilepath.$componentGroup[$j]."/".$categories[$i]."/".$componentNames[$i].".glb");
- }
- }
- $start = "";
- $end = [];
- $a = array_unique($componentNames);
- for($i = 0; $i < count($a); $i++) {
- for($j = 0; $j < count($old); $j++){
- if(str_contains($old[$j], $a[$i])){
- $start = $old[$j];
- }
- }
- for($j = 0; $j < count($newFilepaths); $j++){
- if(str_contains($newFilepaths[$j], $a[$i])){
- array_push($end, $newFilepaths[$j]);
- }
- }
- for($j = 0; $j < count($end); $j++){
- copy($start, $end[$j]);
- }
- $end = [];
- }
- ?>
|