コード例 #1
0
def entities2(filename):
    print('using modelspace()')
    return modelspace(filename)
コード例 #2
0
# License: MIT License
import time
from pathlib import Path
from collections import Counter
import ezdxf
from ezdxf.addons import iterdxf

DIR = Path('~/Desktop/Outbox').expanduser()
BIGFILE = Path(ezdxf.EZDXF_TEST_FILES) / 'GKB-R2010.dxf'
# BIGFILE = Path(ezdxf.EZDXF_TEST_FILES) / 'ACAD_R2000.dxf'

doc = ezdxf.new()
msp = doc.modelspace()

print('Modelspace Iterator:')
counter = Counter()
t0 = time.perf_counter()
for entity in iterdxf.modelspace(BIGFILE):
    counter[entity.dxftype()] += 1
    try:
        msp.add_foreign_entity(entity)
    except ezdxf.DXFValueError:
        pass

ta = time.perf_counter() - t0
print(f'Processing time: {ta:.2f}s')

print('Saving as ezdxf.dxf')
doc.saveas(DIR / 'ezdxf.dxf')

コード例 #3
0
tb = time.perf_counter() - t0
print(f'Processing time: {tb:.2f}s')
print(counter)
print()

name = 'iterdxf.single_pass_modelspace()'
print(f"{name}\n{len(name) * '-'}")
counter = Counter()
t0 = time.perf_counter()
for entity in iterdxf.single_pass_modelspace(open(BIGFILE, 'rb'),
                                             types=['LINE']):
    counter[entity.dxftype()] += 1

ta = time.perf_counter() - t0
print(f'Processing time: {ta:.2f}s')
print(counter)
print(f'Advantage {name}: {((tb / ta) - 1) * 100.:.0f}%\n')

name = 'iterdxf.modelspace()'
print(f"{name}\n{len(name) * '-'}")
counter = Counter()
t0 = time.perf_counter()
for entity in iterdxf.modelspace(BIGFILE, types=['LINE']):
    counter[entity.dxftype()] += 1

tc = time.perf_counter() - t0
print(f'Processing time: {tc:.2f}s')
print(counter)
print(f'Advantage {name}: {((tb / tc) - 1) * 100.:.0f}%\n')