Skip to content

Instantly share code, notes, and snippets.

@egradman
Created August 11, 2015 06:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egradman/c47767b3254b63e31b80 to your computer and use it in GitHub Desktop.
Save egradman/c47767b3254b63e31b80 to your computer and use it in GitHub Desktop.
"""
quick and dirty rhino script to "hole-out" an inner convex angle so an end-mill can carve it
see:
http://www.kontraptionist.com/post/45218053861/slotted-construction-its-a-pretty-nice-thing-to
for the technique it implements
to use it:
- choose a cplane orthogonal to the face
- run the script
- select the object
- select an inside point clockwise of the corner
- select the corner
- select an inside point counterclockwise of the corner
"""
import rhinoscriptsyntax as rs
from collections import defaultdict
from collections import Iterable
import Rhino
def main():
diameter = 3.0/8.0 * 1.1
# first, select objects in three orthogonal planes
obj = rs.GetObject("select object", filter=16) # polysurface
points = rs.GetPoints(draw_lines=False, max_points=3, base_point=None)
rs.VectorUnitize(rs.VectorSubtract(points[0], points[1]))
angle = rs.Angle2(
(points[1], points[0]),
(points[1], points[2]),
)
print angle
angle = angle[0]
point = rs.VectorAdd(
points[1],
rs.VectorRotate(0.5*diameter*rs.VectorUnitize(rs.VectorSubtract(points[2], points[1])), angle/2, (0,0,1))
)
p0 = (point.X, point.Y, point.Z + 1000)
p1 = (point.X, point.Y, point.Z - 1000)
diameter = rs.GetReal("enter cutter diameter", number=3.0/8.0*1.1)
circle = rs.AddCircle(p0, diameter/2.0)
rs.EnableRedraw(False)
extrusion = rs.ExtrudeCurveStraight(circle, p0, p1)
rs.BooleanDifference(obj, extrusion, delete_input=True)
rs.DeleteObject(circle)
rs.EnableRedraw(True)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment