# -*- coding: utf-8 -*-
# Macro for initializing Path Job and setting tool and feed rate

import FreeCAD
import PathScripts.PathJob as PathJob
import PathScripts.PathLoadTool as PathLoadTool
import Path


# create Path Job
myjob = FreeCAD.ActiveDocument.addObject("Path::FeatureCompoundPython", "Job")
PathJob.ObjectPathJob(myjob)

# get first drawing object and set it as job.Base:
objs = FreeCAD.ActiveDocument.Objects
firstobj = objs[0]
myjob.Base=firstobj

# Create tool
tool = Path.Tool()
tool.Diameter = 3.0
tool.Name = str(tool.Diameter)+"mm mill"
tool.CuttingEdgeHeight = 15.0
tool.ToolType = "EndMill"
tool.Material = "HighSpeedSteel"

# Load tool:
PathLoadTool.CommandPathLoadTool.Create(myjob.Name)
myjob.Tooltable.addTools(tool)
tl = myjob.Group[0]
tl.ToolNumber = 1

# set feed rates
tl.HorizFeed=200
tl.VertFeed = 200
tl.HorizRapid = 300
tl.VertRapid = 500

tl.SpindleSpeed = 10000.00

myjob.X_Max= 400
myjob.Y_Max= 300
myjob.Z_Max= 50
myjob.Z_Min= -80

myjob.UsePlacements = True
myjob.PostProcessor = u"linuxcnc"

# eventually activate GUI edit tool
## myjob.ViewObject.Proxy.deleteOnReject = True
## myjob.ViewObject.startEditing()
# close GUI window

# activate Path workbench:
# Gui.activateWorkbench("PathWorkbench")


