I want to simulate the carving with a chisel. So I wrote this below. But I think there must be a better way to get it. Thanks!
import rhinoscriptsyntax as rs
#Create a function for carving with rectangle.
def trianglecarving():
#Create a sketch curve on a surf.
commandsketch = "_Sketch"
curve = rs.Command(commandsketch, False)
if not curve: return
new_curve01 = rs.LastCreatedObjects(select=True)
#Create a triangle surrounding the curve.
#Creat the plane for the rectangle
if new_curve01:
plane = rs.CurvePerpFrame(new_curve01[0], 0)
#Creat the triangle
rectangle01 = rs.AddRectangle( plane, 3.0, 0.5)
if rectangle01:
#Mirror the rectangle and then create the rectangle
plane1 = rs.ViewCPlane()
xform = rs.XformMirror(plane1.Origin, plane1.Normal)
rectangle02 = rs.TransformObjects(rectangle01, xform, True )
if rectangle02:
explodedCurves = rs.ExplodeCurves([rectangle02], True)
curve0 = rs.FirstObject()
curve1 = rs.NextObject(curve0)
curve2 = rs.NextObject(curve1)
curve3 = rs.NextObject(curve2)
pointstart = rs.CurveStartPoint(curve3)
pointend = rs.CurveEndPoint(curve3)
point01 = rs.AddPoint(pointstart)
point02 = rs.AddPoint(pointend)
midpoint = rs.CurveMidPoint(curve1)
point03 = rs.AddPoint(midpoint)
trianglepolyline = rs.AddPolyline([point01,point02,point03,point01])
if trianglepolyline:
surface = rs.AddPlanarSrf(trianglepolyline)
#Extrude the triangle prism
triangleprism = rs.ExtrudeSurface(surface, new_curve01)
if triangleprism:
rs.DeleteObjects([rectangle01,trianglepolyline,new_curve01,surface,curve0,curve1,curve2,curve3,point01,point02,point03])
#Boolean the box
input0 = rs.LastObject()
input1 = rs.FirstObject()
rs.BooleanDifference(input0, input1)
if( __name__ == "__main__" ):
#Call the function
trianglecarving()
trianglecarving-L3W1.py (2.0 KB)