def test_default_new():
    entity = Spline.new(
        handle="ABBA",
        owner="0",
        dxfattribs={
            "color": 7,
            "flags": 4,
            "degree": 4,
            "knot_tolerance": 42,
            "control_point_tolerance": 43,
            "fit_tolerance": 44,
            "start_tangent": (1, 2, 3),
            "end_tangent": (4, 5, 6),
            "extrusion": (7, 8, 9),
        },
    )
    assert entity.dxf.layer == "0"
    assert entity.dxf.color == 7
    assert entity.dxf.flags == 4
    assert entity.dxf.degree == 4
    assert entity.dxf.knot_tolerance == 42
    assert entity.dxf.control_point_tolerance == 43
    assert entity.dxf.fit_tolerance == 44
    assert entity.dxf.start_tangent == (1, 2, 3)
    assert entity.dxf.end_tangent == (4, 5, 6)
    assert entity.dxf.extrusion == (7, 8, 9)
Exemple #2
0
def test_spline_to_code():
    from ezdxf.entities.spline import Spline

    entity = Spline.new(
        handle="ABBA",
        owner="0",
        dxfattribs={
            "color": "7",
            "degree": 3,
        },
    )
    entity.fit_points = [(1, 2, 0), (4, 3, 0), (7, 8, 0)]
    entity.control_points = [(1, 2, 0), (4, 3, 0), (7, 8, 0)]
    entity.knots = [1, 2, 3, 4, 5, 6, 7]
    entity.weights = [1.0, 2.0, 3.0]
    new_entity = translate_to_code_and_execute(entity)
    for name in (
            "color",
            "n_knots",
            "n_control_points",
            "n_fit_points",
            "degree",
    ):
        assert new_entity.get_dxf_attrib(name) == entity.get_dxf_attrib(name)

    assert new_entity.knots == entity.knots
    assert new_entity.control_points.values == entity.control_points.values
    assert new_entity.fit_points.values == entity.fit_points.values
    assert new_entity.weights == entity.weights
Exemple #3
0
def test_spline_to_code():
    from ezdxf.entities.spline import Spline
    entity = Spline.new(handle='ABBA', owner='0', dxfattribs={
        'color': '7',
        'degree': 3,
    })
    entity.fit_points = [(1, 2, 0), (4, 3, 0), (7, 8, 0)]
    entity.control_points = [(1, 2, 0), (4, 3, 0), (7, 8, 0)]
    entity.knots = [1, 2, 3, 4, 5, 6, 7]
    entity.weights = [1., 2., 3.]
    new_entity = translate_to_code_and_execute(entity)
    for name in ('color', 'n_knots', 'n_control_points', 'n_fit_points', 'degree'):
        assert new_entity.get_dxf_attrib(name) == entity.get_dxf_attrib(name)

    assert new_entity.knots == entity.knots
    assert new_entity.control_points.values == entity.control_points.values
    assert new_entity.fit_points.values == entity.fit_points.values
    assert new_entity.weights == entity.weights
Exemple #4
0
def test_default_new():
    entity = Spline.new(handle='ABBA', owner='0', dxfattribs={
        'color': 7,
        'flags': 4,
        'degree': 4,
        'knot_tolerance': 42,
        'control_point_tolerance': 43,
        'fit_tolerance': 44,
        'start_tangent': (1, 2, 3),
        'end_tangent': (4, 5, 6),
        'extrusion': (7, 8, 9),

    })
    assert entity.dxf.layer == '0'
    assert entity.dxf.color == 7
    assert entity.dxf.flags == 4
    assert entity.dxf.degree == 4
    assert entity.dxf.knot_tolerance == 42
    assert entity.dxf.control_point_tolerance == 43
    assert entity.dxf.fit_tolerance == 44
    assert entity.dxf.start_tangent == (1, 2, 3)
    assert entity.dxf.end_tangent == (4, 5, 6)
    assert entity.dxf.extrusion == (7, 8, 9)