def test_get_pass_through_ocs(): line = Line.new(dxfattribs={ "start": (0, 0, 0), "end": (1, 0, 0), "extrusion": (0, 0, -1), }) ocs = line.ocs() assert ocs.to_wcs((0, 0, 0)) == (0, 0, 0) assert ocs.to_wcs((1, 0, 0)) == (1, 0, 0)
def test_translation(): line = Line.new(dxfattribs={ "start": (0, 0, 0), "end": (1, 0, 0), "extrusion": (0, 1, 0), }) line.translate(1, 2, 3) assert line.dxf.start == (1, 2, 3) assert line.dxf.end == (2, 2, 3)
def test_translation(): line = Line.new(dxfattribs={ 'start': (0, 0, 0), 'end': (1, 0, 0), 'extrusion': (0, 1, 0) }) line.translate(1, 2, 3) assert line.dxf.start == (1, 2, 3) assert line.dxf.end == (2, 2, 3)
def test_line_to_code(): from ezdxf.entities.line import Line entity = Line.new(handle='ABBA', owner='0', dxfattribs={ 'color': '7', 'start': (1, 2, 3), 'end': (4, 5, 6), }) new_entity = translate_to_code_and_execute(entity) for name in ('color', 'start', 'end'): assert new_entity.get_dxf_attrib(name) == entity.get_dxf_attrib(name)
def test_scaling(): line = Line.new( dxfattribs={ "start": (0, 0, 0), "end": (1, 0, 0), "extrusion": (0, 1, 0), "thickness": 2, }) m = Matrix44.scale(2, 2, 0) line.transform(m) assert line.dxf.start == (0, 0, 0) assert line.dxf.end == (2, 0, 0) assert line.dxf.extrusion == (0, 1, 0) assert line.dxf.thickness == 4
def test_scaling(): line = Line.new( dxfattribs={ 'start': (0, 0, 0), 'end': (1, 0, 0), 'extrusion': (0, 1, 0), 'thickness': 2 }) m = Matrix44.scale(2, 2, 0) line.transform(m) assert line.dxf.start == (0, 0, 0) assert line.dxf.end == (2, 0, 0) assert line.dxf.extrusion == (0, 1, 0) assert line.dxf.thickness == 4
def test_rotation(): line = Line.new(dxfattribs={ "start": (0, 0, 0), "end": (1, 0, 0), "extrusion": (0, 1, 0), }) angle = math.pi / 4 m = Matrix44.z_rotate(angle) line.transform(m) assert line.dxf.start == (0, 0, 0) assert line.dxf.end.isclose((math.cos(angle), math.sin(angle), 0), abs_tol=1e-9) assert line.dxf.extrusion.isclose((-math.cos(angle), math.sin(angle), 0), abs_tol=1e-9) assert line.dxf.thickness == 0
def test_line_to_code(): from ezdxf.entities.line import Line entity = Line.new( handle="ABBA", owner="0", dxfattribs={ "color": "7", "start": (1, 2, 3), "end": (4, 5, 6), }, ) new_entity = translate_to_code_and_execute(entity) for name in ("color", "start", "end"): assert new_entity.get_dxf_attrib(name) == entity.get_dxf_attrib(name)
def test_default_new(): entity = Line.new(handle='ABBA', owner='0', dxfattribs={ 'color': '7', 'start': (1, 2, 3), 'end': (4, 5, 6), }) assert entity.dxf.layer == '0' assert entity.dxf.color == 7 assert entity.dxf.start == (1, 2, 3) assert entity.dxf.start.x == 1, 'is not Vector compatible' assert entity.dxf.start.y == 2, 'is not Vector compatible' assert entity.dxf.start.z == 3, 'is not Vector compatible' assert entity.dxf.end == (4, 5, 6) assert entity.dxf.extrusion == (0.0, 0.0, 1.0) assert entity.dxf.hasattr('extrusion') is False, 'just the default value' # can set DXF R2007 value entity.dxf.shadow_mode = 1 assert entity.dxf.shadow_mode == 1
def test_transform(): line = Line.new(dxfattribs={ "start": (0, 0, 0), "end": (1, 0, 0), "extrusion": (0, 1, 0), }) m = Matrix44.translate(1, 2, 3) line.transform(m) # simple 3D entity - no OCS transformation, assert line.dxf.start == (1, 2, 3) assert line.dxf.end == (2, 2, 3) # extrusion direction without translation - not an OCS extrusion vector! assert line.dxf.extrusion == (0, 1, 0) # Create new entity by transformation: new_line = line.copy() new_line.transform(m) assert new_line.dxf.start == (2, 4, 6) assert new_line.dxf.end == (3, 4, 6) assert new_line.dxf.extrusion == (0, 1, 0)
def test_default_new(): entity = Line.new( handle="ABBA", owner="0", dxfattribs={ "color": "7", "start": (1, 2, 3), "end": (4, 5, 6), }, ) assert entity.dxf.layer == "0" assert entity.dxf.color == 7 assert entity.dxf.start == (1, 2, 3) assert entity.dxf.start.x == 1, "is not Vec3 compatible" assert entity.dxf.start.y == 2, "is not Vec3 compatible" assert entity.dxf.start.z == 3, "is not Vec3 compatible" assert entity.dxf.end == (4, 5, 6) assert entity.dxf.extrusion == (0.0, 0.0, 1.0) assert entity.dxf.hasattr("extrusion") is False, "just the default value" # can set DXF R2007 value entity.dxf.shadow_mode = 1 assert entity.dxf.shadow_mode == 1