Exemplo n.º 1
0
def circle(radius=1, count=16):
    circle_ = Circle.new(dxfattribs={
        'center': (0, 0, 0),
        'radius': radius
    },
                         doc=doc)
    control_vertices = list(circle_.vertices(linspace(0, 360, count)))
    return circle_, control_vertices
Exemplo n.º 2
0
def test_from_circle_with_zero_radius():
    from ezdxf.entities import Circle
    circle = Circle.new(dxfattribs={
        'center': (1, 0, 0),
        'radius': 0,
    })
    path = Path.from_circle(circle)
    assert len(path) == 0
Exemplo n.º 3
0
def test_from_circle(radius):
    from ezdxf.entities import Circle
    circle = Circle.new(dxfattribs={
        'center': (1, 0, 0),
        'radius': radius,
    })
    path = Path.from_circle(circle)
    assert path.start == (2, 0)
    assert path.end == (2, 0)
    assert path.is_closed is True
Exemplo n.º 4
0
 def base(self):
     return EntityQuery([
         Line.new(dxfattribs={
             "layer": "Lay_line",
             "color": 1
         }),
         Circle.new(dxfattribs={
             "layer": "lAy_circle",
             "center": Vec3(0, 0)
         }),
         Text.new(dxfattribs={"layer": "laY_text"}),
     ])
    def test_unit_circle(self):
        from ezdxf.entities import Circle

        # create unit circle
        circle: Circle = Circle.new(dxfattribs={
            "center": (0, 0),
            "radius": 1.0
        })
        cp = ConstructionPolyline(circle.flattening(0.01))
        assert cp.is_closed is True
        assert len(cp) > 20
        assert abs(cp.length - math.tau) < 0.02
Exemplo n.º 6
0
 def base(self):
     return EntityQuery([
         Line.new(dxfattribs={
             "layer": "line",
             "color": 1
         }),
         Circle.new(dxfattribs={
             "layer": "circle",
             "color": 2
         }),
         Text.new(dxfattribs={
             "layer": "text",
             "color": 3
         }),
     ])
Exemplo n.º 7
0
def test_from_circle():
    from ezdxf.entities import Circle
    spline = Spline.from_arc(Circle.new(dxfattribs={
        'center': (1, 1),
        'radius': 2,
        'layer': 'circle',
    }))
    assert spline.dxf.handle is None
    assert spline.dxf.owner is None
    assert spline.dxf.layer == 'circle'
    assert spline.dxf.degree == 2
    assert len(spline.control_points) > 2
    assert len(spline.weights) > 2
    assert len(spline.fit_points) == 0
    assert len(spline.knots) == required_knot_values(len(spline.control_points), spline.dxf.degree + 1)
Exemplo n.º 8
0
 def test_union(self, base: EntityQuery):
     other = EntityQuery([
         Line.new(dxfattribs={
             "layer": "line",
             "color": 1
         }),
         Circle.new(dxfattribs={
             "layer": "circle",
             "color": 2
         }),
         Text.new(dxfattribs={
             "layer": "text",
             "color": 3
         }),
     ])
     assert len(base | other) == 6
Exemplo n.º 9
0
 def entities(self):
     return EntityQuery([
         Line.new(
             handle="ABBA",
             dxfattribs={
                 "layer": "line",
                 "color": 1,
                 "linetype": "SOLID",
                 "lineweight": 18,
             },
         ),
         Circle.new(
             handle="FEFE",
             dxfattribs={
                 "layer": "circle",
                 "color": 2,
                 "linetype": "DOT",
                 "lineweight": 25,
             },
         ),
     ])
Exemplo n.º 10
0
def circle():
    return Circle.new(dxfattribs={
        "center": (3, 4),
        "radius": 2.0,
        "extrusion": (0, 0, -1)
    })