Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- FREECADPATH = '/home/danfalck/cadcam/freecadcam/dancam6/freecad/lib'
- sys.path.append(FREECADPATH)
- import FreeCAD, Part, Drawing
- #dv = 0.000000000001
- box = Part.makeBox(100,100,100)
- box.translate(box.CenterOfMass.multiply(-1))
- cylx = Part.makeCylinder(25, 100, FreeCAD.Base.Vector(0,1,0), FreeCAD.Base.Vector(0,90,0))
- cylx.translate(cylx.CenterOfMass.multiply(-1))
- cyly = Part.makeCylinder(25, 100, FreeCAD.Base.Vector(0,1,0), FreeCAD.Base.Vector(90,0,0))
- cyly.translate(cyly.CenterOfMass.multiply(-1))
- cylz = Part.makeCylinder(25, 100)
- cylz.translate(cylz.CenterOfMass.multiply(-1))
- hole = cylx.fuse(cyly).fuse(cylz)
- test = box.cut(hole).common(Part.makeSphere(50))
- #with open('coin.iv', 'w') as f:
- # f.write(test.writeInventor())
- Part.show(test)
- # FreeCAD.ActiveDocument.FileName = 'foo.fcstd'
- # FreeCAD.ActiveDocument.save()
- Shape = FreeCAD.ActiveDocument.Shape.Shape
- visibleG0,visibleG1,hiddenG0,hiddenG1 = Drawing.project(Shape,FreeCAD.Base.Vector(1,1,1))
- resultSVG = Drawing.projectToSVG(Shape,FreeCAD.Base.Vector(1,0.2,1))
- # if 0 is used instead of dv, the image is rendered incorrectly
- #resultSVG = Drawing.projectToSVG(Shape,FreeCAD.Base.Vector(0,dv,1))
- with open('foo.svg', 'w') as f:
- f.write('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-100 -100 200 200">')
- f.write(resultSVG)
- f.write('</svg>')
Add Comment
Please, Sign In to add comment