Resolving bugs and rebasing for 0.21 merge

This commit is contained in:
sliptonic
2022-06-19 13:35:59 -05:00
parent f94aecad70
commit 8dad6cf84d
4 changed files with 31 additions and 151 deletions

View File

@@ -159,8 +159,13 @@ class PathWorkbench(Workbench):
if PathPreferences.advancedOCLFeaturesEnabled():
try:
subprocess.call(["camsim", "-v"])
toolcmdlist.append("Path_Camotics")
r = subprocess.run(
["camotics", "--version"], capture_output=True, text=True
).stderr.strip()
major, minor, patch = r.split(".")
if int(major) >= 1 and int(minor) >= 2 and int(patch) >= 2:
# subprocess.call(["camsim", "-v"])
toolcmdlist.append("Path_Camotics")
except FileNotFoundError:
pass
@@ -276,8 +281,8 @@ class PathWorkbench(Workbench):
msg = translate(
"Path",
"The currently selected unit schema: \n '{}'\n Does not use 'minutes' for velocity values. \n \nCNC machines require feed rate to be expressed in \nunit/minute. To ensure correct gcode: \nSelect a minute-based schema in preferences.\nFor example:\n 'Metric, Small Parts & CNC'\n 'US Customary'\n 'Imperial Decimal'"
).format(current_schema)
"The currently selected unit schema: \n '{}'\n Does not use 'minutes' for velocity values. \n \nCNC machines require feed rate to be expressed in \nunit/minute. To ensure correct gcode: \nSelect a minute-based schema in preferences.\nFor example:\n 'Metric, Small Parts & CNC'\n 'US Customary'\n 'Imperial Decimal'",
).format(current_schema)
header = translate("Path", "Warning")
msgbox = QtGui.QMessageBox(QtGui.QMessageBox.Warning, header, msg)

View File

@@ -20,30 +20,20 @@
# * *
# ***************************************************************************
from PySide.QtCore import QT_TRANSLATE_NOOP
from threading import Thread, Lock
import FreeCAD
import FreeCADGui
import PathScripts.PathLog as PathLog
from PySide.QtCore import QT_TRANSLATE_NOOP
# from pivy import coin
# from itertools import cycle
# import FreeCADGui as Gui
import json
# import tempfile
import os
import Mesh
# import string
# import random
import camotics
import PathScripts.PathPost as PathPost
import io
# import time
import PathScripts
import PathScripts.PathLog as PathLog
import PathScripts.PathPost as PathPost
import camotics
import io
import json
import os
import queue
from threading import Thread, Lock
import subprocess
from PySide import QtCore, QtGui
@@ -216,42 +206,24 @@ class CamoticsSimulation(QtCore.QObject):
success = True
finalgcode = ""
if self.job.SplitOutput:
PathLog.track(postlist)
for idx, section in enumerate(postlist):
# split = os.path.splitext(self.filename)
# partname = split[0] + "_{}".format(index) + split[1]
partname = section[0]
sublist = section[1]
for idx, section in enumerate(postlist):
partname = section[0]
sublist = section[1]
result, gcode, name = PathPost.CommandPathPost().exportObjectsWith(
sublist,
partname,
self.job,
idx,
extraargs="--no-show-editor",
)
self.filenames.append(name)
PathLog.track(result, gcode, name)
if result is None:
success = False
else:
finalgcode += gcode
else:
finalpostlist = [item for slist in postlist for item in slist]
PathLog.track(postlist)
result, gcode, name = PathPost.CommandPathPost().exportObjectsWith(
finalpostlist,
"allitems",
sublist,
partname,
self.job,
0,
idx,
extraargs="--no-show-editor",
)
self.filenames.append(name)
success = result is not None
finalgcode = gcode
PathLog.track(result, gcode, name)
if result is None:
success = False
else:
finalgcode += gcode
if not success:
return
@@ -273,102 +245,6 @@ class CamoticsSimulation(QtCore.QObject):
def cancel(self):
pass
# def makeCoinMesh(self, surface):
# # this doesn't work yet
# sg = Gui.ActiveDocument.ActiveView.getSceneGraph();
# color = coin.SoBaseColor()
# color.rgb = (1, 0, 1)
# coords = coin.SoTransform()
# node = coin.SoSeparator()
# node.addChild(color)
# node.addChild(coords)
# end = [-1]
# vertices = list(zip(*[iter(surface['vertices'])] * 3))
# #polygons = list(zip(*[iter(vertices)] * 3, cycle(end)))
# polygons = list(zip(*[iter(range(len(vertices)))] * 3, cycle(end)))
# print(vertices)
# print(polygons)
# data=coin.SoCoordinate3()
# face=coin.SoIndexedFaceSet()
# node.addChild(data)
# node.addChild(face)
# i = 0
# for v in vertices:
# data.point.set1Value(i, v[0], v[1], v[2])
# i += 1
# i = 0
# for p in polygons:
# try:
# face.coordIndex.set1Value(i, p)
# i += 1
# except Exception as e:
# print(e)
# print(i)
# print(p)
# sg.addChild(node)
# def Activated(self):
# s = self.SIM
# print('activated')
# print (s.is_running())
# if s.is_running():
# print('interrupted')
# s.interrupt()
# s.wait()
# else:
# try:
# surface = s.get_surface('python')
# except Exception as e:
# print(e)
# pp = CommandPathPost()
# job = FreeCADGui.Selection.getSelectionEx()[0].Object
# s = camotics.Simulation()
# s.set_metric()
# s.set_resolution('high')
# bb = job.Stock.Shape.BoundBox
# s.set_workpiece(min = (bb.XMin, bb.YMin, bb.ZMin), max = (bb.XMax, bb.YMax, bb.ZMax))
# shapemap = {'ballend': 'Ballnose',
# 'endmill': 'Cylindrical',
# 'v-bit' : 'Conical',
# 'chamfer': 'Snubnose'}
# for t in job.Tools.Group:
# s.set_tool(t.ToolNumber,
# metric = True,
# shape = shapemap.get(t.Tool.ShapeName, 'Cylindrical'),
# length = t.Tool.Length.Value,
# diameter = t.Tool.Diameter.Value)
# gcode = job.Path.toGCode() #temporary solution!!!!!
# s.compute_path(gcode)
# s.wait()
# print(s.get_path())
# tot = sum([step['time'] for step in s.get_path()])
# print(tot)
# for t in range(1, int(tot), int(tot/10)):
# print(t)
# s.start(callback, time=t)
# while s.is_running():
# time.sleep(0.1)
# s.wait()
# surface = s.get_surface('binary')
# self.addMesh(surface)
def buildproject(self): # , files=[]):
PathLog.track()

View File

@@ -42,7 +42,7 @@ from PySide.QtCore import QT_TRANSLATE_NOOP
LOG_MODULE = PathLog.thisModule()
if False:
if True:
PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule())
PathLog.trackModule(PathLog.thisModule())
else:

View File

@@ -206,7 +206,6 @@ class TestBuildPostList(unittest.TestCase):
self.job.OrderOutputBy = "Operation"
def test010(self):
# check that function returns correct hash
postlist = PathPost.buildPostList(self.job)
self.assertTrue(type(postlist) is list)