I believe I’ve searched all of the forum for this but didn’t find it. If this has been done already please let me know.
I laser cut a lot of small wood laser parts and I want them to stay attached to the board so that they don’t get lost. The client can then tear them from the board easily, like cardboard parts for a new boardgame. To do that I create “tabs” which are small pauses (~0,5mm) in the laser cutting path. See here for an example : Applying tabs in laser drawing
The way I do this is by creating a circle on the path, and using the trim command to cut what is inside the circle, then delete it.
I wish we had an “eraser tool” with a specified width, so that by simply clicking and moving the mouse over a curve, it would delete a portion of this with a specified width. I’m thinking Sketch/Offset and cap/Trim.
Is there any easy way to do this?
See below an exemple of a tabbed laser cutting path.
import Rhino
import scriptcontext as sc
import rhinoscriptsyntax as rs
def reparameterize_curve_to_length():
curve_id = rs.GetObject("Select a curve to reparameterize", rs.filter.curve)
if not curve_id: return
curve = rs.coercecurve(curve_id)
# Reparameterize curve to its length
length = curve.GetLength()
if length:
domain = Rhino.Geometry.Interval(0, length)
curve.Domain = domain
rs.Redraw()
return curve_id
def pick_points_and_trim_curve(curve_id):
points = rs.GetPoints()
if not points: return
w = 10
w_half = w / 2.0
curve = rs.coercecurve(curve_id)
# Trim intervals around each point
params_to_trim = []
for point in points:
param = curve.ClosestPoint(point)
if param:
params_to_trim.append(param[1] - w_half)
params_to_trim.append(param[1] + w_half)
params_to_trim.sort()
trimmed_curves = curve.Split(params_to_trim)
if trimmed_curves:
rs.DeleteObject(curve_id) # Remove original curve
for seg in trimmed_curves:
if seg.GetLength() > w:
sc.doc.Objects.AddCurve(seg) # Add back valid segments
sc.doc.Views.Redraw()
def main():
curve_id = reparameterize_curve_to_length()
if curve_id:
pick_points_and_trim_curve(curve_id)
if __name__ == "__main__":
main()