Path projects. Ideally, the user could execute these utilities from an icon to make sure tools are selected and configured and defaults have been revised''' from __future__ import print_function from PySide import QtCore import FreeCAD import FreeCADGui import PathScripts import PathScripts.PathLog as PathLog # import PathScripts.PathCollision as PC # Qt tanslation handling def translate(context, text, disambig=None): return QtCore.QCoreApplication.translate(context, text, disambig) LOG_MODULE = 'PathSanity' PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE) #PathLog.trackModule('PathSanity') class CommandPathSanity: baseobj=None def GetResources(self): return {'Pixmap' : 'Path-Sanity', 'MenuText': QtCore.QT_TRANSLATE_NOOP("Path_Sanity","Check the Path project for common errors"), 'Accel': "P, S", 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Path_Sanity","Check the Path Project for common errors")} def IsActive(self): obj = FreeCADGui.Selection.getSelectionEx()[0].Object if hasattr(obj, 'Operations') and hasattr(obj, 'ToolController'):
import Part import Path import PathScripts.PathDressup as PathDressup import PathScripts.PathLog as PathLog import PathScripts.PathUtil as PathUtil import PathScripts.PathUtils as PathUtils from PathScripts.PathGeom import PathGeom from PySide import QtCore, QtGui """Dogbone Dressup object and FreeCAD command""" LOG_MODULE = PathLog.thisModule() if False: PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE) # Qt tanslation handling def translate(context, text, disambig=None): return QtCore.QCoreApplication.translate(context, text, disambig) movecommands = ['G0', 'G00', 'G1', 'G01', 'G2', 'G02', 'G3', 'G03'] movestraight = ['G1', 'G01'] movecw = ['G2', 'G02'] moveccw = ['G3', 'G03'] movearc = movecw + moveccw def debugMarker(vector, label, color=None, radius=0.5): if PathLog.getLevel(LOG_MODULE) == PathLog.Level.DEBUG:
import Draft import math import Part # from PathScripts.PathUtils import waiting_effects from PySide import QtCore if FreeCAD.GuiUp: import FreeCADGui __title__ = "Base class for PathArea based operations." __author__ = "sliptonic (Brad Collette)" __url__ = "http://www.freecadweb.org" __doc__ = "Base class and properties for Path.Area based operations." LOGLEVEL = PathLog.Level.INFO PathLog.setLevel(LOGLEVEL, PathLog.thisModule()) if LOGLEVEL is PathLog.Level.DEBUG: PathLog.trackModule() # Qt translation handling def translate(context, text, disambig=None): return QtCore.QCoreApplication.translate(context, text, disambig) class ObjectOp(PathOp.ObjectOp): '''Base class for all Path.Area based operations. Provides standard features including debugging properties AreaParams, PathParams and removalshape, all hidden. The main reason for existence is to implement the standard interface to Path.Area so subclasses only have to provide the shapes for the
import PathScripts.PathUtil as PathUtil import PathScripts.PathUtils as PathUtils import time # lazily loaded modules from lazy_loader.lazy_loader import LazyLoader Part = LazyLoader("Part", globals(), "Part") __title__ = "Base class for all operations." __author__ = "sliptonic (Brad Collette)" __url__ = "https://www.freecadweb.org" __doc__ = "Base class and properties implementation for all Path operations." if False: PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) PathLog.trackModule(PathLog.thisModule()) else: PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) translate = FreeCAD.Qt.translate FeatureTool = 0x0001 # ToolController FeatureDepths = 0x0002 # FinalDepth, StartDepth FeatureHeights = 0x0004 # ClearanceHeight, SafeHeight FeatureStartPoint = 0x0008 # StartPoint FeatureFinishDepth = 0x0010 # FinishDepth FeatureStepDown = 0x0020 # StepDown FeatureNoFinalDepth = 0x0040 # edit or not edit FinalDepth FeatureBaseVertexes = 0x0100 # Base FeatureBaseEdges = 0x0200 # Base
# * * # *************************************************************************** from __future__ import print_function import FreeCAD #from FreeCAD import Vector import Path import PathScripts.PathLog as PathLog #import Part from PySide import QtCore, QtGui from PathScripts import PathUtils from PathScripts.PathUtils import fmt #from math import pi LOG_MODULE = 'PathDrilling' PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE) PathLog.trackModule('PathDrilling') FreeCADGui = None if FreeCAD.GuiUp: import FreeCADGui """Path Drilling object and FreeCAD command""" # Qt tanslation handling try: _encoding = QtGui.QApplication.UnicodeUTF8 def translate(context, text, disambig=None): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError:
import PathScripts.PathGui as PathGui import PathScripts.PathLog as PathLog import PathScripts.PathOpGui as PathOpGui from PySide import QtCore __title__ = "Path Drilling Operation UI." __author__ = "sliptonic (Brad Collette)" __url__ = "https://www.freecadweb.org" __doc__ = "UI and Command for Path Drilling Operation." __contributors__ = "IMBack!" LOGLEVEL = False if LOGLEVEL: PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) PathLog.trackModule(PathLog.thisModule()) else: PathLog.setLevel(PathLog.Level.NOTICE, PathLog.thisModule()) class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage): '''Controller for the drilling operation's page''' def initPage(self, obj): # pylint: disable=attribute-defined-outside-init self.peckDepthSpinBox = PathGui.QuantitySpinBox( self.form.peckDepth, obj, 'PeckDepth') self.peckRetractSpinBox = PathGui.QuantitySpinBox( self.form.peckRetractHeight, obj, 'RetractHeight') self.dwellTimeSpinBox = PathGui.QuantitySpinBox( self.form.dwellTime, obj, 'DwellTime')
from __future__ import print_function import FreeCAD from FreeCAD import Units import Path import argparse import datetime import shlex from PathScripts import PostUtils from PathScripts import PathUtils import PathScripts.PathLog as PathLog import PathGeom import math import base64 LOG_MODULE = PathLog.thisModule() PathLog.setLevel(PathLog.Level.ERROR, LOG_MODULE) TOOLTIP = ''' This is a postprocessor file for the Path workbench. It is used to take a pseudo-gcode fragment outputted by a Path object, and output real GCode suitable for a linuxcnc 3 axis mill. This postprocessor, once placed in the appropriate PathScripts folder, can be used directly from inside FreeCAD, via the GUI importer or via python scripts with: import linuxcnc_post linuxcnc_post.export(object,"/path/to/file.ncc","") ''' now = datetime.datetime.now() parser = argparse.ArgumentParser(prog='linuxcnc', add_help=False)
def setUp(self): PathLog.setLevel(PathLog.Level.RESET) PathLog.untrackAllModules()
import Path from PathScripts import PathLog from PathScripts import PathPost from PathScripts import PathPreferences from PathScripts import PostUtils from PathScripts.PathPostProcessor import PostProcessor # If KEEP_DEBUG_OUTPUT is False, remove the gcode file after the test succeeds. # If KEEP_DEBUG_OUTPUT is True or the test fails leave the gcode file behind # so it can be looked at easily. KEEP_DEBUG_OUTPUT = False PathPost.LOG_MODULE = PathLog.thisModule() PathLog.setLevel(PathLog.Level.INFO, PathPost.LOG_MODULE) class TestPathPost(unittest.TestCase): """Test some of the output of the postprocessors. So far there are three tests each for the linuxcnc and centroid postprocessors. """ def setUp(self): """Set up the postprocessor tests.""" pass def tearDown(self): """Tear down after the postprocessor tests."""
import PathScripts.PathDressup as PathDressup import PathScripts.PathGeom as PathGeom import PathScripts.PathLog as PathLog import PathScripts.PathUtil as PathUtil import PathScripts.PathUtils as PathUtils from PySide import QtCore # lazily loaded modules from lazy_loader.lazy_loader import LazyLoader DraftGeomUtils = LazyLoader('DraftGeomUtils', globals(), 'DraftGeomUtils') Part = LazyLoader('Part', globals(), 'Part') LOG_MODULE = PathLog.thisModule() PathLog.setLevel(PathLog.Level.NOTICE, LOG_MODULE) #PathLog.setLevel(PathLog.Level.DEBUG, LOG_MODULE) # Qt translation handling def translate(context, text, disambig=None): return QtCore.QCoreApplication.translate(context, text, disambig) movecommands = ['G0', 'G00', 'G1', 'G01', 'G2', 'G02', 'G3', 'G03'] movestraight = ['G1', 'G01'] movecw = ['G2', 'G02'] moveccw = ['G3', 'G03'] movearc = movecw + moveccw def debugMarker(vector, label, color=None, radius=0.5):
def test21(self): """Verify debug logs are logged if log level is set to DEBUG.""" PathLog.setLevel(PathLog.Level.DEBUG) self.assertIsNotNone(PathLog.debug("this"))
def test12(self): """Verify setting module log level.""" PathLog.setLevel(PathLog.Level.DEBUG, self.MODULE) self.assertEqual(PathLog.getLevel(), PathLog.Level.NOTICE) self.assertEqual(PathLog.getLevel(self.MODULE), PathLog.Level.DEBUG)
def test11(self): """Verify setting global log level.""" PathLog.setLevel(PathLog.Level.DEBUG) self.assertEqual(PathLog.getLevel(), PathLog.Level.DEBUG) self.assertEqual(PathLog.getLevel(self.MODULE), PathLog.Level.DEBUG)
import FreeCAD import Path import PathScripts.PathLog as PathLog import PathScripts.PathOp as PathOp import PathScripts.PathUtils as PathUtils from PathScripts.PathUtils import waiting_effects from PySide import QtCore __title__ = "Base class for PathArea based operations." __author__ = "sliptonic (Brad Collette)" __url__ = "http://www.freecadweb.org" __doc__ = "Base class and properties for Path.Area based operations." if False: PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) PathLog.trackModule() else: PathLog.setLevel(PathLog.Level.INFO, PathLog.thisModule()) # Qt tanslation handling def translate(context, text, disambig=None): return QtCore.QCoreApplication.translate(context, text, disambig) class ObjectOp(PathOp.ObjectOp): '''Base class for all Path.Area based operations. Provides standard features including debugging properties AreaParams, PathParams and removalshape, all hidden. The main reason for existence is to implement the standard interface to Path.Area so subclasses only have to provide the shapes for the operations.'''
# * * # *************************************************************************** ''' Tool Controller defines tool, spindle speed and feed rates for Path Operations ''' import FreeCAD from FreeCAD import Units import FreeCADGui import PathUtils import Path import Part import PathScripts from PySide import QtCore, QtGui import PathScripts.PathLog as PathLog LOG_MODULE = 'PathLoadTool' PathLog.setLevel(PathLog.Level.INFO, LOG_MODULE) #PathLog.trackModule('PathLoadTool') # Qt tanslation handling try: _encoding = QtGui.QApplication.UnicodeUTF8 def translate(context, text, disambig=None): return QtGui.QApplication.translate(context, text, disambig, _encoding) except AttributeError: def translate(context, text, disambig=None): return QtGui.QApplication.translate(context, text, disambig) class LoadTool():
# * * # *************************************************************************** import FreeCAD import FreeCADGui import PathScripts.PathCircularHoleBaseGui as PathCircularHoleBaseGui import PathScripts.PathHelix as PathHelix import PathScripts.PathLog as PathLog import PathScripts.PathOpGui as PathOpGui from PySide import QtCore, QtGui __doc__ = "Helix operation page controller and command implementation." if True: PathLog.setLevel(PathLog.Level.DEBUG, PathLog.thisModule()) PathLog.trackModule(PathLog.thisModule()) else: PathLog.setLevel(PathLog.Level.NOTICE, PathLog.thisModule()) class TaskPanelOpPage(PathCircularHoleBaseGui.TaskPanelOpPage): '''Page controller class for Helix operations.''' def getForm(self): '''getForm() ... return UI''' return FreeCADGui.PySideUic.loadUi(":/panels/PageOpHelixEdit.ui") def getFields(self, obj): '''getFields(obj) ... transfers values from UI to obj's proprties''' PathLog.track()
def testzz(self): """Restoring environment after tests.""" PathLog.setLevel(PathLog.Level.RESET)