diff --git a/src/Mod/Draft/importDXF.py b/src/Mod/Draft/importDXF.py index 2222f20e1d..8baee72332 100644 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -1927,11 +1927,24 @@ def addObject(shape, name="Shape", layer=None): if layer: lay = locateLayer(layer) # For old style layers, which are just groups - if hasattr(lay, "addObject"): - lay.addObject(newob) + if hasattr(lay, "Group"): + pass # For new Draft Layers - elif hasattr(lay, "Proxy") and hasattr(lay.Proxy, "addObject"): - lay.Proxy.addObject(lay, newob) + elif hasattr(lay, "Proxy") and hasattr(lay.Proxy, "Group"): + lay = lay.Proxy + else: + lay = None + + if lay != None: + if lay not in layerObjects: + l = [] + layerObjects[lay] = l + else: + l = layerObjects[lay] + l.append(newob) + + + formatObject(newob) return newob @@ -2227,6 +2240,8 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True): badobjects = [] global layerBlocks layerBlocks = {} + global layerObjects + layerObjects = {} sketch = None shapes = [] @@ -2724,6 +2739,10 @@ def processdxf(document, filename, getShapes=False, reComputeFlag=True): formatObject(newob, insert) num += 1 + # Move layer contents to layers + for (l, contents) in layerObjects.items(): + l.Group += contents + # Make blocks, if any if dxfMakeBlocks: print("creating layerblocks...")