示例#1
0
def test_packed_points_advanced():
    packed_points, _ = LWPolylinePoints.from_tags(lwtags(LWPOLYLINE1))
    packed_points.append((5, 5, 1, 2, 3))
    assert len(packed_points) == 3
    assert packed_points[-1] == (5, 5, 1, 2, 3)
    packed_points[0] = (7, 7, 0, 0, 0)
    assert packed_points[0] == (7, 7, 0, 0, 0)
    assert len(packed_points) == 3
    packed_points.clear()
    assert len(packed_points) == 0
示例#2
0
def test_packed_points_to_dxf_tags_with_bulge():
    packed_points, _ = LWPolylinePoints.from_tags(lwtags(LWPOLYLINE1))
    packed_points[0] = (-.5, -.5, 0, 0, 1)
    packed_points[1] = (.5, .5, .1, .2, -1)
    tags = list(packed_points.dxftags())
    assert len(tags) == 6
    assert tags[0] == (10, (-.5, -.5))
    assert tags[1] == (42, 1)
    assert tags[2] == (10, (.5, .5))
    assert tags[3] == (40, .1)
    assert tags[4] == (41, .2)
    assert tags[5] == (42, -1)
示例#3
0
def test_packed_points_basics():
    packed_points, _ = LWPolylinePoints.from_tags(lwtags(LWPOLYLINE1))
    assert len(packed_points) == 2
    points = list(packed_points)
    assert len(points) == 2
    assert packed_points[0] == (-.5, -.5, 0, 0, 0)
    assert packed_points[1] == (.5, .5, 0, 0, 0)
    # test negative index
    assert packed_points[-1] == (.5, .5, 0, 0, 0)
    with pytest.raises(IndexError):
        packed_points[-3]
    with pytest.raises(IndexError):
        packed_points[2]
示例#4
0
def test_packed_points_to_dxf_tags():
    packed_points, _ = LWPolylinePoints.from_tags(lwtags(LWPOLYLINE1))
    tags = list(packed_points.dxftags())
    assert len(tags) == 2  # just the points
    assert tags[0] == (10, (-.5, -.5))
    assert tags[1] == (10, (.5, .5))