示例#1
0
def test_2d_polyline_has_default_width():
    assert Polyline().has_width is False
    assert (Polyline.new(dxfattribs={
        "default_start_width": 0.1
    }).has_width is True)
    assert Polyline.new(dxfattribs={
        "default_end_width": 0.1
    }).has_width is True
示例#2
0
def test_polyline3d_transform_interface():
    pline = Polyline.new(dxfattribs={"flags": 8})
    pline.append_vertices([(0, 0, 0), (2, 0, 0), (1, 1, 0)])
    pline.translate(1, 1, 1)
    vertices = list(v.dxf.location for v in pline.vertices)
    assert pline.is_3d_polyline is True
    assert vertices[0] == (1, 1, 1)
    assert vertices[1] == (3, 1, 1)
    assert vertices[2] == (2, 2, 1)
示例#3
0
def test_default_new():
    entity = Polyline.new(handle='ABBA', owner='0', dxfattribs={
        'color': '7',
    })
    assert entity.dxf.layer == '0'
    assert entity.dxf.color == 7
    assert entity.dxf.linetype == 'BYLAYER'
    # can set DXF R2007 value
    entity.dxf.shadow_mode = 1
    assert entity.dxf.shadow_mode == 1
示例#4
0
def test_write_dxf(txt, ver):
    expected = basic_tags_from_text(txt)
    polyline = Polyline.from_text(txt)
    collector = TagCollector(dxfversion=ver, optional=True)
    polyline.export_dxf(collector)
    assert collector.tags == expected

    collector2 = TagCollector(dxfversion=ver, optional=False)
    polyline.export_dxf(collector2)
    assert collector.has_all_tags(collector2)
示例#5
0
def test_default_new():
    entity = Polyline.new(
        handle="ABBA",
        owner="0",
        dxfattribs={
            "color": "7",
        },
    )
    assert entity.dxf.layer == "0"
    assert entity.dxf.color == 7
    assert entity.dxf.linetype == "BYLAYER"
    # can set DXF R2007 value
    entity.dxf.shadow_mode = 1
    assert entity.dxf.shadow_mode == 1
示例#6
0
def test_polyline2d_transform_interface():
    pline = Polyline()
    pline.append_vertices([(0, 0, 0), (2, 0, 0), (1, 1, 0)])
    pline.translate(1, 1, 1)
    vertices = list(v.dxf.location for v in pline.vertices)
    assert pline.is_2d_polyline is True
    assert vertices[0] == (1, 1, 1)
    assert vertices[1] == (3, 1, 1)
    assert vertices[2] == (2, 2, 1)
    assert pline.dxf.elevation == (0, 0, 1)
    assert Vec3(0, 0, 1).isclose(pline.dxf.extrusion)
示例#7
0
def test_poly_face_mesh():
    polyline = Polyline.new(dxfattribs={"flags": Polyline.POLYFACE})
    collector = TagCollector(dxfversion="R2000", optional=True)
    polyline.export_dxf(collector)
    assert (100, "AcDbPolyFaceMesh") == collector.tags[5]
示例#8
0
def test_polyline_3d():
    polyline = Polyline.new(dxfattribs={"flags": Polyline.POLYLINE_3D})
    collector = TagCollector(dxfversion="R2000", optional=True)
    polyline.export_dxf(collector)
    assert (100, "AcDb3dPolyline") == collector.tags[5]
示例#9
0
def test_default_constructor():
    entity = Polyline()
    assert entity.dxftype() == "POLYLINE"
    assert entity.is_virtual is True
    assert entity.seqend is None, "SEQEND must not exist"
示例#10
0
def entity(request):
    return Polyline.from_text(request.param)
示例#11
0
def test_malformed_polyline():
    entity = Polyline.from_text(MALFORMED_POLYLINE)
    assert entity.dxf.layer == "LY_EZDXF"
    assert entity.dxf.linetype == "LT_EZDXF"
    assert entity.dxf.color == 7
    assert entity.dxf.elevation.isclose((0, 0, 99))
示例#12
0
def test_2d_polyline_has_any_arc():
    pline = Polyline()
    assert pline.has_arc is False
    pline.append_formatted_vertices([(0, 0, 1.0)], format="xyb")
    assert pline.has_arc is True
示例#13
0
def test_2d_polyline_has_any_end_width():
    pline = Polyline()
    pline.append_formatted_vertices([(0, 0, 0.1)], format="xye")
    assert pline.has_width is True
示例#14
0
def test_polygon_mesh():
    polyline = Polyline.new(dxfattribs={'flags': Polyline.POLYMESH})
    collector = TagCollector(dxfversion='R2000', optional=True)
    polyline.export_dxf(collector)
    assert (100, 'AcDbPolygonMesh') == collector.tags[5]
示例#15
0
def test_2d_polyline_has_default_width():
    assert Polyline.new().has_width is False
    assert Polyline.new(dxfattribs={
        'default_start_width': .1
    }).has_width is True
    assert Polyline.new(dxfattribs={'default_end_width': .1}).has_width is True
示例#16
0
def test_polyline_3d():
    polyline = Polyline.new(dxfattribs={'flags': Polyline.POLYLINE_3D})
    collector = TagCollector(dxfversion='R2000', optional=True)
    polyline.export_dxf(collector)
    assert (100, 'AcDb3dPolyline') == collector.tags[5]
示例#17
0
def test_2d_polyline_has_any_start_width():
    pline = Polyline.new()
    pline.append_formatted_vertices([(0, 0, .1)], format='xys')
    assert pline.has_width is True