- 
                Notifications
    
You must be signed in to change notification settings  - Fork 383
 
Description
 Issue by huskier
Friday Nov 18, 2016 at 05:59 GMT
Originally opened as dcowden/cadquery#155
The idea is that we could store some useful sketches in data files( maybe a special formatted file), and we could re-use them. The sketchlet function could parse the special formatted files or just strings, and draw them.
With sketchlet function, we could significantly simplify the example "Panel With Various Connector Holes", and make the code elegant.
The following code is just a simple demo, no any parsing function. The current problem is that we could only add one complete wire into the sketchlet wire, otherwise Wire.assembleEdges complaint that "command not done". In the following code, I commented the second circle code.
`
def sketchlet(self):
    def makeSketchletWire(pnt):
        p0 = pnt
        p1 = p0.add(Vector(-23.5,0,0))
        e1 = Edge.makeCircle(1.6,p1)
        #p2 = p0.add(Vector(23.5,0,0))
        #e2 = Edge.makeCircle(1.6,p2)
        listOfEdges = []
        listOfEdges.append(e1)
        #listOfEdges.append(e2)
        sketchWire = Wire.assembleEdges(listOfEdges)
        sketchWire.forConstruction = False
        return sketchWire       
    return self.eachpoint(makeSketchletWire, useLocalCoordinates=True)
To call sketchlet:
result = cadquery.Workplane("XY").pushPoints( [ (25, 25),(50, 50)] ).sketchlet().extrude(50)
show(result)
`