Advertisement
danfalck

parsePath_for_CL.py

Jan 18th, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.06 KB | None | 0 0
  1. # parsing FreeCAD Path Objects
  2.  
  3. import FreeCAD
  4. import FreeCADGui as Gui
  5.  
  6. obj = Gui.Selection.getSelection()[0] #select the PathProject
  7.  
  8. outlist = ""
  9.  
  10. for g in obj.Group:
  11.     if hasattr(g, "Fixture"):
  12.     if g.TypeId == "Path::FeatureCompound":
  13.         for c in g.Path.Commands:
  14.             if c.Name == "M6":
  15.                 outlist +="LOADTL/"+ str(int(c.Parameters['T']))+ "\n"
  16.             if (c.Name == "G0") or (c.Name == "G1"):
  17.                 if (c.Name == "G0"):
  18.                     outlist +="RAPID\n"
  19.                 outlist +="GOTO/"
  20.                 if 'X' in c.Parameters:
  21.                     outlist +='X'+ str(c.Parameters['X'])
  22.                 if 'Y' in c.Parameters:
  23.                     outlist +='Y'+ str(c.Parameters['Y'])
  24.                 if 'Z' in c.Parameters:
  25.                     outlist +='Z'+ str(c.Parameters['Z'])
  26.                 outlist +='\n'
  27.             elif (c.Name == "G2") or (c.Name == "G3"):
  28.                 outlist +="CIRCLE/"
  29.                 outlist +='\n'
  30.  
  31.  
  32. lines = outlist.split("\n")
  33. for l in lines:
  34.     print l
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement