コード例 #1
0
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
コード例 #2
0
ファイル: test_814_text2path.py プロジェクト: yanbin-ha/ezdxf
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
コード例 #3
0
 def query(self):
     return EntityQuery([
         Line.new(dxfattribs={
             "layer": "Lay1",
             "color": 1
         }),
         Text.new(dxfattribs={
             "layer": "Lay2",
             "color": 2
         }),
     ])
コード例 #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"}),
     ])
コード例 #5
0
ファイル: test_514_text.py プロジェクト: yening2020/ezdxf
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'
コード例 #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
         }),
     ])
コード例 #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
コード例 #8
0
ファイル: test_514_text.py プロジェクト: Rahulghuge94/ezdxf
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"
コード例 #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'
コード例 #10
0
    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
コード例 #11
0
    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
コード例 #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)
コード例 #13
0
 def entities(self):
     return EntityQuery([
         MText.new(
             dxfattribs={"text": "content"}),  # virtual text attribute
         Text.new(dxfattribs={"text": "content"})
     ])