From d243a3457a17e1aa3fe6985ac63518b68901b834 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 24 Jan 2012 11:15:58 -0200 Subject: [PATCH] Improvements to Arch IFC importer + Auto download of IFC schema if none found + Use of openshell shapes in Arch objects if available --- src/Mod/Arch/ArchCommands.py | 18 ++ src/Mod/Arch/Arch_rc.py | 241 ++++++++------------ src/Mod/Arch/Resources/ui/archprefs-base.ui | 72 ++---- src/Mod/Arch/importIFC.py | 153 ++++++++----- 4 files changed, 227 insertions(+), 257 deletions(-) diff --git a/src/Mod/Arch/ArchCommands.py b/src/Mod/Arch/ArchCommands.py index 83f6059ad3..a8b09f5e81 100644 --- a/src/Mod/Arch/ArchCommands.py +++ b/src/Mod/Arch/ArchCommands.py @@ -259,6 +259,24 @@ def mergeCells(objectslist): FreeCAD.ActiveDocument.removeObject(o.Name) FreeCAD.ActiveDocument.recompute() return base + +def download(url): + '''downloads a file from the given URL and saves it in the + user directory. Returns the path to the saved file''' + try: + FreeCAD.Console.PrintMessage("downloading "+url+" ...\n") + import urllib2, os + response = urllib2.urlopen(url) + s = response.read() + fp = os.path.join(FreeCAD.ConfigGet("UserAppData"),url.split('/')[-1]) + if not os.path.exists(fp): + f = open(fp,'wb') + f.write(s) + f.close() + except: + return None + else: + return fp # command definitions ############################################### diff --git a/src/Mod/Arch/Arch_rc.py b/src/Mod/Arch/Arch_rc.py index 7c1c30950e..f56440b2c8 100644 --- a/src/Mod/Arch/Arch_rc.py +++ b/src/Mod/Arch/Arch_rc.py @@ -2,7 +2,7 @@ # Resource object code # -# Created: Tue Jan 17 17:15:03 2012 +# Created: Tue Jan 24 10:12:37 2012 # by: The Resource Compiler for PyQt (Qt v4.7.4) # # WARNING! All changes made in this file will be lost! @@ -5697,122 +5697,83 @@ qt_resource_data = "\ \x00\x00\x00\x12\x00\x57\x00\x65\x00\x72\x00\x6b\x00\x7a\x00\x65\ \x00\x75\x00\x67\x00\x65\x08\x00\x00\x00\x00\x06\x00\x00\x00\x05\ \x54\x6f\x6f\x6c\x73\x07\x00\x00\x00\x04\x61\x72\x63\x68\x01\ -\x00\x00\x07\x1c\ +\x00\x00\x04\xaa\ \x00\ -\x00\x27\x43\x78\x9c\xed\x5a\x6d\x73\xda\x38\x10\xfe\x9e\x5f\xa1\ -\xe3\x66\xda\xbb\x99\x80\x21\x81\x34\x21\xc6\x9d\x96\x24\x4d\x66\ -\xd2\x2b\x2d\xb4\x99\xfb\xd4\x31\xb6\xc0\x6a\x65\xcb\xb1\xe4\x1a\ -\x7a\x73\xff\xfd\x56\x92\x0d\x36\x06\xf2\x02\x49\xae\x9d\xce\x24\ -\x13\x4b\xbb\xda\x5d\xad\x76\x9f\x5d\x39\x36\x5f\x4e\x7c\x8a\xbe\ -\xe1\x88\x13\x16\x74\x2a\x8d\x5a\xbd\x82\x70\xe0\x30\x97\x04\xe3\ -\x4e\xe5\xe3\xe0\xac\x7a\x58\x79\x69\xed\x98\x31\x99\x33\x35\x81\ -\xc9\xda\x41\xa6\x43\x6d\xce\xad\x37\x31\x69\xb7\x4f\x88\x4d\xd9\ -\x18\xfe\xd2\x71\x1f\x0b\x01\x8b\xf9\xab\xc8\xf1\x4c\x43\xf3\x00\ -\x73\x42\xdc\x31\x16\x48\x8d\x3b\x95\xf7\x57\x6a\x58\x41\x81\xed\ -\xe3\x4e\x65\x9d\x0c\xa9\x0a\x99\x61\xc4\x42\x1c\x89\x69\xba\x60\ -\x8c\x99\x8f\x45\x34\x55\x44\x64\x46\xd8\x11\xea\x09\x99\x13\xab\ -\x6e\x1a\x93\x74\x30\x95\x83\x69\x3a\x00\x0b\x84\x67\xb5\x5e\xb4\ -\x4c\x43\x3f\xea\x69\x0f\x93\xb1\x27\xac\x83\xbd\x23\xd3\x48\x9f\ -\x95\x4c\x23\x13\x6a\x1a\x99\xf2\x65\x96\x24\x24\x70\x59\x32\x20\ -\x82\xe2\xd4\x18\x2e\x22\xb0\xdd\x7a\x83\x03\x1c\xd9\x14\xf1\x74\ -\x2f\xa6\x91\x12\xca\x22\xa9\x3d\x65\xf1\xdc\x37\x9f\x5e\xb3\xc9\ -\xa5\x9a\x4a\x25\x2e\xa8\xe4\xa1\xed\x80\xa0\x4a\xba\x81\x20\xf6\ -\x87\x38\xb2\x0e\x4c\x23\x7d\xd2\xe6\xe7\x35\x94\x44\xf8\x76\x34\ -\x26\xc1\x82\x84\xa3\xb5\x12\x88\xc0\xfe\xdc\x93\xf9\xb3\x7c\x13\ -\xb1\x38\x04\x9b\xb3\xd3\x1c\x67\x63\xcd\x5e\x52\x2e\xe6\xce\x5a\ -\xe2\x2f\x79\xe6\xa8\xbf\xc4\x69\x65\x9b\xd6\xba\x2e\x55\x06\x51\ -\x2b\x88\x63\x53\x3d\xfb\x79\x6f\xae\x77\xbe\xa1\x25\x82\xce\x4b\ -\x82\x3c\x16\x91\xef\x2c\x10\x4b\x44\x2d\x0a\x2b\xbb\xe8\xd2\x1e\ -\x62\x9a\x49\xa2\x72\x50\x58\xbe\xc4\x47\x78\x22\x0a\x0c\x33\x3f\ -\x9d\xe0\x91\x1d\x53\x10\xcd\x28\x8b\xd0\x08\x7e\x13\x9b\xd2\x45\ -\x4f\x2d\x77\x97\x9e\xd4\xb6\xe5\x8c\x37\x8a\xd6\x97\x36\x23\x03\ -\x0e\x47\x25\x3f\xf4\xd5\xf4\xda\x6d\x00\x2f\x06\x56\x01\xb8\xb1\ -\xb0\x1b\x0c\xa1\x66\xbd\x17\xed\xf6\xf9\x4c\x9e\x69\xa8\xc9\x9b\ -\x36\x50\xce\x07\xf2\x1d\x9f\x93\x00\x4e\x8a\x0b\x17\xd2\xad\x53\ -\xa9\x2f\xba\x0e\x38\x0a\x33\x19\x1a\x34\xeb\x05\x30\x98\x51\x53\ -\x20\xd8\xab\x17\x30\x61\x6e\xd6\xa2\xc0\x15\x9e\xd6\x8e\xbb\x83\ -\xa7\x8b\x61\xa3\x60\xb1\x17\xe1\x51\x57\x9e\xf5\xeb\x58\x08\x70\ -\x63\x96\x64\x92\x16\x02\x4d\xc5\xc1\x50\xd3\xd6\x46\x14\x63\x74\ -\x40\xc2\xe5\x41\x35\xf0\x08\x47\xf0\x23\x3c\x8c\xdc\x52\x80\x05\ -\x38\x41\x57\x10\x64\x88\x0d\xbf\x00\x28\xde\x3e\xd6\x4a\x46\x28\ -\x99\x0b\x26\xa8\xb9\x05\xff\x47\xd8\xb5\xf6\x5a\x2d\x09\xc2\xee\ -\x02\x69\x1c\x61\x1c\x58\x8d\x23\x38\x1a\xfd\x58\x24\x0f\x69\x8c\ -\xad\xc6\x0b\xa0\xaa\xa7\xe2\xb1\x95\x54\xdd\xce\x6a\xe9\xe6\xd3\ -\x40\x96\x9b\x95\x11\xe6\xa4\x1e\x91\x6e\x52\xa7\x05\xca\xee\xeb\ -\x24\xa9\xae\x67\x0b\xef\x66\x6d\x6f\x99\x6b\xa4\x75\x76\x5b\xd9\ -\x6f\x1a\x1a\x09\x67\x30\x59\x20\x6f\x0a\x9a\x1b\x41\xe6\xd6\x00\ -\x13\x08\xb1\x23\xe2\x08\x3f\x1d\x6a\xde\x00\xff\xbf\x70\xf3\x31\ -\x71\xf3\xa6\x5a\xbc\x19\x72\xf6\xb3\x68\x7b\x5c\xf8\x6c\xb4\xea\ -\x6b\xe0\xf3\xe0\x68\x1d\x7c\x1e\x1e\x3c\x11\x7c\xce\x7c\xf5\x0b\ -\x43\x57\x37\x9e\x07\x9b\x35\x9e\xad\xed\x35\x9e\xea\xee\xf3\x84\ -\x20\xda\xfc\x05\xa2\xab\x7d\xfd\xd8\x20\xba\xbf\xf6\x30\xee\x02\ -\x5d\xad\xa3\x35\xc8\xb5\xbf\xb7\x0e\xb9\x9a\x4f\x85\x5c\x57\x2a\ -\x17\x7e\x5e\xd8\x2a\x12\x0b\xb2\x72\x7c\xf7\x78\x4b\x30\x2f\xbe\ -\xb7\x7b\x4f\x70\x71\xd6\x45\xc4\x0f\x59\x24\xb6\xfd\x72\x60\x7b\ -\xaf\x06\xf6\x37\x43\xe8\xf5\x99\xb4\x1a\xa1\x9f\x51\x71\xfc\xdb\ -\xc9\xbb\xee\xe0\xef\xde\x29\x3a\x1f\xbc\xbd\x44\xbd\x8f\xaf\x2f\ -\x2f\xba\xe8\xd9\x75\xcc\xc4\x71\xd5\x30\xae\xf6\xbb\x86\x71\x32\ -\x38\xd1\xd4\x66\xad\x6e\x18\xa7\x7f\x69\x6a\xca\xe4\x09\x11\xb6\ -\x0d\x23\x49\x92\x5a\xb2\x5f\x63\xd1\xd8\x18\x7c\x30\x3e\x9c\x76\ -\xab\x9e\xf0\x69\xb3\xae\x5c\xee\x88\x9a\x2b\x5c\xcd\xff\x6c\x2c\ -\x8e\x77\xa4\x62\x49\x97\x03\xf5\x8c\x6d\x37\x7b\xf6\xb1\xb0\xb5\ -\xe5\x7a\xc1\x35\xac\xf7\xe4\x1e\x52\xb5\x0e\x38\x0e\x60\x3a\xa5\ -\x36\xd2\x59\x23\x5b\xce\xc5\x94\x62\x24\xa6\x61\xb6\x5e\x2e\x85\ -\x98\xe7\x39\xf5\xe1\x2e\xa2\x04\xfd\x83\x12\x0f\x7c\x5d\x55\xb8\ -\xd7\x46\x90\x4a\xd5\x24\xb2\xc3\x63\xf4\xaf\xb2\xcf\x50\x92\x32\ -\xb1\x46\xde\xc4\x21\x73\xa7\x48\x91\x53\x1d\x50\xdd\x02\x51\x1d\ -\xd9\x3e\xa1\xd3\xf6\xf3\x13\xfc\xc5\xfe\x14\xa3\xbe\x1d\xf0\xe7\ -\x29\x49\x42\x70\xfb\x30\xcc\x38\x13\x05\xd3\xed\x66\xbd\x9e\xd1\ -\xa5\xb0\x76\xc0\x22\xdf\xa6\xc7\x0b\x8e\x0a\x8b\xaa\xf4\xab\xb8\ -\xaa\x60\x61\xbb\x1e\x4e\x66\xe3\x21\x03\x50\xf5\x0b\x53\x14\x8f\ -\x44\x61\x22\x52\x5a\xd5\x4c\xf5\x5a\x54\x87\x94\x39\x5f\xab\x80\ -\x43\xe0\xce\x36\x58\x22\x3d\x35\x1b\x02\xd3\xdc\x8e\x33\x28\xde\ -\xb2\x61\x95\xb9\x14\x81\x23\xa0\xc2\x0a\x86\x46\x71\xe0\xc8\x62\ -\xb9\x8b\x20\x88\xa1\x75\xc5\x2e\xb2\x03\xc5\xd3\x77\x3c\xec\xdb\ -\xe8\x74\x02\x4e\xe5\x1c\x8d\x08\x1c\xc9\x1f\x35\x3c\x09\xff\x44\ -\xf6\x37\x9b\x40\xd4\xc2\x84\x87\x23\xdc\x56\xbe\x0d\xff\x4f\x7b\ -\x95\x66\xd8\xc8\x03\x60\xed\x94\x22\x9c\x0b\x1c\xca\xee\x9e\xd7\ -\x1c\xe6\x1b\x3c\x0e\x25\xac\x40\xa0\xb8\xf8\xdb\x67\x97\x39\xdc\ -\xc0\x7a\xc7\x06\x19\x39\x7b\x93\xfd\xf4\xcf\x67\xe1\x34\xe4\xe6\ -\x8b\x3a\x20\xec\x82\xe2\x6e\x95\x4d\x2e\x76\x58\xa4\x7a\x90\x36\ -\x8a\xc1\xbe\x88\x92\x00\x1f\xeb\x26\xaa\xfd\x7b\xab\x7e\x88\xdd\ -\xc3\x9c\xb5\xdb\x33\x4e\x85\x3c\xd8\x34\x8b\x78\x7b\xf6\x14\xce\ -\x9e\x64\xe4\xcf\x53\x22\xcd\xe0\xed\xf5\x73\x0f\xdc\x08\x37\x6f\ -\x0f\xb3\xf3\x6e\xc6\xc3\xce\xd7\x7c\x19\x9a\xb5\x32\x92\x30\xcc\ -\xd7\xa3\xe5\xe8\xbb\xee\x32\x48\x46\x90\x56\xfa\x3e\xa8\xc4\x61\ -\x77\x57\xe5\x19\xf4\x87\x38\x0a\xb2\x97\xdb\x32\xa3\x42\x3b\xe2\ -\x58\x76\xd0\x94\xa2\x21\x46\x31\xc7\x32\x03\x87\x31\xa1\xae\x66\ -\x4a\xef\x8a\x68\x14\x31\x1f\x7d\x0d\x58\xa2\x33\x51\x02\x21\xaf\ -\xdd\xff\x06\xb9\xba\x78\x48\x13\x66\x76\xce\x4d\xdc\xe0\xb2\xaa\ -\x3d\xb0\xa0\x6d\x08\xfe\xb3\xe0\x96\x87\xa1\x4f\x93\x8f\x0f\xd9\ -\x93\xc1\x96\x2e\x46\x4e\x2f\xdd\xc7\x8f\xd9\x94\xdd\xf5\x4a\xb4\ -\xbe\x77\xf8\x75\x25\xda\xe4\x4a\xb4\xac\x57\x5b\x7f\x05\x5d\x9d\ -\x6e\xb9\xb2\xaa\xca\x29\xd4\x33\x75\x2c\x0f\x79\x99\x5e\x01\x89\ -\x67\xa0\xbf\xeb\x31\x06\x59\x52\x42\x45\x69\x9b\x93\xd2\xee\x0d\ -\x8b\xdb\x6b\x37\x6a\x48\xca\xa2\xc4\xc1\x01\x07\xc9\x52\x1a\x67\ -\x01\x47\x09\x46\x76\x84\x51\xc0\x04\xb2\x29\x65\x09\xc8\x02\x0d\ -\xdc\x23\x21\x28\xb6\x85\x16\x91\x10\xe1\xa1\x33\xb8\x3a\x76\x5f\ -\x9d\xec\x22\xce\x94\x5e\x3f\xe6\x02\xc1\xcd\x2d\xa0\xcc\x76\x11\ -\x11\x72\x12\xf0\x82\x8e\x6a\xa8\x47\x21\x5a\x72\xeb\x09\xd4\x77\ -\xe6\xcf\x8f\x0a\xc1\x8f\xe4\x86\x62\xee\x87\x31\x20\xe7\x2e\x6c\ -\xc0\x45\xb0\x18\x90\x5b\x6d\x58\x2d\x93\x7d\xd1\x06\x88\x7d\x07\ -\xbc\x03\xb0\xd3\xae\xfb\x51\xc1\xee\x81\xfb\x85\xd6\x43\xf4\x0b\ -\xf7\x4f\x8b\x8b\x15\xdd\x02\xa4\xc0\xbb\x10\x07\x7d\x0f\x43\x73\ -\xa0\xaf\xba\xc5\x56\xc1\x55\x6f\xdf\xb2\x0e\x41\x06\xbd\x07\x81\ -\x47\x61\x7e\x38\x2d\xf6\x1b\x9b\xd6\xf0\xd5\xf8\xf5\x91\x17\x0d\ -\x7d\x94\x00\xd7\x05\x3d\xa7\xf3\x27\x0c\xf3\x5b\xbd\x68\xc9\x31\ -\xe5\x38\xd2\x94\xc8\xfe\x0d\x91\x7e\x27\xd2\xa9\x1c\x54\xd2\x5b\ -\x54\xa7\xd2\x68\x54\x0c\xc9\x19\x92\x89\x6f\x87\x19\x04\x5b\xd7\ -\x3d\x35\x3e\x83\x66\xf3\x2d\xf1\x71\x1f\x50\xcd\x81\x0e\x6d\x81\ -\x4b\x7e\xf3\x03\x70\xc9\x7c\xad\x91\x2b\x4b\xf2\x33\xda\xca\xdc\ -\x77\x41\xb9\xd2\x32\xff\x16\x48\x76\x1b\x13\xb8\xf3\xbb\xdc\x4a\ -\xbf\x03\x82\x4e\x23\x9d\x50\x54\x4f\xd5\x08\x29\xc1\x90\x02\xf4\ -\x87\x41\x35\xcf\x34\x52\x82\x72\xc0\xa2\xde\xf5\x86\xe4\x5e\x62\ -\x2e\x37\xa4\x17\x73\x2f\xa3\xaf\x32\x46\x1b\xcb\x37\xb3\x64\xa1\ -\xe2\x2e\xb5\xa6\xec\xbb\x55\x26\x49\x69\x5b\x33\xeb\x26\x27\x95\ -\x3d\xf9\x38\x66\xa5\x10\xbc\xfc\xe0\xe6\xd4\xcd\x8d\x29\x4e\xa8\ -\xef\xd6\xa0\x03\x51\xc9\xc0\x55\xda\x38\x2c\x08\xb0\x4a\x06\x39\ -\x36\x8d\x98\x58\x3b\xff\x01\xea\x67\xa5\xfc\ +\x00\x1c\xf4\x78\x9c\xed\x59\x6d\x6f\xa3\x38\x10\xfe\xde\x5f\x61\ +\xf1\xf9\xae\x24\xd9\x24\xbb\xad\x08\xab\x7d\xb9\xbe\x48\xbb\xba\ +\x54\xe9\x6e\x3f\xae\x08\x4c\x82\x6f\xc1\xe6\x8c\xb9\x24\xfb\xeb\ +\xcf\x36\x26\x60\x20\xb4\x69\xb2\xad\x54\x55\x6a\x54\xdb\x63\x66\ +\xc6\x8f\x67\x1e\x0f\xd8\x79\xbf\x8e\x23\xf4\x1f\xb0\x14\x53\x32\ +\xb1\xfa\xa7\x3d\x0b\x01\xf1\x69\x80\xc9\x72\x62\x7d\xbb\xbd\xf8\ +\xf3\x9d\xf5\xde\x3d\x71\x32\x5c\x4e\x1a\x8a\x49\xee\x09\x72\xfc\ +\xc8\x4b\x53\xf7\x32\xc3\xe7\xe7\x9f\xb1\x17\xd1\xa5\xf8\x1f\x2d\ +\x67\xc0\xb9\x78\x38\xfd\xc0\xfc\xd0\xb1\xf3\x39\x62\xf2\x0a\x07\ +\x4b\xe0\x48\xf5\x27\xd6\xcd\x9d\xea\x5a\x88\x78\x31\x4c\xac\x2e\ +\x1d\xd2\x14\x72\x12\x46\x13\x60\x7c\xa3\x1f\x58\x02\x8d\x81\xb3\ +\x8d\x12\x22\x87\x81\xcf\x55\x0b\x39\x6b\xb7\xe7\xd8\x6b\xdd\xd9\ +\xc8\xce\x46\x77\x84\x07\x3c\x74\x47\x6f\x47\x8e\x9d\x37\xf3\xe1\ +\x10\xf0\x32\xe4\xee\x78\x70\xe6\xd8\xba\xad\x74\xda\x85\x52\xc7\ +\x2e\x8c\xb7\x79\xb2\xc2\x24\xa0\xab\x5b\xcc\x23\xd0\xce\xa4\x9c\ +\x09\xdf\xdd\x4b\x20\xc0\xbc\x08\xa5\x7a\x2d\x8e\xad\x05\x4d\x95\ +\x91\xb7\xa1\x59\x89\xcd\xf7\x8f\x74\xfd\x45\x0d\x69\x8d\x35\x93\ +\x69\xe2\xf9\x42\x91\xa5\x17\x40\xb2\x78\x0e\xcc\x1d\x3b\xb6\x6e\ +\xe5\xee\x57\x2d\x34\x54\xc4\x1e\x5b\x62\x52\xd3\x70\xd6\xa9\x01\ +\x73\x88\x4b\x24\xab\x7b\x79\xc9\x68\x96\x08\x9f\x8b\xdd\x5c\x16\ +\xfd\x7c\x7a\xc3\x38\x2f\xc1\x6a\xc1\x4b\xee\x39\x9a\xb5\x80\xd6\ +\xf4\xa9\x13\x3a\x6d\x4c\x44\x2d\xc7\xbe\x17\xe5\xa3\x3f\x06\xa5\ +\xdd\x72\x41\x2d\x8a\xae\x1a\x8a\x42\xca\xf0\x2f\x4a\x78\x8b\xaa\ +\xba\xb2\x26\x44\x5f\xbc\x39\x44\x85\xa6\x48\x76\x8c\xc7\x5b\x30\ +\x82\x35\x37\x26\x6c\x71\xfa\x0c\x0b\x2f\x8b\x84\x6a\x1a\x51\x86\ +\x16\xe2\xb7\xf2\xa2\xa8\x8e\x54\x3b\x5c\xf9\x60\xee\x5b\xc5\x79\ +\xdb\xf4\xbe\xb1\x18\x19\x70\xc0\x1a\x38\xcc\xd4\x70\xe7\x32\xc4\ +\x5c\x10\x53\xb9\xe0\x8d\xda\x6a\x40\x84\x9a\x7b\xc3\xcf\xcf\xaf\ +\xb6\xfa\x1c\x5b\x0d\xde\xb7\x80\x66\x3e\xe0\x5f\x70\x85\x89\xd8\ +\xa9\x94\x07\x22\xdd\x26\x56\xaf\x0e\x9d\x98\x61\x8c\x14\x6c\x30\ +\xec\x19\x64\xb0\x95\x6a\x22\x18\xf4\x0c\x4e\x28\xdd\xaa\x2b\xdc\ +\x81\x74\x0e\xdc\x1e\x48\x9b\x61\xa3\x68\x71\xca\x60\xf1\x49\xee\ +\xf5\xc7\x8c\x73\x01\x63\x91\x64\x52\x96\x08\x99\x8a\x83\x79\x2e\ +\xeb\x8c\x28\x4a\xa3\x5b\x9c\xb4\x07\xd5\x6d\x88\x53\x24\xfe\x78\ +\x08\x28\x68\x04\x18\x81\x15\xba\x13\x41\x86\xe8\xfc\x1f\x41\x8a\ +\x0f\x8f\xb5\x86\x13\x4a\x67\xcd\x05\x35\x56\xc3\x9f\x41\xe0\x0e\ +\x46\x23\x49\xc2\x41\x4d\xb4\x64\x00\xc4\xed\x9f\x89\xad\xc9\x9b\ +\xa6\x78\x1e\x65\xe0\xf6\xdf\x0a\xa9\x6a\x99\xdb\xd6\x30\xf5\x30\ +\xaf\x25\xcc\x7f\x11\x79\xdc\xec\x8c\x30\x5f\x23\x22\x61\x52\xbb\ +\x25\x8c\x3d\x16\x24\x69\x6e\xea\xf1\xf0\x7e\x6b\x5f\x69\x60\xeb\ +\x73\xf6\x58\xd9\xef\xd8\x39\x13\x6e\x69\xd2\x10\x1f\x4a\x9a\x07\ +\x51\xe6\xd1\x08\x53\x08\x32\x9f\x67\x0c\x9e\x8f\x35\xef\xa1\xff\ +\x57\xde\x7c\x4a\xde\xbc\xef\x2c\x3e\x8c\x39\x67\x45\xb4\x3d\x2d\ +\x7d\xf6\x47\xbd\x0e\xfa\x1c\x9f\x75\xd1\xe7\xbb\xf1\x33\xd1\xe7\ +\x16\xab\x57\x0e\xdd\x5d\x78\x8e\x0f\x2b\x3c\x47\xc7\x2b\x3c\xd5\ +\xbb\xcf\x33\x92\xe8\xf0\x95\x44\x77\x63\xfd\xd4\x24\xfa\xa6\x73\ +\x33\xf6\xa1\xae\xd1\x59\x07\x73\xbd\x19\x74\x31\xd7\xf0\xb9\x98\ +\xeb\x4e\xe5\xc2\xcb\xa5\x2d\x53\x68\xe8\xaa\xcc\x7b\xc4\x57\x82\ +\xf2\xf0\x7d\xd8\x77\x82\xeb\x8b\x4f\x08\xc7\x09\x65\xfc\xd8\x1f\ +\x07\x8e\xf7\x69\x60\xf8\x70\x86\x2e\xd3\x2c\x04\xff\x67\x15\x9f\ +\x6d\x8e\x49\xc1\xbc\x0a\x54\x3b\x5a\x5d\x55\x0a\x5e\x88\x02\x25\ +\x2f\x54\x94\x3a\x08\xfe\x50\x15\x8b\x20\x2e\x60\xa4\xf8\xea\x22\ +\xa1\x4d\x3c\x96\x82\xa4\x76\xf1\xba\x37\x07\x94\xa5\x80\x38\x45\ +\xf3\x0c\x47\x41\x3e\x49\x17\x31\x68\xc1\x68\x8c\x7e\x12\xba\x22\ +\xea\x39\xbe\x49\x20\x3d\x7d\x7c\x69\xb3\xfb\xdc\x91\x2e\x6c\xfd\ +\x2c\x5d\x3c\xa0\x8a\xca\x11\xa8\x59\x9b\x0b\xfc\x5c\x51\x7e\x80\ +\x20\x10\xd9\xfc\x9d\x64\x21\x96\x74\xbd\xf0\xa7\x7a\x1d\x2f\x90\ +\x2d\x0e\x4f\xa1\xd1\xef\x48\xa1\xc7\x27\xd0\xf5\x8e\x04\x12\xf1\ +\xf8\x77\x02\x64\x16\x82\xc8\x97\x9c\x96\xcc\xec\x09\x54\xa5\x54\ +\x24\x0d\xa1\x1c\x85\x1e\x09\x22\x31\x3e\xdf\x98\x29\x78\x68\x58\ +\xef\xce\xa0\x6f\xa9\xe9\xe8\xe3\x6d\xec\x1d\xe3\x15\x9b\x2f\x30\ +\xcc\xf7\x3f\x14\x8d\x7a\xb6\x38\x7e\xcc\x0f\xa9\x0f\x29\x63\xcb\ +\x0a\xf6\xbb\xd6\x61\xd4\xaf\xcd\xa3\x70\x8f\xaa\xd5\x2c\x58\x75\ +\xad\x3a\x68\xd4\xaa\x45\x99\x3a\x6c\x94\xa9\x46\x85\x5a\x77\xc5\ +\xa8\x4b\x4b\x90\x2a\x48\x56\x60\xd4\xbc\x51\xbc\x57\xeb\x8b\x8f\ +\x89\x35\xb6\x50\x7e\x83\x31\xb1\xfa\x7d\xcb\x96\x33\x13\xbc\x8e\ +\xbd\x64\x91\x11\x5f\x02\xe5\xfe\x3b\x55\xfd\x0b\x71\x48\x7d\xc5\ +\x31\xcc\x68\xc6\x7c\xc1\xec\xb5\x59\xf2\x12\x2b\x4b\x39\x8d\x73\ +\x8b\xa9\xf2\xa4\x3a\x92\x7b\x59\xb9\xe8\xaa\x14\xc3\xe5\xe5\x96\ +\xdc\x8f\x35\x07\x12\xa4\xee\xcd\x34\x4b\xc3\x42\x5e\x0c\x9e\xe4\ +\x70\x79\x81\x58\xb6\xd0\x62\xe7\x97\x5f\xe9\x69\x28\x91\x53\xa3\ +\x0a\x81\xba\xe1\x6e\x4f\x6a\xa5\x79\xab\x37\x4d\x97\x77\xb9\x24\ +\xb5\x1d\xcf\x2d\xcd\xc3\xed\x08\x95\xd2\xc3\x9d\x31\x07\xd4\x45\ +\x23\x83\x54\x6d\x76\xaa\xc2\xc2\xa7\x84\x80\xda\x6c\xd9\x77\xec\ +\x0c\xbb\x27\xff\x03\x16\x13\x63\x21\ \x00\x00\x07\x4c\ \x00\ \x00\x29\xd1\x78\x9c\xed\x59\x5b\x8f\xe2\x46\x16\x7e\xef\x5f\xe1\ @@ -10089,30 +10050,30 @@ qt_resource_struct = "\ \x00\x00\x00\x86\x00\x00\x00\x00\x00\x01\x00\x00\x3e\x30\ \x00\x00\x01\x70\x00\x00\x00\x00\x00\x01\x00\x01\x08\x08\ \x00\x00\x00\x38\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\ -\x00\x00\x05\x12\x00\x01\x00\x00\x00\x01\x00\x02\x30\x38\ -\x00\x00\x04\x1e\x00\x00\x00\x00\x00\x01\x00\x01\xf2\x69\ -\x00\x00\x02\xfc\x00\x00\x00\x00\x00\x01\x00\x01\xa3\xf7\ -\x00\x00\x05\xb2\x00\x01\x00\x00\x00\x01\x00\x02\x5b\xca\ -\x00\x00\x04\xe4\x00\x01\x00\x00\x00\x01\x00\x02\x29\x66\ -\x00\x00\x03\x36\x00\x01\x00\x00\x00\x01\x00\x01\xb2\x66\ -\x00\x00\x03\x88\x00\x01\x00\x00\x00\x01\x00\x01\xc5\xed\ -\x00\x00\x02\xa0\x00\x01\x00\x00\x00\x01\x00\x01\x89\x57\ -\x00\x00\x04\x5e\x00\x00\x00\x00\x00\x01\x00\x02\x0c\x43\ -\x00\x00\x02\x7e\x00\x01\x00\x00\x00\x01\x00\x01\x80\x5e\ -\x00\x00\x03\x64\x00\x01\x00\x00\x00\x01\x00\x01\xbb\xbe\ -\x00\x00\x02\x34\x00\x01\x00\x00\x00\x01\x00\x01\x6f\xb6\ -\x00\x00\x02\x5e\x00\x01\x00\x00\x00\x01\x00\x01\x79\x5e\ -\x00\x00\x04\x8e\x00\x01\x00\x00\x00\x01\x00\x02\x1b\xb1\ -\x00\x00\x03\xf4\x00\x00\x00\x00\x00\x01\x00\x01\xe1\xe8\ -\x00\x00\x04\xbc\x00\x01\x00\x00\x00\x01\x00\x02\x21\x01\ -\x00\x00\x05\x3c\x00\x00\x00\x00\x00\x01\x00\x02\x37\x13\ -\x00\x00\x03\xac\x00\x01\x00\x00\x00\x01\x00\x01\xcb\x04\ -\x00\x00\x05\x86\x00\x01\x00\x00\x00\x01\x00\x02\x53\x50\ -\x00\x00\x05\x66\x00\x01\x00\x00\x00\x01\x00\x02\x49\x16\ -\x00\x00\x04\x3e\x00\x01\x00\x00\x00\x01\x00\x02\x06\x2b\ -\x00\x00\x02\xd2\x00\x00\x00\x00\x00\x01\x00\x01\x91\x99\ -\x00\x00\x03\xd6\x00\x00\x00\x00\x00\x01\x00\x01\xd2\xec\ -\x00\x00\x02\x00\x00\x01\x00\x00\x00\x01\x00\x01\x68\x66\ +\x00\x00\x05\x12\x00\x01\x00\x00\x00\x01\x00\x02\x2d\xc6\ +\x00\x00\x04\x1e\x00\x00\x00\x00\x00\x01\x00\x01\xef\xf7\ +\x00\x00\x02\xfc\x00\x00\x00\x00\x00\x01\x00\x01\xa1\x85\ +\x00\x00\x05\xb2\x00\x01\x00\x00\x00\x01\x00\x02\x59\x58\ +\x00\x00\x04\xe4\x00\x01\x00\x00\x00\x01\x00\x02\x26\xf4\ +\x00\x00\x03\x36\x00\x01\x00\x00\x00\x01\x00\x01\xaf\xf4\ +\x00\x00\x03\x88\x00\x01\x00\x00\x00\x01\x00\x01\xc3\x7b\ +\x00\x00\x02\xa0\x00\x01\x00\x00\x00\x01\x00\x01\x86\xe5\ +\x00\x00\x04\x5e\x00\x00\x00\x00\x00\x01\x00\x02\x09\xd1\ +\x00\x00\x02\x7e\x00\x01\x00\x00\x00\x01\x00\x01\x7d\xec\ +\x00\x00\x03\x64\x00\x01\x00\x00\x00\x01\x00\x01\xb9\x4c\ +\x00\x00\x02\x34\x00\x01\x00\x00\x00\x01\x00\x01\x6d\x44\ +\x00\x00\x02\x5e\x00\x01\x00\x00\x00\x01\x00\x01\x76\xec\ +\x00\x00\x04\x8e\x00\x01\x00\x00\x00\x01\x00\x02\x19\x3f\ +\x00\x00\x03\xf4\x00\x00\x00\x00\x00\x01\x00\x01\xdf\x76\ +\x00\x00\x04\xbc\x00\x01\x00\x00\x00\x01\x00\x02\x1e\x8f\ +\x00\x00\x05\x3c\x00\x00\x00\x00\x00\x01\x00\x02\x34\xa1\ +\x00\x00\x03\xac\x00\x01\x00\x00\x00\x01\x00\x01\xc8\x92\ +\x00\x00\x05\x86\x00\x01\x00\x00\x00\x01\x00\x02\x50\xde\ +\x00\x00\x05\x66\x00\x01\x00\x00\x00\x01\x00\x02\x46\xa4\ +\x00\x00\x04\x3e\x00\x01\x00\x00\x00\x01\x00\x02\x03\xb9\ +\x00\x00\x02\xd2\x00\x00\x00\x00\x00\x01\x00\x01\x8f\x27\ +\x00\x00\x03\xd6\x00\x00\x00\x00\x00\x01\x00\x01\xd0\x7a\ +\x00\x00\x02\x00\x00\x01\x00\x00\x00\x01\x00\x01\x65\xf4\ \x00\x00\x01\xd8\x00\x01\x00\x00\x00\x01\x00\x01\x61\x46\ " diff --git a/src/Mod/Arch/Resources/ui/archprefs-base.ui b/src/Mod/Arch/Resources/ui/archprefs-base.ui index 2963885847..88b1ba306f 100644 --- a/src/Mod/Arch/Resources/ui/archprefs-base.ui +++ b/src/Mod/Arch/Resources/ui/archprefs-base.ui @@ -164,22 +164,6 @@ IFC import - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Sans'; font-size:8pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">For the IFC reader to function, you need an IFC Schema Express file (.exp) available here:</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><a href="http://www.steptools.com/support/stdev_docs/express/ifc2x3/ifc2x3_tc1.exp"><span style=" text-decoration: underline; color:#508ed8;">http://www.steptools.com/support/stdev_docs/express/ifc2x3/ifc2x3_tc1.exp</span></a></p></body></html> - - - - - @@ -201,39 +185,6 @@ p, li { white-space: pre-wrap; } - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - IFC Schema file location - - - - - - - For the IFC reader to function, you need an IFC Schema Express file (.exp). For licensing reasons we are not allowed to ship that file with FreeCAD, so you must download it yourself. Place that file in some location on your computer, and select the file here. - - - IfcSchema - - - Mod/Arch - - - @@ -259,26 +210,29 @@ p, li { white-space: pre-wrap; } + + + + Qt::Vertical + + + + 20 + 40 + + + + qPixmapFromMimeSource - - Gui::FileChooser - QWidget -
Gui/FileDialog.h
-
Gui::ColorButton QPushButton
Gui/Widgets.h
- - Gui::PrefFileChooser - Gui::FileChooser -
Gui/PrefWidgets.h
-
Gui::PrefColorButton Gui::ColorButton diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index 9cfdf57c37..3de2aff0ff 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -21,7 +21,7 @@ #* * #*************************************************************************** -import ifcReader, FreeCAD, Arch, Draft, os, sys, time, tempfile +import ifcReader, FreeCAD, Arch, Draft, os, sys, time, tempfile, Part from draftlibs import fcvec __title__="FreeCAD IFC importer" @@ -29,6 +29,8 @@ __author__ = "Yorik van Havre" __url__ = "http://free-cad.sourceforge.net" DEBUG = True +SCHEMA = "http://www.steptools.com/support/stdev_docs/express/ifc2x3/ifc2x3_tc1.exp" +SKIP = ["IfcOpeningElement"] pyopen = open # because we'll redefine open below def open(filename): @@ -38,9 +40,10 @@ def open(filename): doc.Label = decode(docname) FreeCAD.ActiveDocument = doc p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") - p = p.GetBool("useIfcOpenShell") - if p: - readOpenShell(filename) + op = p.GetBool("useIfcOpenShell") + ip = p.GetBool("useIfcParser") + if op: + readOpenShell(filename,useParser=ip) else: read(filename) return doc @@ -59,15 +62,14 @@ def decode(name): def getSchema(): "retrieves the express schema" - default = "IFC2X3_TC1.exp" - p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") - p = p.GetString("IfcSchema") - if p: - if os.path.exists(p): - return p - p = os.path.join(FreeCAD.ConfigGet("UserAppData"),default) + p = None + p = os.path.join(FreeCAD.ConfigGet("UserAppData"),SCHEMA.split('/')[-1]) if os.path.exists(p): return p + import ArchCommands + p = ArchCommands.download(SCHEMA) + if p: + return p return None def getIfcOpenShell(): @@ -81,8 +83,12 @@ def getIfcOpenShell(): else: return True -def readOpenShell(filename): +def readOpenShell(filename,useParser=False): "Parses an IFC file with IfcOpenShell" + + altifc = None + if useParser: + altifc = parseFile(filename) if getIfcOpenShell(): USESHAPES = False @@ -97,72 +103,97 @@ def readOpenShell(filename): meshdata = [] n = obj.name if not n: n = "Unnamed" - - if USESHAPES: + if obj.type in SKIP: + pass + + elif altifc and (obj.type == "IfcWallStandardCase"): + makeWall(altifc.Entities[obj.id],shape=getShape(obj)) + + elif USESHAPES: # treat as Parts - import Part - tf = tempfile.mkstemp(suffix=".brp")[1] - of = pyopen(tf,"wb") - of.write(obj.mesh.brep_data) - of.close() - sh = Part.read(tf) + sh = getShape(obj) nobj = FreeCAD.ActiveDocument.addObject("Part::Feature",n) nobj.Shape = sh - os.remove(tf) - else: - # treat as meshes - import Mesh - f = obj.mesh.faces - v = obj.mesh.verts - for i in range(0, len(f), 3): - face = [] - for j in range(3): - vi = f[i+j]*3 - face.append([v[vi],v[vi+1],v[vi+2]]) - meshdata.append(face) - newmesh = Mesh.Mesh(meshdata) + me,pl = getMesh(obj) nobj = FreeCAD.ActiveDocument.addObject("Mesh::Feature",n) - nobj.Mesh = newmesh - - # apply transformation matrix - m = obj.matrix - mat = FreeCAD.Matrix(m[0], m[3], m[6], m[9], - m[1], m[4], m[7], m[10], - m[2], m[5], m[8], m[11], - 0, 0, 0, 1) - nobj.Placement = FreeCAD.Placement(mat) + nobj.Mesh = me + nobj.Placement = pl + if not IfcImport.Next(): break IfcImport.CleanUp() return None + +def getMesh(obj): + "gets mesh and placement from an IfcOpenShell object" + import Mesh + f = obj.mesh.faces + v = obj.mesh.verts + for i in range(0, len(f), 3): + face = [] + for j in range(3): + vi = f[i+j]*3 + face.append([v[vi],v[vi+1],v[vi+2]]) + meshdata.append(face) + me = Mesh.Mesh(meshdata) + # get transformation matrix + m = obj.matrix + mat = FreeCAD.Matrix(m[0], m[3], m[6], m[9], + m[1], m[4], m[7], m[10], + m[2], m[5], m[8], m[11], + 0, 0, 0, 1) + pl = FreeCAD.Placement(mat) + return me,pl + +def getShape(obj): + "gets a shape from an IfcOpenShell object" + tf = tempfile.mkstemp(suffix=".brp")[1] + of = pyopen(tf,"wb") + of.write(obj.mesh.brep_data) + of.close() + sh = Part.read(tf) + os.remove(tf) + m = obj.matrix + mat = FreeCAD.Matrix(m[0], m[3], m[6], m[9], + m[1], m[4], m[7], m[10], + m[2], m[5], m[8], m[11], + 0, 0, 0, 1) + sh.Placement = FreeCAD.Placement(mat) + return sh def read(filename): "processes an ifc file and add its objects to the given document" t1 = time.time() + ifc = parseFile(filename) + t2 = time.time() + if DEBUG: print "Successfully loaded",ifc,"in %s s" % ((t2-t1)) + # getting walls + for w in ifc.getEnt("IFCWALLSTANDARDCASE"): + makeWall(w) + # getting floors + for f in ifc.getEnt("IFCBUILDINGSTOREY"): + makeCell(f,"Floor") + # getting buildings + for b in ifc.getEnt("IFCBUILDING"): + makeCell(b,"Building") + FreeCAD.ActiveDocument.recompute() + t3 = time.time() + if DEBUG: print "done processing",ifc,"in %s s" % ((t3-t1)) + +def parseFile(filename): + "parses an IFC file" schema=getSchema() if schema: if DEBUG: global ifc if DEBUG: print "opening",filename,"..." ifc = ifcReader.IfcDocument(filename,schema=schema,debug=DEBUG) - t2 = time.time() - if DEBUG: print "Successfully loaded",ifc,"in %s s" % ((t2-t1)) - # getting walls - for w in ifc.getEnt("IFCWALLSTANDARDCASE"): - makeWall(w) - # getting floors - for f in ifc.getEnt("IFCBUILDINGSTOREY"): - makeCell(f,"Floor") - # getting buildings - for b in ifc.getEnt("IFCBUILDING"): - makeCell(b,"Building") - FreeCAD.ActiveDocument.recompute() - t3 = time.time() - if DEBUG: print "done processing",ifc,"in %s s" % ((t3-t1)) + return ifc else: - FreeCAD.Console.PrintWarning("IFC Schema not found, IFC import disabled. See Arch Preferences to get a schema") + FreeCAD.Console.PrintWarning("IFC Schema not found, IFC import disabled.\n") + return None def makeCell(entity,mode="Cell"): "makes a cell in the freecad document" @@ -202,10 +233,16 @@ def makeCell(entity,mode="Cell"): except: if DEBUG: print "error: skipping cell",entity.id -def makeWall(entity): +def makeWall(entity,shape=None): "makes a wall in the freecad document" try: if DEBUG: print "=====> making wall",entity.id + if shape: + sh = FreeCAD.ActiveDocument.addObject("Part::Feature","WallBody") + sh.Shape = shape + wall = Arch.makeWall(sh) + if DEBUG: print "made wall object ",entity.id,":",wall + return placement = wall = wire = body = width = height = None placement = getPlacement(entity.ObjectPlacement) if DEBUG: print "got wall placement",entity.id,":",placement