Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- import sys
- FREECADPATH = '/home/danfalck/cadcam/freecad/freecad1/lib'
- sys.path.append(FREECADPATH)
- import FreeCAD, Part, Drawing, importWebGL
- 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))
- Part.show(test)
- 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('test.html', 'w') as f:
- # f.write('<html>')
- # f.write('<body>')
- # 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>')
- # f.write('</html>')
- # f.write('</body>')
- def drawIt():
- result = ''
- result+='<html>'
- result+='<body>'
- result+='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="-100 -100 200 200">'
- result+= resultSVG
- result+= '</svg>'
- result+='</html>'
- result+='</body>'
- return result
- def drwsolid():
- solidlist = [test]
- result = ''
- result+= importWebGL.getHTML(solidlist)
- return result
Add Comment
Please, Sign In to add comment