Beispiel #1
0
def test_virtual_sub_entities():
    point = Point()
    entities = list(point.virtual_entities())
    assert len(entities) == 1
    e = entities[0]
    assert e.is_copy is True
    assert e.source_of_copy is point
Beispiel #2
0
def test_fast_translation():
    point = Point.new(dxfattribs={
        'location': (2, 3, 4),
        'extrusion': (0, 1, 0),
        'thickness': 2
    })
    point.translate(1, 2, 3)
    assert point.dxf.location == (3, 5, 7)
Beispiel #3
0
def test_point_to_code():
    from ezdxf.entities.point import Point
    entity = Point.new(handle='ABBA', owner='0', dxfattribs={
        'color': '7',
        'location': (1, 2, 3),
    })
    new_entity = translate_to_code_and_execute(entity)
    for name in ('color', 'location'):
        assert new_entity.get_dxf_attrib(name) == entity.get_dxf_attrib(name)
Beispiel #4
0
def test_fast_translation():
    point = Point.new(
        dxfattribs={
            "location": (2, 3, 4),
            "extrusion": (0, 1, 0),
            "thickness": 2,
        }
    )
    point.translate(1, 2, 3)
    assert point.dxf.location == (3, 5, 7)
Beispiel #5
0
def test_point_to_code():
    from ezdxf.entities.point import Point

    entity = Point.new(
        handle="ABBA",
        owner="0",
        dxfattribs={
            "color": "7",
            "location": (1, 2, 3),
        },
    )
    new_entity = translate_to_code_and_execute(entity)
    for name in ("color", "location"):
        assert new_entity.get_dxf_attrib(name) == entity.get_dxf_attrib(name)
Beispiel #6
0
def test_transform():
    point = Point.new(dxfattribs={
        'location': (2, 3, 4),
        'extrusion': (0, 1, 0),
        'thickness': 2
    })
    # 1. rotation - 2. scaling - 3. translation
    m = Matrix44.chain(Matrix44.scale(2, 3, 1), Matrix44.translate(1, 1, 1))
    point.transform(m)
    assert point.dxf.location == (5, 10, 5)
    assert point.dxf.extrusion == (0, 1, 0)
    assert point.dxf.thickness == 6

    angle = math.pi / 4
    point.transform(Matrix44.z_rotate(math.pi / 4))
    assert point.dxf.extrusion.isclose((-math.cos(angle), math.sin(angle), 0))
    assert math.isclose(point.dxf.thickness, 6)
Beispiel #7
0
def test_do_not_explode_point_entity():
    point = Point()
    with pytest.raises(TypeError):
        explode_entity(point)