Exemple #1
0
def merge(source, target):
    importer = Importer(source, target)
    # import all entities from source modelspace into target modelspace
    importer.import_modelspace()
    #importer.import_paperspace_layouts()
    # import all required resources and dependencies
    importer.finalize()
Exemple #2
0
 def model_importer(self,src_doc,target_doc):
     importer = Importer(src_doc,target_doc)
     names = []
     for i in src_doc.blocks:
         #print(i.name)
         names.append(i.name)
         importer.import_block(i.name)
     importer.finalize()
     return target_doc,names
def fixed_by_ezdxf(filename):
    new_filename = filename.replace(".dxf", ".fix.dxf")
    # The original file is only readable but not to fix!
    doc, auditor = recover.readfile(filename)
    # Create a new valid DXF document:
    doc2 = ezdxf.new()
    # Import data into new document:
    importer = Importer(doc, doc2)
    importer.import_modelspace()
    importer.finalize()
    doc2.saveas(new_filename)
    print(f'saved fixed DXF file "{new_filename}"')
def test_block_import(filename, tmpdir):
    source_dwg = ezdxf.readfile(filename)
    target_dwg = ezdxf.new(source_dwg.dxfversion)
    importer = Importer(source_dwg, target_dwg)
    importer.import_blocks(query='CustomBlock1')
    importer.import_modelspace_entities()
    filename = str(tmpdir.join('custom_blocks_import.dxf'))
    try:
        target_dwg.saveas(filename)
    except ezdxf.DXFError as e:
        pytest.fail("DXFError: {0} for DXF version {1}".format(
            str(e), target_dwg.dxfversion))
    assert os.path.exists(filename)
Exemple #5
0
 def import_dxf(self):
     path, _ = qw.QFileDialog.getOpenFileName(
         self,
         caption='Select CAD Document',
         filter='DXF Documents (*.dxf)')
     if path:
         incoming_dxf = ezdxf.readfile(path)
         importer = Importer(incoming_dxf,
                             self.controller.current_camo_file.dxf_doc)
         # import all entities from source modelspace into modelspace of the target drawing
         importer.import_modelspace()
         importer.finalize()
         self.set_document(self.controller.current_camo_file.dxf_doc)
         self.controller.build_file_tree_model()
Exemple #6
0
def import_msp_and_psp(source, target):
    importer = Importer(source, target)
    importer.import_modelspace()
    importer.import_paperspace_layouts()
    importer.finalize()
Exemple #7
0
def import_msp(source, target):
    importer = Importer(source, target)
    importer.import_modelspace()
    importer.finalize()