Exemplo n.º 1
0
 def test_virtual_entities_to_all_types_at_once(self, text):
     entities = text2path.virtual_entities(
         text, kind=Kind.HATCHES + Kind.SPLINES + Kind.LWPOLYLINES)
     types = {e.dxftype() for e in entities}
     assert types == {'LWPOLYLINE', 'SPLINE', 'POLYLINE', 'HATCH'}
Exemplo n.º 2
0
 def test_virtual_entities_as_lwpolylines(self, text):
     entities = text2path.virtual_entities(text, kind=Kind.LWPOLYLINES)
     types = {e.dxftype() for e in entities}
     assert types == {'LWPOLYLINE'}
Exemplo n.º 3
0
 def test_virtual_entities_as_hatches(self, text):
     entities = text2path.virtual_entities(text, kind=Kind.HATCHES)
     types = {e.dxftype() for e in entities}
     assert types == {'HATCH'}
Exemplo n.º 4
0
 def test_virtual_entities_as_splines_and_polylines(self, text):
     entities = text2path.virtual_entities(text, kind=Kind.SPLINES)
     types = {e.dxftype() for e in entities}
     assert types == {'SPLINE', 'POLYLINE'}
Exemplo n.º 5
0
EXAMPLES = Path(__file__).parent.parent.parent / 'examples_dxf'
OUTBOX = Path('~/Desktop/Outbox').expanduser()
FILE1 = "text_mirror_true_type_font.dxf"
FILE2 = "text_oblique_rotate.dxf"

FILE = FILE2
doc = ezdxf.readfile(EXAMPLES / FILE)
doc.layers.new('OUTLINE', dxfattribs={'color': 1})
doc.layers.new('BBOX', dxfattribs={'color': 5})
msp = doc.modelspace()
text_entities = msp.query('TEXT')

# Convert TEXT entities into SPLINE and POLYLINE entities:
kind = text2path.Kind.SPLINES
for text in text_entities:
    for e in text2path.virtual_entities(text, kind=kind):
        e.dxf.layer = 'OUTLINE'
        e.dxf.color = const.BYLAYER
        msp.add_entity(e)

# Add bounding boxes
attrib = {'layer': 'BBOX'}
boxes = []

# The "primitive" representation for TEXT entities is the bounding box:
for prim in disassemble.to_primitives(text_entities):
    p = msp.add_lwpolyline(prim.vertices(), dxfattribs=attrib)
    boxes.append(p)

# Zoom on bounding boxes (fast):
zoom.objects(msp, boxes,factor=1.1)