1

I'm using matplotlib to preview the carving path for my CNC router.

The path is a series of X, Y, and Z coordinates describing where the router bit moves.

I'm rendering the path as a series of line segments, but this is inaccurate because of the router's circular bit. For example, if your path is a square, the outside of your path is a rounded rectangle.

Is there an easy way to render my path as a continuous series of circles?

2
  • David Beazley gave a talk on using Python to control a CNC mill. Commented Dec 15, 2014 at 0:22
  • I got nice results using shapely, see this answer Commented Dec 15, 2014 at 6:46

2 Answers 2

2

Perhaps use solid_capstyle='round':

import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.axes3d as axes3d
import numpy as np
x = np.linspace(0, 6, 10)
y = np.sin(x)
z = x

fig = plt.figure()
ax = fig.add_subplot(1, 1, 1, projection='3d')

ax.plot(x, y, z
         , linestyle='-'
         , linewidth=20
         , marker='o'
         , markersize=20
         , solid_capstyle='round'
)
ax.set_xlim3d(-1, 7)
ax.set_ylim3d(-2, 2)
ax.set_zlim3d(-1, 7)
plt.show()

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

0

What I would try to do, and I'm not saying this is the best way but I would make a function that maps a large amount of circles using the radius of your bit sizes as the diameter of the cirle. And the circles are related as an x and y coordinate that follows the route of your bit. You can fill in the circles to make it somewhat a line. Depending on how large or small you make a circle or a line you can approximate it for your CNC machine on python.

http://matplotlib.org/api/path_api.html?highlight=circle#matplotlib.path.Path.circle

classmethod circle(center=(0.0, 0.0), radius=1.0, readonly=False)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.