diff --git a/src/Mod/Arch/ArchCommands.py b/src/Mod/Arch/ArchCommands.py index 38452421c1..0803b54116 100644 --- a/src/Mod/Arch/ArchCommands.py +++ b/src/Mod/Arch/ArchCommands.py @@ -138,6 +138,7 @@ def splitMesh(obj,mark=True): def meshToShape(obj,mark=True): '''meshToShape(object,[mark]): turns a mesh into a shape, joining coplanar facets. If mark is True (default), non-solid objects will be marked in red''' + name = obj.Name import Part,MeshPart from draftlibs import fcgeo if "Mesh" in obj.PropertiesList: @@ -177,21 +178,26 @@ def meshToShape(obj,mark=True): # make sure that the exterior wires comes as first in the list wires.insert(0, ext) print "done sorting", wires - faces.append(Part.Face(wires)) + if wires: + faces.append(Part.Face(wires)) print "done facing" print "faces",faces - shell=Part.Compound(faces) - solid = Part.Solid(Part.Shell(faces)) - name = obj.Name - if solid.isClosed(): - FreeCAD.ActiveDocument.removeObject(name) - newobj = FreeCAD.ActiveDocument.addObject("Part::Feature",name) - newobj.Shape = solid - newobj.Placement = plac - if not solid.isClosed(): - newobj.ViewObject.ShapeColor = (1.0,0.0,0.0,1.0) - return newobj + try: + se = Part.makeShell(faces) + solid = Part.Solid(se) + except: + pass + else: + if solid.isClosed(): + FreeCAD.ActiveDocument.removeObject(name) + else: + if mark: + newobj.ViewObject.ShapeColor = (1.0,0.0,0.0,1.0) + newobj = FreeCAD.ActiveDocument.addObject("Part::Feature",name) + newobj.Shape = solid + newobj.Placement = plac + return newobj return None def removeShape(objs,mark=True): diff --git a/src/Mod/Arch/Arch_rc.py b/src/Mod/Arch/Arch_rc.py index 9dc96a3c14..a8691486c6 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 3 20:45:25 2012 +# Created: Fri Jan 6 18:11:49 2012 # by: The Resource Compiler for PyQt (Qt v4.7.3) # # WARNING! All changes made in this file will be lost! @@ -5697,111 +5697,132 @@ 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\x06\x65\ +\x00\x00\x07\xb2\ \x00\ -\x00\x22\x4d\x78\x9c\xed\x5a\x6d\x6f\xdb\x36\x10\xfe\x9e\x5f\xc1\ -\x79\x40\xbb\x01\xb1\x69\xe7\xad\x89\x22\xbb\x68\x9d\xa4\x29\x90\ -\x6e\x69\xe3\xb6\xd8\xa7\x40\x96\x68\x8b\x1d\x25\x2a\x24\x55\xd9\ -\x1d\xf6\xdf\x77\xa4\x28\x5b\xb2\x1c\x27\x8d\xbd\xb6\x1b\x52\xa4\ -\x88\xc8\xa3\xee\x1e\x3e\x77\xbc\x3b\x49\x71\x9f\x4f\x22\x86\x3e\ -\x13\x21\x29\x8f\xbb\x8d\x4e\xab\xdd\x40\x24\xf6\x79\x40\xe3\x71\ -\xb7\xf1\x7e\x70\xd6\x3c\x6c\x3c\xef\x6d\xb9\x29\x9d\x2f\xda\x83\ -\x45\xbd\x2d\xe4\xfa\xcc\x93\xb2\xf7\x2a\xa5\x8e\x73\x42\x3d\xc6\ -\xc7\xf0\x9b\x8d\xaf\x88\x52\x70\xb3\x7c\x21\xfc\xd0\xc5\xf9\x1a\ -\x58\x9c\xd1\x60\x4c\x14\x32\xe3\x6e\xe3\xed\x47\x33\x6c\xa0\xd8\ -\x8b\x48\xb7\xb1\x4a\x87\x36\x85\xdc\x44\xf0\x84\x08\x35\xb5\x37\ -\x8c\x09\x8f\x88\x12\x53\x23\x44\xae\x20\xbe\x32\x57\xc8\x9d\xf4\ -\xda\x2e\x9e\xd8\xc1\x54\x0f\xa6\x76\x00\x08\x54\xd8\xdb\x7f\xb6\ -\xef\xe2\xfc\x32\x9f\x0e\x09\x1d\x87\xaa\x77\xb0\x73\xe4\x62\x7b\ -\x6d\x74\xe2\x42\xa9\x8b\x0b\xe3\xcb\x90\x64\x34\x0e\x78\x36\xa0\ -\x8a\x11\x0b\x46\x2a\x01\xd8\x7b\xaf\x48\x4c\x84\xc7\x90\xb4\x7b\ -\x71\xb1\x15\xd4\x55\x32\x6f\xca\xd3\x39\x37\x1f\x5e\xf2\xc9\x85\ -\x99\xb2\x1a\x17\x4c\xca\xc4\xf3\x41\x51\xc3\x6e\x20\x4e\xa3\x21\ -\x11\xbd\x03\x17\xdb\xab\x1c\x7e\xd9\x42\x4d\x45\xe4\x89\x31\x8d\ -\x17\x34\x1c\xad\xd4\x40\x15\x89\xe6\x4c\x96\x7d\xf9\x4a\xf0\x34\ -\x01\xcc\x85\x37\xc7\xc5\x38\x5f\x5e\x33\xae\xe6\x64\x2d\xe1\x4b\ -\xfb\x1c\x5d\x2d\x21\xad\x8e\x69\x25\x75\xd6\x18\x44\xad\xa2\xbe\ -\xc7\xf2\xd9\xeb\x9d\xb9\xdd\xf9\x86\x96\x28\x3a\xaf\x29\x0a\xb9\ -\xa0\x5f\x78\xac\x96\xa8\x5a\x54\x56\xa7\xe8\xc2\x1b\x12\x56\x68\ -\x62\x7a\x50\xb9\x7d\x09\x47\x64\xa2\x2a\x0b\x66\x3c\x9d\x90\x91\ -\x97\x32\x50\xcd\x19\x17\x68\x04\xff\x33\x8f\xb1\x45\xa6\x96\xd3\ -\x95\x4f\xe6\xd8\x4a\xe0\x71\x15\x7d\x6d\x33\x3a\xe0\x88\xa8\xf1\ -\x70\x65\xa6\x57\x6e\x03\xd6\x12\x58\xaa\x20\x6f\x2c\xec\x86\x40\ -\xa8\xf5\xde\x2a\xc7\x39\x9f\xe9\x73\xb1\x99\xbc\x6b\x03\xf5\xf3\ -\x40\xbf\x90\x73\x1a\x83\xa7\xa4\x0a\xe0\xb8\x75\x1b\xed\x45\xea\ -\x60\x45\x65\xa6\xc8\x06\x7b\xed\x4a\x32\x98\x49\x6d\x22\xd8\x69\ -\x57\x72\xc2\x1c\xd6\xa2\xc2\x5b\x98\xce\x89\xfb\x0a\xa6\xab\x61\ -\x63\xd2\xe2\xa5\x20\xa3\xbe\xf6\xf5\xcb\x54\x29\xa0\xb1\x38\x64\ -\x5a\x96\x80\xcc\xc4\xc1\x30\x97\xad\x8c\x28\xce\xd9\x80\x26\xcb\ -\x83\x6a\x10\x52\x89\xe0\x47\x85\x04\x05\xb5\x00\x8b\x49\x86\x3e\ -\x42\x90\x21\x3e\xfc\x04\x49\xf1\xfe\xb1\x56\x03\x61\x74\x2e\x40\ -\x30\x73\x0b\xfc\x0b\x12\xf4\x76\xf6\xf7\x75\x12\x0e\x16\x44\x63\ -\x41\x48\xdc\xeb\x1c\x81\x6b\xf2\xcb\xaa\x78\xc8\x52\xd2\xeb\x3c\ -\x03\xa9\xb9\xaa\xba\xad\x66\xea\x7e\xa8\x35\xcd\xa7\xb1\x2e\x37\ -\xb7\x46\x98\x6f\x19\xd1\x34\x19\x6f\x81\xb1\x87\x92\xa4\xcd\x5d\ -\x7a\x2a\xbc\xdb\xda\x1b\x1e\x60\x5b\x67\x37\x75\xfa\x5d\x9c\x67\ -\xc2\x59\x9a\xac\x88\xd7\x4d\x9a\x6b\xa5\xcc\x8d\x25\x4c\x10\xa4\ -\xbe\x4a\x05\xf9\x7e\x59\xf3\x8e\xf4\xff\x98\x37\xbf\x65\xde\xbc\ -\xab\x16\xaf\x97\x39\xaf\x8a\x68\xfb\xb6\xe9\xb3\xb3\xdf\x5e\x91\ -\x3e\x0f\x8e\x56\xa5\xcf\xc3\x83\xef\x94\x3e\x67\x5c\xfd\x7f\x73\ -\x68\x55\x58\xd1\x55\x5a\xf7\x80\x76\x7b\x1e\xc5\xf7\x6b\xb8\x5f\ -\x9f\xf5\x11\x8d\x12\x2e\xd4\xa6\xbb\xec\xcd\xf5\xd8\xbb\xeb\xf5\ -\xd8\xbb\x0f\x2c\x19\x4f\x98\x3a\xfe\xe9\xe4\xf7\xfe\xe0\x8f\xcb\ -\x53\x74\x3e\x78\x73\x81\x2e\xdf\xbf\xbc\x78\xdd\x47\x4f\x6e\x52\ -\xae\x8e\x9b\x18\x7f\xdc\xed\x63\x7c\x32\x38\xc9\xa5\xf0\x44\x8c\ -\xf1\xe9\x6f\xb9\xd4\x2e\x0a\x95\x4a\x1c\x8c\xb3\x2c\x6b\x65\xbb\ -\x2d\x2e\xc6\x78\xf0\x0e\xbf\x3b\xed\x37\x43\x15\xb1\xbd\xb6\xa1\ -\xdc\x57\xad\x40\x05\xf9\xfa\x27\x63\x75\xbc\xa5\x0d\x6b\xb9\x1e\ -\x98\x6b\xe2\x05\xc5\x35\x3c\xf0\x7a\x39\xf2\xfc\x86\x1b\xb8\x3f\ -\xd4\x7b\xb0\x66\x7d\x20\x0e\x8a\x86\x95\x76\xec\x2c\x2e\x6e\x97\ -\x6a\xca\x08\x52\xd3\xa4\xb8\x5f\xdf\x0a\x31\x2f\x4b\xe6\x93\x6d\ -\xc4\x28\xfa\x0b\x65\x21\x70\xdd\x34\x59\xd8\x41\x70\x94\x9a\x99\ -\xf0\x92\x63\xf4\xb7\xc1\x87\x8d\xa6\x42\x2d\x2e\x43\x1c\xf2\x60\ -\x8a\x8c\xd8\xda\x80\x24\x18\xab\xe6\xc8\x8b\x28\x9b\x3a\x4f\x4f\ -\xc8\x27\xef\x43\x8a\xae\xbc\x58\x3e\xb5\x22\x5d\x10\x9c\xc3\xa4\ -\x58\x99\x99\xa2\xe1\xec\xb5\xdb\x85\x5c\x2b\x73\x62\x2e\x22\x8f\ -\x1d\x2f\x10\x95\x54\x4d\xe5\xcf\xb4\x4d\xc5\x13\xa7\x9d\x4c\x66\ -\xe3\x21\x87\x14\x1f\x55\xa6\x18\x19\xa9\xca\x84\x30\x56\xcd\x4c\ -\xf3\x46\x35\x87\x8c\xfb\x7f\x36\xe1\xc1\x1e\xe8\x74\x00\x89\x66\ -\x6a\x36\x84\x45\x73\x1c\x67\x90\xe3\x75\xe6\xd7\x67\x49\x00\x11\ -\x50\xef\x15\x47\xa3\x34\xf6\x75\xe9\xde\x46\x10\xc4\x50\x03\x48\ -\x80\xbc\xd8\xac\xb9\xf2\x43\x12\x79\xe8\x74\x02\xa4\x4a\x89\x46\ -\x14\x5c\xf2\x4b\x8b\x4c\x92\x5f\x91\xf7\xd9\xa3\x10\xb5\x30\x11\ -\x12\x41\x1c\xc3\x6d\xf2\x23\xed\x55\xc3\xf0\x50\x08\x89\xb5\x5b\ -\x8b\x70\xa9\x48\xa2\xcb\xa4\x6c\xf9\x3c\xc2\x32\x4d\x74\x5a\x81\ -\x40\x09\xc8\xe7\xeb\x80\xfb\x12\x93\x7c\xc7\x98\x8e\xfc\x9d\xc9\ -\xae\xfd\x75\xad\xfc\x8e\xde\x7c\xd5\x06\x84\x5d\x5c\xdd\xad\xc1\ -\x14\x10\x9f\x0b\xd3\x11\x39\x28\x05\x7c\x82\xd1\x98\x1c\xe7\xb5\ -\xd6\xf9\x79\xbf\x7d\x48\x82\xc3\x12\xda\xcd\x81\x33\x21\x0f\x98\ -\x66\x11\xef\xcd\xae\x92\xd9\x95\x8e\xfc\xf9\x91\xb0\x27\x78\x73\ -\xdd\xe5\xbf\xdb\x95\x5f\xef\xad\x97\x66\xf7\x1e\x98\x66\x4b\x27\ -\xc2\x9c\x04\x08\x45\xe3\xe0\xef\xd7\x95\xaf\x2e\x18\x8f\x5d\xf9\ -\x46\xba\xf2\x33\xf0\x75\x3f\xe4\x5c\x12\x51\xeb\xca\x75\x1c\xf8\ -\x56\xf6\xe0\x9e\xfc\xb1\x7c\x3f\x96\xef\x6f\x5d\xbe\x97\xfc\xfb\ -\xf1\x4a\xf8\xbc\xc7\xf8\x8f\x15\x73\xe8\x88\x5a\xe8\x96\x4a\xac\ -\x9d\xc8\xa8\x4f\x62\x09\x67\x5f\xbb\x51\xf2\x58\xa2\x8c\x20\x0f\ -\x1e\xb9\x63\xae\x90\xc7\x18\xcf\xc0\x89\xe0\x5a\x19\xd2\x04\x3c\ -\xee\xa9\xdc\x77\x3f\x9e\x87\x32\xaa\x42\x74\x06\x0f\xe6\xfd\x17\ -\x27\xdb\x48\x72\x13\x82\x51\x2a\x15\x0a\x78\x16\x33\xee\x05\x88\ -\x2a\x3d\x29\x24\x61\xa3\x16\xba\x64\x70\xc8\x4b\x3b\xa2\xc0\x36\ -\x8f\xc8\x8f\xb7\xb1\xa2\xb6\x23\xf8\xd1\xf0\xc1\xd7\x51\x92\x2a\ -\x22\xb6\xe1\x70\x05\x08\x76\x43\x7c\x65\x0e\xa3\xd9\x87\xf1\xf8\ -\x46\x7b\xac\x75\x5e\x4b\xbc\x1e\xf9\xf9\xd1\x7f\x7c\x23\x91\xd7\ -\xd9\x72\x13\x55\x3c\xfb\x57\x3f\x07\xdd\xa7\x77\x9a\xb7\x4d\x1f\ -\xac\x8e\x4a\xd3\x54\x7f\x0f\xf1\x15\xad\x52\xb5\x4b\xb2\x0d\xd2\ -\x4e\xad\x41\x2a\x7a\xa3\xbd\x5a\x6f\x54\x69\x8b\x16\xa1\x54\x9a\ -\xa1\x39\x49\x25\x26\x4b\x34\xda\x86\xbc\x78\x3b\x68\x3f\xdf\x76\ -\x1b\x07\x0d\x7b\xaa\xba\x8d\x4e\xa7\x81\xf5\xca\x84\x4e\x22\x2f\ -\x29\x0a\x50\xef\xe6\xd2\x8c\xcf\x04\x8f\xde\xd0\x88\x5c\xc1\xb9\ -\xf1\x09\x60\xa9\xae\xd2\x9f\xe2\x21\x43\xf0\x28\xb7\x28\x0d\x92\ -\xf2\x4c\x8e\xb2\xf4\xb9\xbe\xd4\x81\xcd\x3f\xd1\x6b\x7f\x4c\xa0\ -\x05\x09\x64\xcf\x7e\x9e\x07\x6f\xd8\x89\xad\x9c\x2a\x5d\x21\xb5\ -\x06\xac\x15\xe4\xdf\xeb\x5b\xa1\x8b\xad\xc0\x10\xb0\x68\x77\x35\ -\x90\xd2\x0b\xda\xe5\x40\x2e\x53\x19\x16\xf2\xdb\xc0\xe4\x60\xe5\ -\x7a\x48\x16\x1a\xd3\xa5\x68\xea\xdc\xdd\x06\x49\x6b\xdb\x18\xac\ -\xbb\x48\xaa\x33\xb9\x3e\xac\xea\x84\xf9\x0b\x0e\x28\xf9\x26\xfe\ -\xa4\x89\x54\x68\x57\x63\x62\xe2\x4f\x8f\x5d\x9c\xd2\xde\xd6\x3f\ -\x48\xb4\x84\x40\ +\x00\x28\x75\x78\x9c\xed\x5a\xeb\x73\xd3\x38\x10\xff\xde\xbf\x42\ +\x97\x9b\xe1\x31\xd3\x44\x49\xdb\x94\x36\x75\x7d\x03\x7d\x40\x67\ +\xe0\x28\xb4\xc0\xdc\x27\xc6\xb1\x95\x58\x20\x5b\xc6\x92\x49\xc2\ +\xcd\xfd\xef\xb7\x7a\x38\x7e\xa5\xe9\x23\xa1\x1c\x37\xcc\x14\x6a\ +\x69\xa5\xdd\xd5\x4f\xab\xdf\xae\x5c\x3b\x7f\x4c\x23\x86\xbe\x92\ +\x54\x50\x1e\x1f\xb6\x7a\x9d\x6e\x0b\x91\xd8\xe7\x01\x8d\xc7\x87\ +\xad\x77\x97\xa7\xed\xbd\xd6\x1f\xee\x86\x93\xd1\x62\xd0\x0e\x0c\ +\x72\x37\x90\xe3\x33\x4f\x08\xf7\x79\x46\x07\x83\x63\xea\x31\x3e\ +\x86\xdf\x6c\x7c\x41\xa4\x84\xc9\xe2\x69\xea\x87\x0e\x36\x63\x60\ +\xf0\x84\x06\x63\x22\x91\x6e\x1f\xb6\xde\x7c\xd0\xcd\x16\x8a\xbd\ +\x88\x1c\xb6\x96\xe9\x50\xa6\x90\x93\xa4\x3c\x21\xa9\x9c\xd9\x09\ +\x63\xc2\x23\x22\xd3\x99\x16\x22\x27\x25\xbe\xd4\x4f\xc8\x99\xba\ +\x5d\x07\x4f\x6d\x63\xa6\x1a\x33\xdb\x00\x0f\x64\xe8\xf6\x9f\xf4\ +\x1d\x6c\x1e\x4d\x77\x48\xe8\x38\x94\xee\xee\xd6\xbe\x83\xed\xb3\ +\xd6\x89\x73\xa5\x0e\xce\x8d\x2f\xf2\x64\x42\xe3\x80\x4f\x2e\xa9\ +\x64\xc4\x3a\x23\x64\x0a\xbe\xbb\xcf\x49\x4c\x52\x8f\x21\x61\xd7\ +\xe2\x60\x2b\x68\xaa\x64\xde\x8c\x67\x05\x36\xef\x9f\xf1\xe9\x4b\ +\xdd\x65\x35\xd6\x4c\x8a\xc4\xf3\x41\x51\xcb\x2e\x20\xce\xa2\x21\ +\x49\xdd\x5d\x07\xdb\x27\xe3\x7e\xd9\x42\x43\x45\xe4\xa5\x63\x1a\ +\xd7\x34\xec\x2f\xd5\x40\x25\x89\x0a\x24\xcb\x7b\xf9\x3c\xe5\x59\ +\x02\x3e\xe7\xbb\x39\xce\xdb\x66\x78\xc3\xb8\x2c\xc0\x5a\x80\x97\ +\xda\x73\x74\xb1\x00\xb4\xa6\x4f\x4b\xa1\xb3\xc6\x20\x6a\x25\xf5\ +\x3d\x66\x7a\x3f\x6e\x15\x76\x8b\x05\x2d\x50\xf4\xa2\xa1\x28\xe4\ +\x29\xfd\xc6\x63\xb9\x40\x55\x5d\x59\x13\xa2\x97\xde\x90\xb0\x5c\ +\x13\x53\x8d\xca\xf4\x05\x18\x91\xa9\xac\x0c\x98\xe3\x74\x4c\x46\ +\x5e\xc6\x40\x35\x67\x3c\x45\x23\xf8\x37\xf1\x18\xab\x23\xb5\x18\ +\x2e\xd3\x69\x7c\x2b\x39\x8f\xab\xde\x37\x16\xa3\x02\x8e\xa4\x0d\ +\x1c\x2e\x74\xf7\xd2\x65\xc0\x58\x02\x43\x25\xf0\x46\x6d\x35\x04\ +\x42\xcd\x7d\x23\x07\x83\x17\x73\x7d\x0e\xd6\x9d\xd7\x2d\xa0\x79\ +\x1e\xe8\x37\xf2\x82\xc6\xb0\x53\x42\x06\x70\xdc\x0e\x5b\xdd\x3a\ +\x74\x30\xa2\xd2\x93\xb3\xc1\x4e\xb7\x42\x06\x73\xa9\x25\x82\xad\ +\x6e\x85\x13\x0a\xb7\xea\x0a\xaf\x40\xda\x00\x77\x0b\xa4\xab\x61\ +\xa3\x69\xf1\x3c\x25\xa3\x23\xb5\xd7\xcf\x32\x29\x01\xc6\xfc\x90\ +\x29\x59\x02\x32\x1d\x07\x43\x23\x5b\x1a\x51\x9c\xb3\x4b\x9a\x2c\ +\x0e\xaa\xcb\x90\x0a\x04\x3f\x32\x24\x28\x68\x04\x58\x4c\x26\xe8\ +\x03\x04\x19\xe2\xc3\x4f\x40\x8a\x37\x8f\xb5\x86\x13\x5a\x67\xcd\ +\x05\xdd\x57\xc3\x3f\x25\x81\xbb\xd5\xef\x2b\x12\x0e\x6a\xa2\x71\ +\x4a\x48\xec\xf6\xf6\x61\x6b\xcc\x63\x55\x3c\x64\x19\x71\x7b\x4f\ +\x40\xaa\x9f\xaa\xdb\xd6\x30\x75\x33\xaf\x15\xcc\x27\xb1\x4a\x37\ +\x57\x46\x98\x6f\x11\x51\x30\xe9\xdd\x02\x63\x77\x05\x49\x99\x3b\ +\xf7\x64\x78\xbd\xb5\x57\x3c\xc0\x36\xcf\xae\xeb\xf4\x3b\xd8\x30\ +\xe1\x9c\x26\x2b\xe2\x55\x49\x73\x25\xca\x5c\x1b\x61\x82\x20\xf3\ +\x65\x96\x92\x1f\xc7\x9a\xd7\xd0\xff\x2f\xde\xbc\x4f\xde\xbc\x2e\ +\x17\xaf\xc6\x9c\x17\x79\xb4\xdd\x2f\x7d\xf6\xfa\xdd\x25\xf4\xb9\ +\xbb\xbf\x8c\x3e\xf7\x76\x7f\x10\x7d\xce\xb1\xfa\xff\x72\x68\x55\ +\x58\xd1\x55\x1a\x77\x87\x72\xbb\x88\xe2\x9b\x15\xdc\x67\xa7\x47\ +\x88\x46\x09\x4f\xe5\xba\xab\xec\xf5\xd5\xd8\xdb\xab\xd5\xd8\xdb\ +\x77\x4c\x19\x0f\x98\x3c\xf8\xed\xf8\xf5\xd1\xe5\x5f\xe7\x27\xe8\ +\xc5\xe5\xab\x97\xe8\xfc\xdd\xb3\x97\x67\x47\xe8\xc1\x97\x8c\xcb\ +\x83\x36\xc6\x1f\xb6\x8f\x30\x3e\xbe\x3c\x36\x52\xb8\x11\x63\x7c\ +\xf2\xa7\x91\xda\x41\xa1\x94\xc9\x00\xe3\xc9\x64\xd2\x99\x6c\x77\ +\x78\x3a\xc6\x97\x6f\xf1\xdb\x93\xa3\x76\x28\x23\xb6\xd3\xd5\x90\ +\xfb\xb2\x13\xc8\xc0\x8c\x7f\x30\x96\x07\x1b\xca\xb0\x92\xab\x86\ +\x7e\x26\x5e\x90\x3f\xc3\x85\xd7\x33\x9e\x9b\x09\x5f\x60\x7e\xa8\ +\xd6\x60\xcd\xfa\x00\x1c\x24\x0d\x2b\xed\xd9\x5e\x9c\x4f\x17\x72\ +\xc6\x08\x92\xb3\x24\x9f\xaf\xa6\x42\xcc\x8b\x92\xf9\x64\x13\x31\ +\x8a\xfe\x46\x93\x10\xb0\x6e\x6b\x16\x1e\x20\x38\x4a\xed\x49\xea\ +\x25\x07\xe8\x1f\xed\x1f\xd6\x9a\x72\xb5\xb8\xec\xe2\x90\x07\x33\ +\xa4\xc5\xd6\x06\x90\x60\x2c\xdb\x23\x2f\xa2\x6c\x36\x78\x78\x4c\ +\x3e\x79\xef\x33\x74\xe1\xc5\xe2\xa1\x15\xa9\x84\x30\xd8\x4b\xf2\ +\x91\x13\x9d\x34\x06\x3b\xdd\x6e\x2e\x57\xca\x06\x31\x4f\x23\x8f\ +\x1d\xd4\x80\x4a\xaa\xa6\xcc\x9d\xb6\x2d\x79\x32\xe8\x26\xd3\x79\ +\x7b\xc8\x81\xe2\xa3\x4a\x17\x23\x23\x59\xe9\x48\xb5\x55\xdd\xd3\ +\xfe\x22\xdb\x43\xc6\xfd\xcf\x6d\xb8\xd8\x03\x9c\x03\xf0\x44\x21\ +\x35\x6f\xc2\xa0\xc2\x8f\x53\xe0\x78\xc5\xfc\xea\x2c\xa5\x00\x04\ +\xe4\x7b\xc9\xd1\x28\x8b\x7d\x95\xba\x37\x11\x04\x31\xe4\x00\x12\ +\x20\x2f\xd6\x63\x2e\xfc\x90\x44\x1e\x3a\x99\x02\xa8\x42\xa0\x11\ +\x85\x2d\x79\xd4\x21\xd3\xe4\x31\xf2\xbe\x7a\x14\xa2\x16\x3a\x42\ +\x92\x92\x81\xc6\x36\xf9\x2f\xad\x55\xb9\xe1\xa1\x10\x88\xf5\xb0\ +\x11\xe1\x42\x92\x44\xa5\x49\xd1\xf1\x79\x84\x45\x96\x28\x5a\x81\ +\x40\x09\xc8\xd7\x8f\x01\xf7\x05\x26\x66\xc5\x98\x8e\xfc\xad\xe9\ +\xb6\xfd\xf5\x51\xfa\x3d\xb5\xf8\xaa\x0d\x08\xbb\xb8\xba\x5a\xed\ +\x53\x40\x7c\x9e\xea\x8a\x68\x80\x32\xf0\x2f\x65\x34\x26\x07\x26\ +\xd7\x0e\x7e\xef\x77\xf7\x48\xb0\x57\xf2\x76\x7d\xce\xe9\x90\x07\ +\x9f\xe6\x11\xef\xcd\x9f\x92\xf9\x93\x8a\xfc\xe2\x48\xd8\x13\xbc\ +\xbe\xea\xf2\xfb\x56\xe5\x1f\x77\x56\xa3\xd9\x9d\x3b\xd2\x6c\xe9\ +\x44\xe8\x93\x00\xa1\xa8\x37\xf8\xc7\x55\xe5\xcb\x13\xc6\xaf\xaa\ +\x7c\x2d\x55\xf9\x29\xec\xf5\x51\xc8\xb9\x20\x69\xa3\x2a\x57\x71\ +\xe0\x5b\xd9\x9d\x6b\xf2\xf5\xb1\x72\x07\x29\x5d\x8c\xfa\x24\x16\ +\xa0\x59\x69\x13\x3c\x16\x68\x42\x90\x07\x05\x7d\xcc\x25\x82\x0b\ +\x3f\x9f\x80\x2e\xb0\x20\x42\x9a\x80\x61\x4f\x1a\x15\x13\x2a\x43\ +\x74\x0a\x45\xf6\xd1\xd3\xe3\x4d\x24\xb8\xb6\x1b\x65\x42\xa2\x80\ +\x4f\x62\xc6\xbd\x00\x51\xa9\x3a\x53\x41\xd8\xa8\x83\xce\x19\xe0\ +\x5b\x9a\x4f\x81\x06\x79\x54\x1c\x0b\x04\x3f\x6a\x34\x70\x5e\x94\ +\x64\x92\xa4\x9b\xb0\x80\x00\xc1\x64\xb8\x55\xe8\x05\xeb\x69\x2a\ +\x7d\x74\xee\x7e\xc7\xb8\x45\xb5\x7e\x36\xf2\x0d\x74\xff\xcb\x42\ +\x7d\x75\x5a\xed\xdf\x9c\x56\x8b\x2b\x6b\x48\xfc\xcf\xe5\xea\x7e\ +\x7e\x5f\x55\x82\x61\xf1\x56\xfd\xf6\xc7\xe2\x6c\x04\x41\x62\x6e\ +\xab\x5a\x19\x09\x36\x11\xe4\x3a\x50\x10\x8b\x90\x30\x06\x01\x0b\ +\xff\x0d\x09\xca\x84\x89\x67\x1f\xc2\x5d\x12\x14\x11\x10\xc3\xb4\ +\x18\x12\x29\xc4\x2c\x1f\x99\x77\xf4\x2b\xdf\x66\xaf\x4e\x0c\xef\ +\x04\x1c\xde\x91\xff\x1a\x3c\xbb\x50\x9e\xdd\x4b\x34\xc3\xaa\xab\ +\x36\x7f\xce\x98\xbe\x6d\xca\x5b\x9e\xbc\x7f\xa5\xbc\x55\x52\xde\ +\xa2\x62\xa9\xbf\x14\x6f\x12\xab\x2b\x40\x50\x5b\xfe\x10\x8e\xb5\ +\x3b\xf2\x98\x20\x0e\xd6\xcf\x6b\x3c\x6b\x2a\x50\xd5\x61\xbf\xd3\ +\x79\xbb\x43\x34\xae\x56\x14\x5c\xf3\xaa\xee\xbb\xc1\x77\x0d\xaf\ +\xaa\xcc\x1e\x7a\x5f\x49\x95\x4f\x15\x63\x42\x79\xa0\x78\x56\x24\ +\xc4\xa7\xa3\x99\x4e\xce\x3a\x55\x27\x05\xec\x67\xfa\x25\x4c\x27\ +\x99\xdd\x0b\xcd\x95\x3d\xfc\x59\x39\x6e\xcd\x2f\xd8\x2a\x04\x99\ +\xbf\xca\xaa\xfe\x75\xf3\x26\xbc\x58\x50\xe2\x7b\xab\xa3\x42\x88\ +\xcd\xd7\x6a\xb7\xa0\xc1\x2a\x03\x5a\xf2\xdb\x6a\x90\x5f\xce\x7b\ +\x3b\x0d\xde\xab\x50\x5e\xdd\x95\x0a\xd1\x15\x20\x95\x90\x2c\xc1\ +\x68\x0b\xa1\xfc\x65\xb7\xfd\x1a\xe1\xb0\xb5\xdb\xb2\xaf\x18\x0e\ +\x5b\xbd\x5e\x0b\xab\x91\x09\x9d\x46\x5e\x92\x17\xde\xee\x97\x73\ +\xdd\x3e\x4d\x79\xf4\x8a\x46\xe4\x02\x6a\x59\x1f\x8e\x64\x6d\x94\ +\xfa\xb2\x04\x8a\x64\x1e\x19\x8b\x42\x7b\x52\xee\x31\x5e\x96\xbe\ +\x3e\x29\x71\x47\xf1\xc5\x89\xda\x8f\xa9\x24\x71\x20\x5c\xfb\xb5\ +\x09\xec\x86\xed\xd8\x30\x50\xa9\x9b\x81\xd2\x80\x95\x02\xf3\xf9\ +\x49\x27\x74\xb0\x15\x68\x00\xea\x76\x97\x3b\x52\xfa\x7b\xc3\x62\ +\x47\xce\x33\x11\xe6\xf2\xab\x9c\x31\xce\x8a\xd5\x3c\xa9\x51\xea\ +\x42\x6f\x9a\xd8\x5d\xe5\x92\xd2\xb6\x36\xb7\xae\x03\xa9\x89\xe4\ +\xfd\xb8\x65\x0b\xef\xc5\x1b\x57\x48\x57\x77\xa6\xda\xa1\xbf\x8e\ +\x82\x7b\xa7\x3e\x0c\x42\x1f\x1b\x9f\xc7\x31\xd1\x87\xc1\x06\xff\ +\xbc\x6d\xac\x0a\xa2\xde\x7f\xb9\x8d\xab\x01\x1c\x63\x23\x31\xa3\ +\xe8\x38\xf6\x98\x2b\xf9\x78\x0c\x29\xe8\x91\x4a\x7c\x8f\x15\x0b\ +\xe8\x5e\x3d\x22\x25\x3e\xa1\xc0\x77\xae\xad\x4c\xf4\x37\x4f\xa6\ +\xc7\x68\x60\x5c\xba\x40\x44\x27\x26\xab\xce\x55\xa8\x6e\xb3\x7c\ +\x60\x2b\x61\x29\x44\x3d\x9b\xd7\xcb\x2d\xb3\x96\xca\xdf\x6c\x9d\ +\xa9\xfb\x64\x7f\xfe\x61\x96\xfa\x32\xab\xb7\xdf\x2b\xbe\xcd\xc2\ +\x6a\x76\x53\x51\x40\x84\xa4\xb1\x66\xd9\xba\xb6\xed\x27\xbb\x35\ +\x75\x5b\x8b\xd4\x99\x47\x61\xf7\xa1\x82\xe3\xf7\x87\x75\x71\x01\ +\xf3\x7d\x51\xde\xed\xad\x13\xe5\x9d\xdd\x7e\x45\xdd\x56\x77\xa1\ +\xba\xab\x51\x2e\x37\x41\xee\xe0\x8c\xba\x1b\xff\x02\x13\xcc\x10\ +\x82\ \x00\x00\x07\x4c\ \x00\ \x00\x29\xd1\x78\x9c\xed\x59\x5b\x8f\xe2\x46\x16\x7e\xef\x5f\xe1\ @@ -10078,30 +10099,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\x2f\x81\ -\x00\x00\x04\x1e\x00\x00\x00\x00\x00\x01\x00\x01\xf1\xb2\ -\x00\x00\x02\xfc\x00\x00\x00\x00\x00\x01\x00\x01\xa3\x40\ -\x00\x00\x05\xb2\x00\x01\x00\x00\x00\x01\x00\x02\x5b\x13\ -\x00\x00\x04\xe4\x00\x01\x00\x00\x00\x01\x00\x02\x28\xaf\ -\x00\x00\x03\x36\x00\x01\x00\x00\x00\x01\x00\x01\xb1\xaf\ -\x00\x00\x03\x88\x00\x01\x00\x00\x00\x01\x00\x01\xc5\x36\ -\x00\x00\x02\xa0\x00\x01\x00\x00\x00\x01\x00\x01\x88\xa0\ -\x00\x00\x04\x5e\x00\x00\x00\x00\x00\x01\x00\x02\x0b\x8c\ -\x00\x00\x02\x7e\x00\x01\x00\x00\x00\x01\x00\x01\x7f\xa7\ -\x00\x00\x03\x64\x00\x01\x00\x00\x00\x01\x00\x01\xbb\x07\ -\x00\x00\x02\x34\x00\x01\x00\x00\x00\x01\x00\x01\x6e\xff\ -\x00\x00\x02\x5e\x00\x01\x00\x00\x00\x01\x00\x01\x78\xa7\ -\x00\x00\x04\x8e\x00\x01\x00\x00\x00\x01\x00\x02\x1a\xfa\ -\x00\x00\x03\xf4\x00\x00\x00\x00\x00\x01\x00\x01\xe1\x31\ -\x00\x00\x04\xbc\x00\x01\x00\x00\x00\x01\x00\x02\x20\x4a\ -\x00\x00\x05\x3c\x00\x00\x00\x00\x00\x01\x00\x02\x36\x5c\ -\x00\x00\x03\xac\x00\x01\x00\x00\x00\x01\x00\x01\xca\x4d\ -\x00\x00\x05\x86\x00\x01\x00\x00\x00\x01\x00\x02\x52\x99\ -\x00\x00\x05\x66\x00\x01\x00\x00\x00\x01\x00\x02\x48\x5f\ -\x00\x00\x04\x3e\x00\x01\x00\x00\x00\x01\x00\x02\x05\x74\ -\x00\x00\x02\xd2\x00\x00\x00\x00\x00\x01\x00\x01\x90\xe2\ -\x00\x00\x03\xd6\x00\x00\x00\x00\x00\x01\x00\x01\xd2\x35\ -\x00\x00\x02\x00\x00\x01\x00\x00\x00\x01\x00\x01\x67\xaf\ +\x00\x00\x05\x12\x00\x01\x00\x00\x00\x01\x00\x02\x30\xce\ +\x00\x00\x04\x1e\x00\x00\x00\x00\x00\x01\x00\x01\xf2\xff\ +\x00\x00\x02\xfc\x00\x00\x00\x00\x00\x01\x00\x01\xa4\x8d\ +\x00\x00\x05\xb2\x00\x01\x00\x00\x00\x01\x00\x02\x5c\x60\ +\x00\x00\x04\xe4\x00\x01\x00\x00\x00\x01\x00\x02\x29\xfc\ +\x00\x00\x03\x36\x00\x01\x00\x00\x00\x01\x00\x01\xb2\xfc\ +\x00\x00\x03\x88\x00\x01\x00\x00\x00\x01\x00\x01\xc6\x83\ +\x00\x00\x02\xa0\x00\x01\x00\x00\x00\x01\x00\x01\x89\xed\ +\x00\x00\x04\x5e\x00\x00\x00\x00\x00\x01\x00\x02\x0c\xd9\ +\x00\x00\x02\x7e\x00\x01\x00\x00\x00\x01\x00\x01\x80\xf4\ +\x00\x00\x03\x64\x00\x01\x00\x00\x00\x01\x00\x01\xbc\x54\ +\x00\x00\x02\x34\x00\x01\x00\x00\x00\x01\x00\x01\x70\x4c\ +\x00\x00\x02\x5e\x00\x01\x00\x00\x00\x01\x00\x01\x79\xf4\ +\x00\x00\x04\x8e\x00\x01\x00\x00\x00\x01\x00\x02\x1c\x47\ +\x00\x00\x03\xf4\x00\x00\x00\x00\x00\x01\x00\x01\xe2\x7e\ +\x00\x00\x04\xbc\x00\x01\x00\x00\x00\x01\x00\x02\x21\x97\ +\x00\x00\x05\x3c\x00\x00\x00\x00\x00\x01\x00\x02\x37\xa9\ +\x00\x00\x03\xac\x00\x01\x00\x00\x00\x01\x00\x01\xcb\x9a\ +\x00\x00\x05\x86\x00\x01\x00\x00\x00\x01\x00\x02\x53\xe6\ +\x00\x00\x05\x66\x00\x01\x00\x00\x00\x01\x00\x02\x49\xac\ +\x00\x00\x04\x3e\x00\x01\x00\x00\x00\x01\x00\x02\x06\xc1\ +\x00\x00\x02\xd2\x00\x00\x00\x00\x00\x01\x00\x01\x92\x2f\ +\x00\x00\x03\xd6\x00\x00\x00\x00\x00\x01\x00\x01\xd3\x82\ +\x00\x00\x02\x00\x00\x01\x00\x00\x00\x01\x00\x01\x68\xfc\ \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 663bda9ca5..4d1ad8bdd9 100644 --- a/src/Mod/Arch/Resources/ui/archprefs-base.ui +++ b/src/Mod/Arch/Resources/ui/archprefs-base.ui @@ -164,14 +164,7 @@ p, li { white-space: pre-wrap; } - <!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) </p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">available <a href="http://www.steptools.com/support/stdev_docs/express/ifc2x3/ifc2x3_tc1.exp"><span style=" text-decoration: underline; color:#508ed8;">here. </span></a>For licensing reasons we are not allowed to ship that file </p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">with FreeCAD, so you must download it yourself. Place that file in some</p> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">location on your computer, and select the file here.</p></body></html> + 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 @@ -183,6 +176,65 @@ p, li { white-space: pre-wrap; } + + + + + + If this is checked, ifcopenshell will be used to create meshes instead of Arch objects + + + Use IfcOpenShell + + + useIfcOpenShell + + + Mod/Arch + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + Path to IfcOpenShell + + + + + + + false + + + If you have ifcopenshell installed, specify here the path to IfcImport.py + + + ifcopenshell + + + Mod/Arch + + + + + @@ -224,7 +276,45 @@ p, li { white-space: pre-wrap; } Gui::ColorButton
Gui/PrefWidgets.h
+ + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
- + + + gui::prefcheckbox + toggled(bool) + label_5 + setEnabled(bool) + + + 79 + 191 + + + 376 + 192 + + + + + gui::prefcheckbox + toggled(bool) + gui::preffilechooser_2 + setEnabled(bool) + + + 61 + 191 + + + 465 + 201 + + + + diff --git a/src/Mod/Arch/importIFC.py b/src/Mod/Arch/importIFC.py index e165b01265..bbca0e2b10 100644 --- a/src/Mod/Arch/importIFC.py +++ b/src/Mod/Arch/importIFC.py @@ -21,7 +21,7 @@ #* * #*************************************************************************** -import ifcReader, FreeCAD, Arch, Draft, os, time +import ifcReader, FreeCAD, Arch, Draft, os, sys, time from draftlibs import fcvec __title__="FreeCAD IFC importer" @@ -36,7 +36,12 @@ def open(filename): doc = FreeCAD.newDocument(docname) doc.Label = decode(docname) FreeCAD.ActiveDocument = doc - read(filename) + p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") + p = p.GetBool("useIfcOpenShell") + if p: + readOpenShell(filename) + else: + read(filename) return doc def decode(name): @@ -52,6 +57,7 @@ def decode(name): return decodedName def getSchema(): + "retrieves the express schema" default = "IFC2X3_TC1.exp" p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") p = p.GetString("IfcSchema") @@ -62,6 +68,55 @@ def getSchema(): if os.path.exists(p): return p return None + +def getIfcOpenShell(): + "locates and imports ifcopenshell" + p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch") + p = p.GetString("ifcopenshell") + if p: + try: + sys.path.append(os.path.dirname(p)) + global IfcOpenShell + IfcOpenShell = None + import IfcImport as IfcOpenShell + except: + print "Couldn't import IfcOpenShell" + +def readOpenShell(filename): + import Mesh + getIfcOpenShell() + if IfcOpenShell: + IfcOpenShell.Init(filename) + while True: + obj = IfcOpenShell.Get() + print "parsing ",obj.guid,": ",obj.name," of type ",obj.type + meshdata = [] + n = obj.name + if not n: n = "Unnamed" + f = obj.mesh.faces + v = obj.mesh.verts + m = obj.matrix + print "verts: ",len(v)," faces: ",len(f) + mat = FreeCAD.Matrix(m[0], m[1], m[2], 0, + m[3], m[4], m[5], 0, + m[6], m[7], m[8], 0, + m[9], m[10], m[11], 1) + for i in range(0, len(f), 3): + print "face ",f[i],f[i+1],f[i+2] + face = [] + print "i:",i + for j in range(3): + vi = f[i+j]*3 + print "vi:",vi + face.append([v[vi],v[vi+1],v[vi+2]]) + meshdata.append(face) + newmesh = Mesh.Mesh(meshdata) + mobj = FreeCAD.ActiveDocument.addObject("Mesh::Feature",n) + mobj.Mesh = newmesh + mobj.Placement = FreeCAD.Placement(mat) + if not IfcOpenShell.Next(): + break + return None def read(filename): "processes an ifc file and add its objects to the given document" diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index eadc25d54c..22457a4e20 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -273,13 +273,14 @@ def getSelection(): "getSelection(): returns the current FreeCAD selection" return FreeCADGui.Selection.getSelection() -def select(objs): +def select(objs=None): "select(object): deselects everything and selects only the passed object or list" FreeCADGui.Selection.clearSelection() - if not isinstance(objs,list): - objs = [objs] - for obj in objs: - FreeCADGui.Selection.addSelection(obj) + if objs: + if not isinstance(objs,list): + objs = [objs] + for obj in objs: + FreeCADGui.Selection.addSelection(obj) def makeCircle(radius, placement=None, face=True, startangle=None, endangle=None, support=None): '''makeCircle(radius,[placement,face,startangle,endangle]): Creates a circle @@ -1269,10 +1270,10 @@ def makeSketch(objectslist,autoconstraints=False,addTo=None,name="Sketch"): if closed: nobj.addConstraint(Constraint("Coincident",last-1,EndPoint,segs[0],StartPoint)) ok = True - else: + elif obj.isDerivedFrom("Part::Feature"): if fcgeo.hasOnlyWires(obj.Shape): for w in obj.Shape.Wires: - for edge in w.Edges: + for edge in fcgeo.sortEdges(w.Edges): nobj.addGeometry(fcgeo.geom(edge)) if autoconstraints: last = nobj.GeometryCount @@ -2354,9 +2355,9 @@ class _Array: self.createGeometry(obj) def onChanged(self,obj,prop): - if prop in ["ArrayType","NumberX","NumberY","NumberPolar","IntervalX","IntervalY","Angle","Center"]: + if prop in ["ArrayType","NumberX","NumberY","NumberPolar","IntervalX","IntervalY","Angle","Center","Axis"]: self.createGeometry(obj) - + def createGeometry(self,obj): from draftlibs import fcgeo if obj.Base: diff --git a/src/Mod/Draft/importSVG.py b/src/Mod/Draft/importSVG.py index 0590d77016..138ed488a4 100644 --- a/src/Mod/Draft/importSVG.py +++ b/src/Mod/Draft/importSVG.py @@ -22,13 +22,12 @@ #*************************************************************************** __title__="FreeCAD Draft Workbench - SVG importer/exporter" -__author__ = "Yorik van Havre " -__url__ = ["http://yorik.orgfree.com","http://free-cad.sourceforge.net"] +__author__ = "Yorik van Havre, Sebastian Hoogen" +__url__ = ["http://free-cad.sourceforge.net"] ''' This script imports SVG files in FreeCAD. Currently only reads the following entities: paths, lines, arcs and rects. -Bezier curves are skipped. ''' import xml.sax, string, FreeCAD, os, math, re, Draft @@ -373,13 +372,14 @@ class svgHandler(xml.sax.ContentHandler): path = [] point = [] lastvec = Vector(0,0,0) + lastpole = None command = None relative = False firstvec = None pathdata = [] for d in data['d']: - if (len(d) == 1) and (d in ['m','M','l','L','h','H','v','V','a','A','c','C']): + if (len(d) == 1) and (d in ['m','M','l','L','h','H','v','V','a','A','c','C','q','Q','s','S','t','T']): pathdata.append(d) else: try: @@ -453,12 +453,44 @@ class svgHandler(xml.sax.ContentHandler): command = "close" point = [] elif (d == "C"): - command = "curve" + command = "cubic" relative = False + smooth = False point = [] elif (d == "c"): - command = "curve" + command = "cubic" relative = True + smooth = False + point = [] + elif (d == "Q"): + command = "quadratic" + relative = False + smooth = False + point = [] + elif (d == "q"): + command = "quadratic" + relative = True + smooth = False + point = [] + elif (d == "S"): + command = "cubic" + relative = False + smooth = True + point = [] + elif (d == "s"): + command = "cubic" + relative = True + smooth = True + point = [] + elif (d == "T"): + command = "quadratic" + relative = False + smooth = True + point = [] + elif (d == "t"): + command = "quadratic" + relative = True + smooth = True point = [] else: try: @@ -485,6 +517,7 @@ class svgHandler(xml.sax.ContentHandler): firstvec = lastvec print "move ",lastvec command = "line" + lastpole = None point = [] elif (len(point)==2) and (command=="line"): if relative: @@ -496,6 +529,7 @@ class svgHandler(xml.sax.ContentHandler): print "line ",lastvec,currentvec lastvec = currentvec path.append(seg) + lastpole = None point = [] elif (len(point)==1) and (command=="horizontal"): if relative: @@ -505,6 +539,7 @@ class svgHandler(xml.sax.ContentHandler): currentvec = Vector(point[0],lasty,0) seg = Part.Line(lastvec,currentvec).toShape() lastvec = currentvec + lastpole = None path.append(seg) point = [] elif (len(point)==1) and (command=="vertical"): @@ -515,6 +550,7 @@ class svgHandler(xml.sax.ContentHandler): currentvec = Vector(lastx,-point[0],0) seg = Part.Line(lastvec,currentvec).toShape() lastvec = currentvec + lastpole = None path.append(seg) point = [] elif (len(point)==7) and (command=="arc"): @@ -539,6 +575,7 @@ class svgHandler(xml.sax.ContentHandler): midpoint = lastvec.add(chord.add(perp)) seg = Part.Arc(lastvec,midpoint,currentvec).toShape() lastvec = currentvec + lastpole = None path.append(seg) point = [] elif (command == "close"): @@ -574,12 +611,46 @@ class svgHandler(xml.sax.ContentHandler): print "straight segment" seg = Part.Line(lastvec,currentvec).toShape() else: - print "bezier segment" + print "cubic bezier segment" b = Part.BezierCurve() b.setPoles([lastvec,pole1,pole2,currentvec]) seg = b.toShape() print "connect ",lastvec,currentvec lastvec = currentvec + lastpole = ('cubic',pole2) + path.append(seg) + point = [] + + elif (command=="quadratic") and (((smooth==False) and (len(point)==4)) or (smooth==True and (len(point)==2))) : + if smooth: + if relative: + currentvec = lastvec.add(Vector(point[0],-point[1],0)) + else: + currentvec = Vector(point[0],-point[1],0) + if lastpole is not None and lastpole[0]=='quadratic': + pole1 = lastvec.sub(lastpole[1]).add(lastvec) + else: + pole1 = lastvec + else: #not smooth + if relative: + currentvec = lastvec.add(Vector(point[2],-point[3],0)) + pole1 = lastvec.add(Vector(point[0],-point[1],0)) + else: + currentvec = Vector(point[2],-point[3],0) + pole1 = Vector(point[0],-point[1],0) + + if not fcvec.equals(currentvec,lastvec): + if pole1.distanceToLine(lastvec,currentvec) < 10**(-1*Draft.precision()): + print "straight segment" + seg = Part.Line(lastvec,currentvec).toShape() + else: + print "quadratic bezier segment" + b = Part.BezierCurve() + b.setPoles([lastvec,pole1,currentvec]) + seg = b.toShape() + print "connect ",lastvec,currentvec + lastvec = currentvec + lastpole = ('quadratic',pole1) path.append(seg) point = [] @@ -749,7 +820,7 @@ def decodeName(name): try: decodedName = (name.decode("latin1")) except UnicodeDecodeError: - print "dxf: error: couldn't determine character encoding" + print "svg: error: couldn't determine character encoding" decodedName = name return decodedName