def spline_insert_knot(): dwg = ezdxf.new('R2000', setup=True) msp = dwg.modelspace() def add_spline(control_points, color=3, knots=None): msp.add_polyline2d(control_points, dxfattribs={ 'color': color, 'linetype': 'DASHED' }) msp.add_open_spline(control_points, degree=3, knots=knots, dxfattribs={'color': color}) control_points = Vector.list([(0, 0), (10, 20), (30, 10), (40, 10), (50, 0), (60, 20), (70, 50), (80, 70)]) add_spline(control_points, color=3, knots=None) bspline = BSpline(control_points, order=4) bspline.insert_knot(bspline.max_t / 2) add_spline(bspline.control_points, color=4, knots=bspline.knot_values()) if dwg.validate(): dwg.saveas("Spline_R2000_spline_insert_knot.dxf")
def test_bspline_insert_knot(): bspline = BSpline([(0, 0), (10, 20), (30, 10), (40, 10), (50, 0), (60, 20), (70, 50), (80, 70)]) t = bspline.max_t / 2 assert len(bspline.control_points) == 8 bspline.insert_knot(t) assert len(bspline.control_points) == 9
def spline_insert_knot(): doc = ezdxf.new("R2000", setup=True) msp = doc.modelspace() def add_spline(control_points, color=3, knots=None): msp.add_polyline2d(control_points, dxfattribs={ "color": color, "linetype": "DASHED" }) msp.add_open_spline(control_points, degree=3, knots=knots, dxfattribs={"color": color}) control_points = Vec3.list([ (0, 0), (10, 20), (30, 10), (40, 10), (50, 0), (60, 20), (70, 50), (80, 70), ]) add_spline(control_points, color=3, knots=None) bspline = BSpline(control_points, order=4) bspline.insert_knot(bspline.max_t / 2) add_spline(bspline.control_points, color=4, knots=bspline.knots()) doc.saveas("Spline_R2000_spline_insert_knot.dxf")