def test_solid_reorder_quad_ocs_vertices(): solid = Solid() for index, vertex in enumerate([(0, 0), (1, 0), (0, 1), (1, 1)]): solid[index] = vertex # reorder weird vertex order: assert solid.vertices() == [(0, 0), (1, 0), (1, 1), (0, 1)]
def test_solid_close_quad_ocs_vertices(): solid = Solid() for index, vertex in enumerate([(0, 0), (1, 0), (1, 1), (0, 1)]): solid[index] = vertex assert solid.vertices(close=True) == [ (0, 0), (1, 0), (0, 1), (1, 1), (0, 0), ]
def test_solid_to_code(): from ezdxf.entities.solid import Solid entity = Solid.new(handle='ABBA', owner='0', dxfattribs={ 'vtx0': (1, 2, 3), 'vtx1': (4, 5, 6), 'vtx2': (7, 8, 9), 'vtx3': (3, 2, 1), }) new_entity = translate_to_code_and_execute(entity) for name in ('vtx0', 'vtx1', 'vtx2', 'vtx3'): assert new_entity.get_dxf_attrib(name) == entity.get_dxf_attrib(name)
def test_solid_to_code(): from ezdxf.entities.solid import Solid entity = Solid.new( handle="ABBA", owner="0", dxfattribs={ "vtx0": (1, 2, 3), "vtx1": (4, 5, 6), "vtx2": (7, 8, 9), "vtx3": (3, 2, 1), }, ) new_entity = translate_to_code_and_execute(entity) for name in ("vtx0", "vtx1", "vtx2", "vtx3"): assert new_entity.get_dxf_attrib(name) == entity.get_dxf_attrib(name)
def test_do_not_write_elevation_group_code(): solid = Solid.from_text(ELEVATION) collector = TagCollector(dxfversion=DXF12) solid.export_dxf(collector) # Elevation tag should be written: assert any(tag[0] == 38 for tag in collector.tags) is False
def test_elevation_group_code_support(): solid = Solid.from_text(ELEVATION) # elevation data is copied to z-axis of vertices: assert solid.dxf.hasattr('elevation') is False vertices = solid.vertices() assert vertices[0] == (0, 0, 2)
def test_solid_triangle_ocs_vertices(): solid = Solid() for index, vertex in enumerate([(0, 0), (1, 0), (0, 1), (0, 1)]): solid[index] = vertex assert solid.vertices() == [(0, 0), (1, 0), (0, 1)]
def test_solid_translate(): solid = Solid() solid.dxf.vtx1 = (3, 3, 0) solid.translate(1, 1, 0) assert solid.dxf.vtx1 == (4, 4, 0)