|
|
|
@ -41,6 +41,7 @@ class Kuka_Prog: |
|
|
|
self.inert_gas_out = 9 |
|
|
|
self.inert_gas_out = 9 |
|
|
|
self.powder_out = 7 |
|
|
|
self.powder_out = 7 |
|
|
|
self.simulation = True |
|
|
|
self.simulation = True |
|
|
|
|
|
|
|
self.label = "REPLACEME" |
|
|
|
|
|
|
|
|
|
|
|
def set_baseorigin(self, vec): |
|
|
|
def set_baseorigin(self, vec): |
|
|
|
self.baseorigin = (vec.x, vec.y, vec.z) |
|
|
|
self.baseorigin = (vec.x, vec.y, vec.z) |
|
|
|
@ -71,6 +72,9 @@ class Kuka_Prog: |
|
|
|
else: |
|
|
|
else: |
|
|
|
self.use_laser_out = self.laser_pilot_out |
|
|
|
self.use_laser_out = self.laser_pilot_out |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def set_label(self, label): |
|
|
|
|
|
|
|
self.label = label |
|
|
|
|
|
|
|
|
|
|
|
def create_layer(self): |
|
|
|
def create_layer(self): |
|
|
|
self.layers.append(Kuka_Layer()) |
|
|
|
self.layers.append(Kuka_Layer()) |
|
|
|
self.current_layer += 1 |
|
|
|
self.current_layer += 1 |
|
|
|
@ -84,6 +88,7 @@ class Kuka_Prog: |
|
|
|
layer = self.layers[self.current_layer] |
|
|
|
layer = self.layers[self.current_layer] |
|
|
|
if not len(layer.hatchlines): |
|
|
|
if not len(layer.hatchlines): |
|
|
|
layer.hatchlines.append((line, segmenttype)) |
|
|
|
layer.hatchlines.append((line, segmenttype)) |
|
|
|
|
|
|
|
return |
|
|
|
# poses are sorted |
|
|
|
# poses are sorted |
|
|
|
# but maybe we need to reverse |
|
|
|
# but maybe we need to reverse |
|
|
|
# get the point distance from first and last pose |
|
|
|
# get the point distance from first and last pose |
|
|
|
@ -110,12 +115,14 @@ class Kuka_Prog: |
|
|
|
return [FreeCAD.Base.Vector(p.X, p.Y, p.Z) for p in poses for poses in self.contour_path_list ] |
|
|
|
return [FreeCAD.Base.Vector(p.X, p.Y, p.Z) for p in poses for poses in self.contour_path_list ] |
|
|
|
|
|
|
|
|
|
|
|
def save_with_template(self, article, path, templatename): |
|
|
|
def save_with_template(self, article, path, templatename): |
|
|
|
|
|
|
|
if article[0].isdigit(): |
|
|
|
|
|
|
|
article = "_"+article |
|
|
|
if self.simulation: |
|
|
|
if self.simulation: |
|
|
|
filename_src = "kvt_{}_sim.src".format(article) |
|
|
|
filename_src = "{}_sim.src".format(article) |
|
|
|
filename_dat = "kvt_{}_sim.dat".format(article) |
|
|
|
filename_dat = "{}_sim.dat".format(article) |
|
|
|
else: |
|
|
|
else: |
|
|
|
filename_src = "kvt_{}.src".format(article) |
|
|
|
filename_src = "{}.src".format(article) |
|
|
|
filename_dat = "kvt_{}.dat".format(article) |
|
|
|
filename_dat = "{}.dat".format(article) |
|
|
|
|
|
|
|
|
|
|
|
user_dir = FreeCAD.getUserAppDataDir() |
|
|
|
user_dir = FreeCAD.getUserAppDataDir() |
|
|
|
template_dir = os.path.join(user_dir, "Mod", "fc_lasercladding_wb", "freecad", "LaserCladdingWorkbench", "templates") |
|
|
|
template_dir = os.path.join(user_dir, "Mod", "fc_lasercladding_wb", "freecad", "LaserCladdingWorkbench", "templates") |
|
|
|
@ -152,26 +159,40 @@ class Kuka_Prog: |
|
|
|
# end of subroutine |
|
|
|
# end of subroutine |
|
|
|
|
|
|
|
|
|
|
|
f.write(";- =============================\n") |
|
|
|
f.write(";- =============================\n") |
|
|
|
f.write(";- Hatchlines\n") |
|
|
|
if len(layer.hatchlines): |
|
|
|
f.write("$VEL.CP = TRAVELSPEED ; m/s ; m/s \n") |
|
|
|
print("Number Hatchlines: ", len(layer.hatchlines)) |
|
|
|
f.write("LIN_REL {Z 90.0} C_VEL; just move up \n") |
|
|
|
f.write(";- Hatchlines\n") |
|
|
|
(line, seg_type) = layer.hatchlines[0] |
|
|
|
f.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) |
|
|
|
f.write("LIN refpose:{}:{} C_VEL; move to first hatch point but with z_up\n".format(line[0].translate_with(self.baseorigin).to_string(), z_up_pose)) |
|
|
|
f.write("LIN_REL {Z 90.0} C_VEL; just move up \n") |
|
|
|
for (line, seg_type) in layer.hatchlines: |
|
|
|
for (line, seg_type) in layer.hatchlines: |
|
|
|
# start laser code |
|
|
|
# a line has many segments |
|
|
|
f.write(";- Hatchline\n") |
|
|
|
# start laser at first segment |
|
|
|
if seg_type == 'LIN': |
|
|
|
# stop with last |
|
|
|
f.write("$VEL.CP = TRAVELSPEED ;m/s \n") |
|
|
|
f.write(";- Hatchline\n") |
|
|
|
f.write("LIN refpose:{} C_VEL; GENERATED\n".format(line[0].translate_with(self.baseorigin).to_string())) |
|
|
|
segment = line[0] |
|
|
|
f.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=TRUE; Turn on Laser at point \n" % self.use_laser_out) |
|
|
|
f.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) |
|
|
|
f.write("$VEL.CP = WELDSPEED ; m/s \n") |
|
|
|
f.write("LIN {}:{} C_VEL; move to first hatch point but with z_up\n".format(segment.translate_with(self.baseorigin).to_string(), z_up_pose)) |
|
|
|
f.write("LIN refpose:{} C_VEL; GENERATED\n".format(line[1].translate_with(self.baseorigin).to_string())) |
|
|
|
# One Hatchline |
|
|
|
|
|
|
|
f.write(";- First Point in line \n") |
|
|
|
|
|
|
|
f.write("LIN {} C_VEL; GENERATED\n".format(segment.translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
f.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=True; Turn on Laser at point \n" % self.use_laser_out) |
|
|
|
|
|
|
|
# each segment |
|
|
|
|
|
|
|
for segment in line[1:-1]: |
|
|
|
|
|
|
|
f.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vproc) |
|
|
|
|
|
|
|
f.write("LIN {} C_VEL; GENERATED\n".format(segment.translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
segment = line[-1] |
|
|
|
|
|
|
|
f.write(";- Last Point in line \n") |
|
|
|
|
|
|
|
f.write("LIN {} C_VEL; GENERATED\n".format(segment.translate_with(self.baseorigin).to_string())) |
|
|
|
f.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=FALSE; Turn off Laser at point\n" % self.use_laser_out) |
|
|
|
f.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=FALSE; Turn off Laser at point\n" % self.use_laser_out) |
|
|
|
|
|
|
|
f.write(";- End line \n") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
f.write(";- ========= END LAYER =========\n") |
|
|
|
f.write(";- ========= END LAYER =========\n") |
|
|
|
f.write(";- =============================\n") |
|
|
|
f.write(";- =============================\n") |
|
|
|
# end of subroutine |
|
|
|
# end of subroutine |
|
|
|
|
|
|
|
|
|
|
|
content = template_src.render( |
|
|
|
content = template_src.render( |
|
|
|
|
|
|
|
simulation=self.simulation, |
|
|
|
artikel=article, |
|
|
|
artikel=article, |
|
|
|
tool=self.tool, |
|
|
|
tool=self.tool, |
|
|
|
base=self.base, |
|
|
|
base=self.base, |
|
|
|
@ -181,12 +202,14 @@ class Kuka_Prog: |
|
|
|
laserpower=self.laser_power, |
|
|
|
laserpower=self.laser_power, |
|
|
|
vproc=self.vproc, |
|
|
|
vproc=self.vproc, |
|
|
|
vmax=self.vmax, |
|
|
|
vmax=self.vmax, |
|
|
|
paths=f.getvalue() |
|
|
|
paths=f.getvalue(), |
|
|
|
|
|
|
|
label=self.label |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# dat template |
|
|
|
# dat template |
|
|
|
template_dat = environment.get_template(templatename+".dat") |
|
|
|
template_dat = environment.get_template(templatename+".dat") |
|
|
|
datcontent = template_dat.render( |
|
|
|
datcontent = template_dat.render( |
|
|
|
|
|
|
|
simulation=self.simulation, |
|
|
|
artikel=article |
|
|
|
artikel=article |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
@ -295,18 +318,25 @@ class Kuka_Prog: |
|
|
|
srcfile.write(";- Hatchlines\n") |
|
|
|
srcfile.write(";- Hatchlines\n") |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) |
|
|
|
srcfile.write("LIN_REL {Z 90.0} C_VEL; just move up \n") |
|
|
|
srcfile.write("LIN_REL {Z 90.0} C_VEL; just move up \n") |
|
|
|
(line, seg_type) = layer.hatchlines[0] |
|
|
|
|
|
|
|
srcfile.write("LIN {}:{} C_VEL; move to first hatch point but with z_up\n".format(line[0].translate_with(self.baseorigin).to_string(), z_up_pose)) |
|
|
|
|
|
|
|
for (line, seg_type) in layer.hatchlines: |
|
|
|
for (line, seg_type) in layer.hatchlines: |
|
|
|
# start laser code |
|
|
|
# a line has many segments |
|
|
|
|
|
|
|
# start laser at first segment |
|
|
|
|
|
|
|
# stop with last |
|
|
|
|
|
|
|
segment = line[0] |
|
|
|
|
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) |
|
|
|
|
|
|
|
srcfile.write("LIN {}:{} C_VEL; move to first hatch point but with z_up\n".format(segment.translate_with(self.baseorigin).to_string(), z_up_pose)) |
|
|
|
|
|
|
|
# One Hatchline |
|
|
|
srcfile.write(";- Hatchline\n") |
|
|
|
srcfile.write(";- Hatchline\n") |
|
|
|
if seg_type == 'LIN': |
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(segment.translate_with(self.baseorigin).to_string())) |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vmax) |
|
|
|
srcfile.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=True; Turn on Laser at point \n" % self.use_laser_out) |
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(line[0].translate_with(self.baseorigin).to_string())) |
|
|
|
# each segment |
|
|
|
srcfile.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=True; Turn on Laser at point \n" % self.use_laser_out) |
|
|
|
for segment in line[1:-1]: |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vproc) |
|
|
|
srcfile.write("$VEL.CP = %f ; m/s ; m/s \n" % self.vproc) |
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(line[1].translate_with(self.baseorigin).to_string())) |
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(segment.translate_with(self.baseorigin).to_string())) |
|
|
|
srcfile.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=FALSE; Turn off Laser at point\n" % self.use_laser_out) |
|
|
|
segment = line[-1] |
|
|
|
|
|
|
|
srcfile.write("LIN {} C_VEL; GENERATED\n".format(segment.translate_with(self.baseorigin).to_string())) |
|
|
|
|
|
|
|
srcfile.write("TRIGGER WHEN DISTANCE=0 DELAY=0 DO $OUT[%d]=FALSE; Turn off Laser at point\n" % self.use_laser_out) |
|
|
|
|
|
|
|
|
|
|
|
srcfile.write(";- ========= END LAYER =========\n") |
|
|
|
srcfile.write(";- ========= END LAYER =========\n") |
|
|
|
srcfile.write(";- =============================\n") |
|
|
|
srcfile.write(";- =============================\n") |
|
|
|
# end of subroutine |
|
|
|
# end of subroutine |
|
|
|
|