| 55 | |
| 56 | # Class to download extract and convert IFC files |
| 57 | class TestFile: |
| 58 | def __init__(self,fn,store_as=None): |
| 59 | global test_cases |
| 60 | self.fn = fn |
| 61 | self.store_as = store_as |
| 62 | self.failed = [] |
| 63 | test_cases.append(self) |
| 64 | def __call__(self): |
| 65 | if self.fn.startswith("http://") or self.fn.startswith("ftp://"): |
| 66 | fn = self.store_as if self.store_as else self.fn.split("/")[-1] |
| 67 | if os.path.exists(os.path.join("input",fn)): |
| 68 | print ("[Notice] Already downloaded:",fn) |
| 69 | else: |
| 70 | print ("[Notice] Downloading:",fn) |
| 71 | urlretrieve(self.fn,os.path.join("input",fn)) |
| 72 | self.fn = fn |
| 73 | if extension(self.fn) == '.zip': |
| 74 | print ("[Notice] Extracting:",self.fn) |
| 75 | zf = ZipFile(os.path.join("input",self.fn)) |
| 76 | self.fn = [n for n in zf.namelist() if extension(n) == '.ifc' and not n.startswith('__') and not n.startswith('.')] |
| 77 | for fn in self.fn: |
| 78 | if not os.path.exists(os.path.join("input",fn)): zf.extract(fn,"input") |
| 79 | zf.close() |
| 80 | else: self.fn = [self.fn] |
| 81 | for fn in self.fn: |
| 82 | print ("[Notice] Rendering:",fn) |
| 83 | succes = subprocess.call(['blender','-b','-P','bpy.py','render',os.path.join("input",fn)]) == 0 |
| 84 | if not succes: self.failed.append(fn) |
| 85 | return len(self.failed) == 0 |
| 86 | def __str__(self): return "\n".join(self.failed) if len(self.failed) else "" |
| 87 | |
| 88 | # Karlsruher Institut fuer Technologie |
| 89 | TestFile("http://iai-typo3.iai.fzk.de/www-extern-kit/fileadmin/download/download-vrsys/ADT-FZK-Haus-2005-2006.zip") |