Advertisement
danfalck

multiDXFoutpu.py

Dec 8th, 2012
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. import Drawing,FreeCAD
  2. from FreeCAD import Vector
  3.  
  4. filename = "/home/danfalck/Documents/freecad/testview3.dxf"#change the file name and directory here
  5. FILE = open(filename,"w")
  6. sel = FreeCADGui.Selection.getSelection()
  7. page = sel[0]
  8. views = page.OutList
  9.  
  10. fileout = "0\nSECTION\n2\nENTITIES\n"
  11.  
  12. for v in views:
  13.     shape = v.Source.Shape.copy()
  14.  
  15.     if v.Direction.z == 1:
  16.         shape.rotate(Vector(0,0,0),Vector(0,0,1),v.Rotation)
  17.     else:
  18.         shape.rotate(Vector(0,0,0),Vector(v.Direction),90.0)
  19.         if v.Direction.x == 0:
  20.             tx = float(v.X/v.Scale); ty = float(0)
  21.             shape.translate(Vector(tx,ty,0))
  22.         else:
  23.             tx = float(0); ty = float(v.Y/v.Scale)
  24.             shape.translate(Vector(tx,ty,0))
  25.  
  26.     fileout+= Drawing.projectToDXF(shape,Vector(0,0,1))
  27.     del shape
  28.  
  29. fileout+="0\nENDSEC\n0\nEOF\n"
  30. FILE.write(fileout)
  31. FILE.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement