def make_text(text, location, alignment, height=1.0, rotation=0):
    text = Text.new(dxfattribs={
        "text": text,
        "height": height,
        "rotation": rotation,
    })
    text.set_placement(location, align=alignment)
    return text
def make_text(text, location, alignment, height=1.0, rotation=0):
    text = Text.new(dxfattribs={
        'text': text,
        'height': height,
        'rotation': rotation,
    })
    text.set_pos(location, align=alignment)
    return text
Exemple #3
0
 def query(self):
     return EntityQuery([
         Line.new(dxfattribs={
             "layer": "Lay1",
             "color": 1
         }),
         Text.new(dxfattribs={
             "layer": "Lay2",
             "color": 2
         }),
     ])
Exemple #4
0
 def base(self):
     return EntityQuery([
         Line.new(dxfattribs={
             "layer": "Lay_line",
             "color": 1
         }),
         Circle.new(dxfattribs={
             "layer": "lAy_circle",
             "center": Vec3(0, 0)
         }),
         Text.new(dxfattribs={"layer": "laY_text"}),
     ])
Exemple #5
0
def test_plain_text():
    assert plain_text('%%d') == '°'
    # underline
    assert plain_text('%%u') == ''
    assert plain_text('%%utext%%u') == 'text'
    # single %
    assert plain_text('%u%d%') == '%u%d%'
    t = Text.new(dxfattribs={'text': '45%%d'})
    assert t.plain_text() == '45°'

    assert plain_text('abc^a') == 'abc!'
    assert plain_text('abc^Jdef') == 'abcdef'
    assert plain_text('abc^@def') == 'abc\0def'
Exemple #6
0
 def base(self):
     return EntityQuery([
         Line.new(dxfattribs={
             "layer": "line",
             "color": 1
         }),
         Circle.new(dxfattribs={
             "layer": "circle",
             "color": 2
         }),
         Text.new(dxfattribs={
             "layer": "text",
             "color": 3
         }),
     ])
Exemple #7
0
 def test_union(self, base: EntityQuery):
     other = EntityQuery([
         Line.new(dxfattribs={
             "layer": "line",
             "color": 1
         }),
         Circle.new(dxfattribs={
             "layer": "circle",
             "color": 2
         }),
         Text.new(dxfattribs={
             "layer": "text",
             "color": 3
         }),
     ])
     assert len(base | other) == 6
Exemple #8
0
def test_plain_text():
    assert plain_text("%%C") == "Ø"  # alt-0216
    assert plain_text("%%D") == "°"  # alt-0176
    assert plain_text("%%P") == "±"  # alt-0177
    # underline
    assert plain_text("%%u") == ""
    assert plain_text("%%utext%%u") == "text"
    # overline
    assert plain_text("%%o") == ""
    # strike through
    assert plain_text("%%k") == ""

    # single %
    assert plain_text("%u%d%") == "%u%d%"
    t = Text.new(dxfattribs={"text": "45%%d"})
    assert t.plain_text() == "45°"

    assert plain_text("abc^a") == "abc!"
    assert plain_text("abc^Jdef") == "abcdef"
    assert plain_text("abc^@def") == "abc\0def"
Exemple #9
0
def test_plain_text():
    assert plain_text('%%C') == 'Ø'  # alt-0216
    assert plain_text('%%D') == '°'  # alt-0176
    assert plain_text('%%P') == '±'  # alt-0177
    # underline
    assert plain_text('%%u') == ''
    assert plain_text('%%utext%%u') == 'text'
    # overline
    assert plain_text('%%o') == ''
    # strike through
    assert plain_text('%%k') == ''

    # single %
    assert plain_text('%u%d%') == '%u%d%'
    t = Text.new(dxfattribs={'text': '45%%d'})
    assert t.plain_text() == '45°'

    assert plain_text('abc^a') == 'abc!'
    assert plain_text('abc^Jdef') == 'abcdef'
    assert plain_text('abc^@def') == 'abc\0def'
    def text(num):
        height = 1.0
        width = 1.0
        p1 = Vector(0, 0, 0)

        t = Text.new(
            dxfattribs={
                'text':
                content.format(num),  # should easily show reflexion errors
                'height': height,
                'width': width,
                'rotation': 0,
                'layer': 'text',
            },
            doc=doc)
        t.set_pos(p1, align='LEFT')
        tlen = height * len(t.dxf.text) * width
        p2 = p1.replace(x=tlen)
        p3 = p2.replace(y=height)
        p4 = p1.replace(y=height)
        v = [p1, p2, p3, p4, p3.lerp(p4), p2.lerp(p3)]
        return t, v
    def text(num):
        height = 1.0
        width = 1.0
        p1 = Vec3(0, 0, 0)

        t = Text.new(
            dxfattribs={
                "text":
                content.format(num),  # should easily show reflexion errors
                "height": height,
                "width": width,
                "rotation": 0,
                "layer": "text",
            },
            doc=doc,
        )
        t.set_pos(p1, align="LEFT")
        tlen = height * len(t.dxf.text) * width
        p2 = p1.replace(x=tlen)
        p3 = p2.replace(y=height)
        p4 = p1.replace(y=height)
        v = [p1, p2, p3, p4, p3.lerp(p4), p2.lerp(p3)]
        return t, v
Exemple #12
0
 def test_greater_equal_raises_type_error_for_vector_attributes(self):
     query = EntityQuery([Text.new(dxfattribs={"insert": Vec3(0, 0)})])
     with pytest.raises(TypeError):
         _ = query["insert"] >= (1, 0)
Exemple #13
0
 def entities(self):
     return EntityQuery([
         MText.new(
             dxfattribs={"text": "content"}),  # virtual text attribute
         Text.new(dxfattribs={"text": "content"})
     ])