@@ -27,6 +27,7 @@
|
||||
#endif
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <Base/Interpreter.h>
|
||||
|
||||
#include "Command.h"
|
||||
@@ -47,7 +48,7 @@ extern PyObject* initModule();
|
||||
}
|
||||
|
||||
/* Python entry */
|
||||
PyMODINIT_FUNC initPath()
|
||||
PyMOD_INIT_FUNC(Path)
|
||||
{
|
||||
PyObject* pathModule = Path::initModule();
|
||||
Base::Console().Log("Loading Path module... done\n");
|
||||
@@ -74,4 +75,6 @@ PyMODINIT_FUNC initPath()
|
||||
Path::FeatureCompoundPython ::init();
|
||||
Path::FeatureShape ::init();
|
||||
Path::FeatureShapePython ::init();
|
||||
|
||||
PyMOD_Return(pathModule);
|
||||
}
|
||||
|
||||
@@ -74,15 +74,28 @@ int CommandPy::PyInit(PyObject* args, PyObject* kwd)
|
||||
PyObject *key, *value;
|
||||
Py_ssize_t pos = 0;
|
||||
while (parameters && PyDict_Next(parameters, &pos, &key, &value)) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
if ( !PyObject_TypeCheck(key,&(PyBytes_Type)) || (!PyObject_TypeCheck(value,&(PyFloat_Type)) && !PyObject_TypeCheck(value,&(PyLong_Type))) ) {
|
||||
#else
|
||||
if ( !PyObject_TypeCheck(key,&(PyString_Type)) || (!PyObject_TypeCheck(value,&(PyFloat_Type)) && !PyObject_TypeCheck(value,&(PyInt_Type))) ) {
|
||||
#endif
|
||||
PyErr_SetString(PyExc_TypeError, "The dictionary can only contain string:number pairs");
|
||||
return -1;
|
||||
}
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
std::string ckey = PyBytes_AsString(key);
|
||||
#else
|
||||
std::string ckey = PyString_AsString(key);
|
||||
#endif
|
||||
boost::to_upper(ckey);
|
||||
double cvalue;
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
if (PyObject_TypeCheck(value,&(PyLong_Type))) {
|
||||
cvalue = (double)PyLong_AsLong(value);
|
||||
#else
|
||||
if (PyObject_TypeCheck(value,&(PyInt_Type))) {
|
||||
cvalue = (double)PyInt_AsLong(value);
|
||||
#endif
|
||||
} else {
|
||||
cvalue = PyFloat_AsDouble(value);
|
||||
}
|
||||
@@ -124,7 +137,11 @@ Py::Dict CommandPy::getParameters(void) const
|
||||
{
|
||||
PyObject *dict = PyDict_New();
|
||||
for(std::map<std::string,double>::iterator i = getCommandPtr()->Parameters.begin(); i != getCommandPtr()->Parameters.end(); ++i) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyDict_SetItem(dict,PyBytes_FromString(i->first.c_str()),PyFloat_FromDouble(i->second));
|
||||
#else
|
||||
PyDict_SetItem(dict,PyString_FromString(i->first.c_str()),PyFloat_FromDouble(i->second));
|
||||
#endif
|
||||
}
|
||||
return Py::Dict(dict);
|
||||
}
|
||||
@@ -135,12 +152,22 @@ void CommandPy::setParameters(Py::Dict arg)
|
||||
PyObject *key, *value;
|
||||
Py_ssize_t pos = 0;
|
||||
while (PyDict_Next(dict_copy, &pos, &key, &value)) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
if ( PyObject_TypeCheck(key,&(PyBytes_Type)) && (PyObject_TypeCheck(value,&(PyFloat_Type)) || PyObject_TypeCheck(value,&(PyLong_Type)) ) ) {
|
||||
std::string ckey = PyBytes_AsString(key);
|
||||
#else
|
||||
if ( PyObject_TypeCheck(key,&(PyString_Type)) && (PyObject_TypeCheck(value,&(PyFloat_Type)) || PyObject_TypeCheck(value,&(PyInt_Type)) ) ) {
|
||||
std::string ckey = PyString_AsString(key);
|
||||
#endif
|
||||
boost::to_upper(ckey);
|
||||
double cvalue;
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
if (PyObject_TypeCheck(value,&(PyLong_Type))) {
|
||||
cvalue = (double)PyLong_AsLong(value);
|
||||
#else
|
||||
if (PyObject_TypeCheck(value,&(PyInt_Type))) {
|
||||
cvalue = (double)PyInt_AsLong(value);
|
||||
#endif
|
||||
} else {
|
||||
cvalue = PyFloat_AsDouble(value);
|
||||
}
|
||||
@@ -156,7 +183,11 @@ void CommandPy::setParameters(Py::Dict arg)
|
||||
PyObject* CommandPy::toGCode(PyObject *args)
|
||||
{
|
||||
if (PyArg_ParseTuple(args, "")) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
return PyBytes_FromString(getCommandPtr()->toGCode().c_str());
|
||||
#else
|
||||
return PyString_FromString(getCommandPtr()->toGCode().c_str());
|
||||
#endif
|
||||
}
|
||||
throw Py::Exception("This method accepts no argument");
|
||||
}
|
||||
@@ -226,8 +257,13 @@ int CommandPy::setCustomAttributes(const char* attr, PyObject* obj)
|
||||
if (isalpha(satt[0])) {
|
||||
boost::to_upper(satt);
|
||||
double cvalue;
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
if (PyObject_TypeCheck(obj,&(PyLong_Type))) {
|
||||
cvalue = (double)PyLong_AsLong(obj);
|
||||
#else
|
||||
if (PyObject_TypeCheck(obj,&(PyInt_Type))) {
|
||||
cvalue = (double)PyInt_AsLong(obj);
|
||||
#endif
|
||||
} else if (PyObject_TypeCheck(obj,&(PyFloat_Type))) {
|
||||
cvalue = PyFloat_AsDouble(obj);
|
||||
} else {
|
||||
|
||||
@@ -26,7 +26,7 @@ commands (optional) is a list of Path commands</UserDocu>
|
||||
<Documentation>
|
||||
<UserDocu>the number of commands in this path</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Size" Type="Int"/>
|
||||
<Parameter Name="Size" Type="Long"/>
|
||||
</Attribute>
|
||||
<Attribute Name="Commands" ReadOnly="false">
|
||||
<Documentation>
|
||||
|
||||
@@ -112,9 +112,9 @@ Py::Float PathPy::getLength(void) const
|
||||
return Py::Float(getToolpathPtr()->getLength());
|
||||
}
|
||||
|
||||
Py::Int PathPy::getSize(void) const
|
||||
Py::Long PathPy::getSize(void) const
|
||||
{
|
||||
return Py::Int((int)getToolpathPtr()->getSize());
|
||||
return Py::Long((long)getToolpathPtr()->getSize());
|
||||
}
|
||||
|
||||
// specific methods
|
||||
@@ -178,7 +178,11 @@ PyObject* PathPy::toGCode(PyObject * args)
|
||||
{
|
||||
if (PyArg_ParseTuple(args, "")) {
|
||||
std::string result = getToolpathPtr()->toGCode();
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
return PyBytes_FromString(result.c_str());
|
||||
#else
|
||||
return PyString_FromString(result.c_str());
|
||||
#endif
|
||||
}
|
||||
throw Py::Exception("This method accepts no argument");
|
||||
}
|
||||
|
||||
@@ -363,11 +363,19 @@ int TooltablePy::PyInit(PyObject* args, PyObject* /*kwd*/)
|
||||
PyObject *key, *value;
|
||||
Py_ssize_t pos = 0;
|
||||
while (PyDict_Next(pcObj, &pos, &key, &value)) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
if ( !PyObject_TypeCheck(key,&(PyLong_Type)) || !PyObject_TypeCheck(value,&(Path::ToolPy::Type)) ) {
|
||||
#else
|
||||
if ( !PyObject_TypeCheck(key,&(PyInt_Type)) || !PyObject_TypeCheck(value,&(Path::ToolPy::Type)) ) {
|
||||
#endif
|
||||
PyErr_SetString(PyExc_TypeError, "The dictionary can only contain int:tool pairs");
|
||||
return -1;
|
||||
}
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
int ckey = (int)PyLong_AsLong(key);
|
||||
#else
|
||||
int ckey = (int)PyInt_AsLong(key);
|
||||
#endif
|
||||
Path::Tool &tool = *static_cast<Path::ToolPy*>(value)->getToolPtr();
|
||||
getTooltablePtr()->setTool(tool,ckey);
|
||||
}
|
||||
@@ -397,7 +405,11 @@ Py::Dict TooltablePy::getTools(void) const
|
||||
PyObject *dict = PyDict_New();
|
||||
for(std::map<int,Path::Tool*>::iterator i = getTooltablePtr()->Tools.begin(); i != getTooltablePtr()->Tools.end(); ++i) {
|
||||
PyObject *tool = new Path::ToolPy(i->second);
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
PyDict_SetItem(dict,PyLong_FromLong(i->first),tool);
|
||||
#else
|
||||
PyDict_SetItem(dict,PyInt_FromLong(i->first),tool);
|
||||
#endif
|
||||
}
|
||||
return Py::Dict(dict);
|
||||
}
|
||||
@@ -409,8 +421,13 @@ void TooltablePy::setTools(Py::Dict arg)
|
||||
PyObject *key, *value;
|
||||
Py_ssize_t pos = 0;
|
||||
while (PyDict_Next(dict_copy, &pos, &key, &value)) {
|
||||
#if PY_MAJOR_VERSION >= 3
|
||||
if ( PyObject_TypeCheck(key,&(PyLong_Type)) && (PyObject_TypeCheck(value,&(Path::ToolPy::Type))) ) {
|
||||
int ckey = (int)PyLong_AsLong(key);
|
||||
#else
|
||||
if ( PyObject_TypeCheck(key,&(PyInt_Type)) && (PyObject_TypeCheck(value,&(Path::ToolPy::Type))) ) {
|
||||
int ckey = (int)PyInt_AsLong(key);
|
||||
#endif
|
||||
Path::Tool &tool = *static_cast<Path::ToolPy*>(value)->getToolPtr();
|
||||
getTooltablePtr()->setTool(tool,ckey);
|
||||
} else {
|
||||
|
||||
@@ -51,11 +51,11 @@ extern PyObject* initModule();
|
||||
}
|
||||
|
||||
/* Python entry */
|
||||
PyMODINIT_FUNC initPathGui()
|
||||
PyMOD_INIT_FUNC(PathGui)
|
||||
{
|
||||
if (!Gui::Application::Instance) {
|
||||
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
|
||||
return;
|
||||
PyMOD_Return(0);
|
||||
}
|
||||
try {
|
||||
Base::Interpreter().runString("import PartGui");
|
||||
@@ -63,9 +63,9 @@ PyMODINIT_FUNC initPathGui()
|
||||
}
|
||||
catch(const Base::Exception& e) {
|
||||
PyErr_SetString(PyExc_ImportError, e.what());
|
||||
return;
|
||||
PyMOD_Return(0);
|
||||
}
|
||||
(void)PathGui::initModule();
|
||||
PyObject* mod = PathGui::initModule();
|
||||
Base::Console().Log("Loading GUI of Path module... done\n");
|
||||
|
||||
// instantiating the commands
|
||||
@@ -83,4 +83,6 @@ PyMODINIT_FUNC initPathGui()
|
||||
|
||||
// register preferences pages
|
||||
new Gui::PrefPageProducer<PathGui::DlgSettingsPathColor> ("Path");
|
||||
|
||||
PyMOD_Return(mod);
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
from __future__ import print_function
|
||||
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
@@ -57,7 +58,7 @@ class ObjectCompoundExtended:
|
||||
|
||||
def onChanged(self, obj, prop):
|
||||
if prop == "Group":
|
||||
print 'check order'
|
||||
print('check order')
|
||||
for child in obj.Group:
|
||||
if child.isDerivedFrom("Path::Feature"):
|
||||
child.touch()
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
from __future__ import print_function
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
@@ -90,7 +91,7 @@ class ViewProviderDressup:
|
||||
if g.Name == self.Object.Base.Name:
|
||||
group.remove(g)
|
||||
i.Group = group
|
||||
print i.Group
|
||||
print(i.Group)
|
||||
return [self.Object.Base]
|
||||
|
||||
def __getstate__(self):
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
from __future__ import print_function
|
||||
import DraftGeomUtils
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
@@ -951,7 +952,7 @@ class ViewProviderDressup:
|
||||
if g.Name == self.Object.Base.Name:
|
||||
group.remove(g)
|
||||
i.Group = group
|
||||
print i.Group
|
||||
print(i.Group)
|
||||
#FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False
|
||||
return [self.Object.Base]
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from __future__ import print_function
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
import Path
|
||||
@@ -451,7 +452,7 @@ class ViewProviderDressup:
|
||||
if g.Name == self.Object.Base.Name:
|
||||
group.remove(g)
|
||||
i.Group = group
|
||||
print i.Group
|
||||
print(i.Group)
|
||||
#FreeCADGui.ActiveDocument.getObject(obj.Base.Name).Visibility = False
|
||||
return [self.Object.Base]
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from __future__ import print_function
|
||||
import FreeCAD
|
||||
import Path
|
||||
import Part
|
||||
@@ -304,7 +305,7 @@ class ObjectDrilling:
|
||||
else:
|
||||
baselist.append(item)
|
||||
|
||||
print baselist
|
||||
print(baselist)
|
||||
obj.Base = baselist
|
||||
self.execute(obj)
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
'''PathKurveUtils - functions needed for using libarea (created by Dan Heeks) for making simple CNC profile paths '''
|
||||
from __future__ import print_function
|
||||
import Part
|
||||
import math
|
||||
import area
|
||||
@@ -142,7 +143,7 @@ def profile(curve, side_of_line, radius=1.0, vertfeed=0.0, horizfeed=0.0, offset
|
||||
|
||||
output = ""
|
||||
output += "G0 Z" + str(clearance) + "\n"
|
||||
print "in profile: 151"
|
||||
print("in profile: 151")
|
||||
offset_curve = area.Curve(curve)
|
||||
if offset_curve.getNumVertices() <= 1:
|
||||
raise Exception, "Sketch has no elements!"
|
||||
@@ -338,10 +339,10 @@ def profile2(curve, direction="on", radius=1.0, vertfeed=0.0,
|
||||
using_area_for_offset = True
|
||||
a = area.Area()
|
||||
a.append(curve)
|
||||
print "curve, offset: " , str(curve), str(offset)
|
||||
print("curve, offset: " , str(curve), str(offset))
|
||||
a.Offset(-offset)
|
||||
for curve in a.getCurves():
|
||||
print "result curve: ", curve
|
||||
print("result curve: ", curve)
|
||||
curve_cw = curve.IsClockwise()
|
||||
if cw != curve_cw:
|
||||
curve.Reverse()
|
||||
|
||||
@@ -82,8 +82,9 @@ def _caller():
|
||||
file, line, func, text = traceback.extract_stack(limit=3)[0]
|
||||
return os.path.splitext(os.path.basename(file))[0], line, func
|
||||
|
||||
def _log(level, (module, line, func), msg):
|
||||
def _log(level, module_line_func, msg):
|
||||
"""internal function to do the logging"""
|
||||
module, line, func = module_line_func
|
||||
if getLevel(module) >= level:
|
||||
message = "%s.%s: %s" % (module, Level.toString(level), msg)
|
||||
if _useConsole:
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from __future__ import print_function
|
||||
import FreeCAD
|
||||
import Path
|
||||
from PySide import QtCore, QtGui
|
||||
@@ -211,7 +212,7 @@ class ObjectFace:
|
||||
|
||||
# To reload this from FreeCAD, use: import PathScripts.PathFace; reload(PathScripts.PathFace)
|
||||
def execute(self, obj):
|
||||
print "in execute"
|
||||
print("in execute")
|
||||
|
||||
if not obj.Active:
|
||||
path = Path.Path("(inactive operation)")
|
||||
@@ -260,7 +261,7 @@ class ObjectFace:
|
||||
if isinstance (shape, Part.Face):
|
||||
faces.append(shape)
|
||||
else:
|
||||
print ('falling out')
|
||||
print('falling out')
|
||||
return
|
||||
planeshape = Part.makeCompound(faces)
|
||||
|
||||
|
||||
@@ -154,7 +154,7 @@ class ObjectPocket:
|
||||
else:
|
||||
baselist.append(item)
|
||||
obj.Base = baselist
|
||||
print "this base is: " + str(baselist)
|
||||
print("this base is: " + str(baselist))
|
||||
self.execute(obj)
|
||||
|
||||
def getStock(self, obj):
|
||||
@@ -316,7 +316,7 @@ class ObjectPocket:
|
||||
# Otherwise, straight plunge... Don't want to, but sometimes you might not have a choice.
|
||||
# FIXME: At least not with the lazy ramp programming above...
|
||||
else:
|
||||
print "WARNING: Straight-plunging... probably not good, but we didn't find a place to helix or ramp"
|
||||
print("WARNING: Straight-plunging... probably not good, but we didn't find a place to helix or ramp")
|
||||
startPoint = edge.Vertexes[0].Point
|
||||
output += "G0 Z" + fmt(obj.ClearanceHeight.Value) + "F " + PathUtils.fmt(self.vertRapid) + "\n"
|
||||
output += "G0 X" + fmt(startPoint.x) + " Y" + fmt(startPoint.y) +\
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
''' Post Process command that will make use of the Output File and Post Processor entries in PathJob '''
|
||||
from __future__ import print_function
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
from PySide import QtCore, QtGui
|
||||
@@ -190,7 +191,7 @@ class CommandPathPost:
|
||||
FreeCADGui.addModule("PathScripts.PathPost")
|
||||
# select the Path Job that you want to post output from
|
||||
selected = FreeCADGui.Selection.getCompleteSelection()
|
||||
print "in activated %s" %(selected)
|
||||
print("in activated %s" %(selected))
|
||||
|
||||
# try to find the job, if it's not directly selected ...
|
||||
jobs = set()
|
||||
|
||||
@@ -35,12 +35,12 @@ class PostProcessor:
|
||||
def load(cls, processor):
|
||||
postname = processor + "_post"
|
||||
|
||||
exec "import %s as current_post" % postname
|
||||
exec("import %s as current_post" % postname)
|
||||
# make sure the script is reloaded if it was previously loaded
|
||||
# should the script have been imported for the first time above
|
||||
# then the initialization code of the script gets executed twice
|
||||
# resulting in 2 load messages if the script outputs one of those.
|
||||
exec "reload(%s)" % 'current_post'
|
||||
exec("reload(%s)" % 'current_post')
|
||||
|
||||
instance = PostProcessor(current_post)
|
||||
instance.units = None
|
||||
|
||||
@@ -165,8 +165,8 @@ class ObjectProfile:
|
||||
curve = PathKurveUtils.makeAreaCurve(edgelist, obj.Direction, startpoint, endpoint)
|
||||
|
||||
'''The following line uses a profile function written for use with FreeCAD. It's clean but incomplete. It doesn't handle
|
||||
print "x = " + str(point.x)
|
||||
print "y - " + str(point.y)
|
||||
print("x = " + str(point.x))
|
||||
print("y - " + str(point.y))
|
||||
holding tags
|
||||
start location
|
||||
CRC
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
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, QtGui
|
||||
import FreeCAD
|
||||
import FreeCADGui
|
||||
@@ -50,7 +51,7 @@ def review(obj):
|
||||
FreeCAD.Console.PrintWarning(translate("Path_Sanity", "It appears the machine limits haven't been set. Not able to check path extents.\n"))
|
||||
|
||||
for item in obj.Group:
|
||||
print "Checking: " + item.Label
|
||||
print("Checking: " + item.Label)
|
||||
if item.Name[:2] == "TC":
|
||||
toolcontrolcount += 1
|
||||
if item.ToolNumber == 0:
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from __future__ import print_function
|
||||
import FreeCAD
|
||||
import Path
|
||||
from PathScripts import PathUtils
|
||||
@@ -145,7 +146,7 @@ class ObjectSurface:
|
||||
str(fmt(p.x)) + " Y" + str(fmt(p.y)) + \
|
||||
" Z" + str(fmt(zheight)) + "\n"
|
||||
loopstring += "(loop end)" + "\n"
|
||||
print " loop ", nloop, " with ", len(loop), " points"
|
||||
print(" loop ", nloop, " with ", len(loop), " points")
|
||||
nloop = nloop + 1
|
||||
waterlinestring += loopstring
|
||||
waterlinestring += "(waterline end)" + "\n"
|
||||
@@ -174,7 +175,7 @@ class ObjectSurface:
|
||||
# (see c++ code)
|
||||
all_loops = []
|
||||
for zh in zheights:
|
||||
print "calculating Waterline at z= ", zh
|
||||
print("calculating Waterline at z= ", zh)
|
||||
wl.reset()
|
||||
wl.setZ(zh) # height for this waterline
|
||||
wl.run()
|
||||
@@ -184,10 +185,10 @@ class ObjectSurface:
|
||||
n = 0
|
||||
output = ""
|
||||
for loops in all_loops: # at each z-height, we may get many loops
|
||||
print " %d/%d:" % (n, len(all_loops))
|
||||
print(" %d/%d:" % (n, len(all_loops)))
|
||||
output += drawLoops(loops)
|
||||
n = n + 1
|
||||
print "(" + str(calctime) + ")"
|
||||
print("(" + str(calctime) + ")")
|
||||
return output
|
||||
|
||||
def _dropcutter(self, obj, s, bb):
|
||||
@@ -231,11 +232,11 @@ class ObjectSurface:
|
||||
t_before = time.time()
|
||||
pdc.run()
|
||||
t_after = time.time()
|
||||
print "calculation took ", t_after - t_before, " s"
|
||||
print("calculation took ", t_after - t_before, " s")
|
||||
|
||||
# retrieve the points
|
||||
clp = pdc.getCLPoints()
|
||||
print "points received: " + str(len(clp))
|
||||
print("points received: " + str(len(clp)))
|
||||
|
||||
# generate the path commands
|
||||
output = ""
|
||||
@@ -296,7 +297,7 @@ class ObjectSurface:
|
||||
mesh = parentJob.Base
|
||||
if mesh is None:
|
||||
return
|
||||
print "base object: " + mesh.Name
|
||||
print("base object: " + mesh.Name)
|
||||
|
||||
|
||||
|
||||
@@ -499,13 +500,13 @@ class TaskPanel:
|
||||
# get type of object
|
||||
if sel.TypeId.startswith('Mesh'):
|
||||
# it is a mesh already
|
||||
print 'was already mesh'
|
||||
print('was already mesh')
|
||||
|
||||
elif sel.TypeId.startswith('Part') and \
|
||||
(sel.Shape.BoundBox.XLength > 0) and \
|
||||
(sel.Shape.BoundBox.YLength > 0) and \
|
||||
(sel.Shape.BoundBox.ZLength > 0):
|
||||
print 'this is a solid Part object'
|
||||
print('this is a solid Part object')
|
||||
|
||||
else:
|
||||
FreeCAD.Console.PrintError(
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
# * *
|
||||
# ***************************************************************************
|
||||
|
||||
from __future__ import print_function
|
||||
import FreeCAD
|
||||
import xml.sax
|
||||
import FreeCADGui
|
||||
@@ -254,8 +255,8 @@ class ToolLibraryManager():
|
||||
if listname == "<Main>":
|
||||
self.saveMainLibrary(tt)
|
||||
return True
|
||||
except Exception, e:
|
||||
print "could not parse file", e
|
||||
except Exception as e:
|
||||
print("could not parse file", e)
|
||||
|
||||
def write(self, filename, listname):
|
||||
"exports the tooltable to a file"
|
||||
@@ -266,14 +267,14 @@ class ToolLibraryManager():
|
||||
file.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
file.write(tt.Content)
|
||||
file.close()
|
||||
print "Written ", unicode(filename[0])
|
||||
print("Written ", unicode(filename[0]))
|
||||
|
||||
except Exception, e:
|
||||
print "Could not write file:", e
|
||||
except Exception as e:
|
||||
print("Could not write file:", e)
|
||||
|
||||
def addnew(self, listname, tool, position = None):
|
||||
"adds a new tool at the end of the table"
|
||||
print listname, tool, position
|
||||
print(listname, tool, position)
|
||||
tt = self._findList(listname)
|
||||
if position is None:
|
||||
tt.addTools(tool)
|
||||
@@ -413,7 +414,7 @@ class EditorPanel():
|
||||
|
||||
def addTool(self):
|
||||
t = Path.Tool()
|
||||
print ("adding a new tool")
|
||||
print("adding a new tool")
|
||||
editform = FreeCADGui.PySideUic.loadUi(":/panels/ToolEdit.ui")
|
||||
|
||||
r = editform.exec_()
|
||||
|
||||
@@ -620,7 +620,7 @@ def addToJob(obj, jobname = None):
|
||||
if r is False:
|
||||
return None
|
||||
else:
|
||||
print form.cboProject.currentText()
|
||||
print(form.cboProject.currentText())
|
||||
job = [i for i in jobs if i.Name == form.cboProject.currentText()][0]
|
||||
|
||||
g = job.Group
|
||||
@@ -690,7 +690,7 @@ def arc(cx, cy, sx, sy, ex, ey, horizFeed=0, ez=None, ccw=False):
|
||||
|
||||
eps = 0.01
|
||||
if (math.sqrt((cx - sx)**2 + (cy - sy)**2) - math.sqrt((cx - ex)**2 + (cy - ey)**2)) >= eps:
|
||||
print "ERROR: Illegal arc: Start and end radii not equal"
|
||||
print("ERROR: Illegal arc: Start and end radii not equal")
|
||||
return ""
|
||||
|
||||
retstr = ""
|
||||
|
||||
@@ -70,8 +70,8 @@ class FreeCADTooltableHandler(xml.sax.ContentHandler):
|
||||
self.tool.Name = str(attributes["name"])
|
||||
self.tool.ToolType = str(attributes["type"])
|
||||
self.tool.Material = str(attributes["mat"])
|
||||
# for some reason without the following line I get an error
|
||||
print attributes["diameter"]
|
||||
# for some reason without the following line I get an error
|
||||
print(attributes["diameter"])
|
||||
self.tool.Diameter = float(attributes["diameter"])
|
||||
self.tool.LengthOffset = float(attributes["length"])
|
||||
self.tool.FlatRadius = float(attributes["flat"])
|
||||
@@ -122,8 +122,8 @@ class HeeksTooltableHandler(xml.sax.ContentHandler):
|
||||
self.tool.Material = "HighSpeedSteel"
|
||||
elif m == "1":
|
||||
self.tool.Material = "Carbide"
|
||||
# for some reason without the following line I get an error
|
||||
print attributes["diameter"]
|
||||
# for some reason without the following line I get an error
|
||||
print(attributes["diameter"])
|
||||
self.tool.Diameter = float(attributes["diameter"])
|
||||
self.tool.LengthOffset = float(attributes["tool_length_offset"])
|
||||
self.tool.FlatRadius = float(attributes["flat_radius"])
|
||||
@@ -654,7 +654,7 @@ class Editor(QtGui.QDialog):
|
||||
def addnew(self):
|
||||
"adds a new tool at the end of the table"
|
||||
tool = Path.Tool()
|
||||
print self.NameField
|
||||
print(self.NameField)
|
||||
if self.NameField.text():
|
||||
tool.Name = str(self.NameField.text())
|
||||
tool.ToolType = self.getType(self.TypeField.currentIndex())
|
||||
@@ -695,8 +695,8 @@ class Editor(QtGui.QDialog):
|
||||
fil.write('<?xml version="1.0" encoding="UTF-8"?>\n')
|
||||
fil.write(self.tooltable.Content)
|
||||
fil.close()
|
||||
print "Written ", filename[0]
|
||||
|
||||
print("Written ",filename[0])
|
||||
|
||||
def moveup(self):
|
||||
"moves a tool to a lower number, if possible"
|
||||
if self.number:
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#* USA *
|
||||
#* *
|
||||
#***************************************************************************
|
||||
from __future__ import print_function
|
||||
TOOLTIP=''' example post for Centroid CNC mill'''
|
||||
|
||||
import FreeCAD
|
||||
@@ -73,7 +74,7 @@ def export(selection,filename,argstring):
|
||||
params = ['X','Y','Z','A','B','I','J','F','H','S','T','Q','R','L'] #Using XY plane most of the time so skipping K
|
||||
for obj in selection:
|
||||
if not hasattr(obj,"Path"):
|
||||
print "the object " + obj.Name + " is not a path. Please select only path and Compounds."
|
||||
print("the object " + obj.Name + " is not a path. Please select only path and Compounds.")
|
||||
return
|
||||
myMachine = None
|
||||
for pathobj in selection:
|
||||
@@ -85,7 +86,7 @@ def export(selection,filename,argstring):
|
||||
else:
|
||||
UNITS = "G20"
|
||||
if myMachine is None:
|
||||
print "No machine found in this selection"
|
||||
print("No machine found in this selection")
|
||||
|
||||
gcode =''
|
||||
gcode+= HEADER % (FreeCAD.ActiveDocument.FileName)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
TOOLTIP='''
|
||||
Dumper is an extremely simple postprocessor file for the Path workbench. It is used
|
||||
@@ -52,9 +52,9 @@ def export(objectslist, filename,argstring):
|
||||
for obj in objectslist:
|
||||
|
||||
if not hasattr(obj, "Path"):
|
||||
print "the object " + obj.Name + " is not a path. Please select only path and Compounds."
|
||||
print("the object " + obj.Name + " is not a path. Please select only path and Compounds.")
|
||||
return
|
||||
print "postprocessing..."
|
||||
print("postprocessing...")
|
||||
output += parse(obj)
|
||||
|
||||
if SHOW_EDITOR:
|
||||
@@ -68,7 +68,7 @@ def export(objectslist, filename,argstring):
|
||||
else:
|
||||
final = output
|
||||
|
||||
print "done postprocessing."
|
||||
print("done postprocessing.")
|
||||
|
||||
|
||||
def parse(pathobj):
|
||||
@@ -90,4 +90,4 @@ def parse(pathobj):
|
||||
out += str(c) + "\n"
|
||||
return out
|
||||
|
||||
print __name__ + " gcode postprocessor loaded."
|
||||
print(__name__ + " gcode postprocessor loaded.")
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
#* (c) Linden (Linden@aktfast.net) 2016 *
|
||||
#* *
|
||||
#***************************************************************************/
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
TOOLTIP='''
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -114,10 +114,10 @@ def export(objectslist,filename,argstring):
|
||||
global UNITS
|
||||
for obj in objectslist:
|
||||
if not hasattr(obj,"Path"):
|
||||
print "the object " + obj.Name + " is not a path. Please select only path and Compounds."
|
||||
print("the object " + obj.Name + " is not a path. Please select only path and Compounds.")
|
||||
return
|
||||
|
||||
print "postprocessing..."
|
||||
print("postprocessing...")
|
||||
gcode = ""
|
||||
|
||||
#Find the machine.
|
||||
@@ -132,7 +132,7 @@ def export(objectslist,filename,argstring):
|
||||
else:
|
||||
UNITS = "G20"
|
||||
if myMachine is None:
|
||||
print "No machine found in this selection"
|
||||
print("No machine found in this selection")
|
||||
|
||||
# write header
|
||||
if OUTPUT_HEADER:
|
||||
@@ -177,7 +177,7 @@ def export(objectslist,filename,argstring):
|
||||
else:
|
||||
final = gcode
|
||||
|
||||
print "done postprocessing."
|
||||
print("done postprocessing.")
|
||||
|
||||
gfile = pythonopen(filename,"wb")
|
||||
gfile.write(gcode)
|
||||
@@ -259,5 +259,5 @@ def parse(pathobj):
|
||||
|
||||
return out
|
||||
|
||||
print __name__ + " gcode postprocessor loaded."
|
||||
print(__name__ + " gcode postprocessor loaded.")
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
TOOLTIP='''
|
||||
This is an example postprocessor file for the Path workbench. It is used
|
||||
@@ -42,11 +42,11 @@ if open.__module__ == '__builtin__':
|
||||
def export(objectslist, filename,argstring):
|
||||
"called when freecad exports a list of objects"
|
||||
if len(objectslist) > 1:
|
||||
print "This script is unable to write more than one Path object"
|
||||
print("This script is unable to write more than one Path object")
|
||||
return
|
||||
obj = objectslist[0]
|
||||
if not hasattr(obj, "Path"):
|
||||
print "the given object is not a path"
|
||||
print("the given object is not a path")
|
||||
gcode = obj.Path.toGCode()
|
||||
gcode = parse(gcode)
|
||||
gfile = pythonopen(filename, "wb")
|
||||
@@ -56,7 +56,7 @@ def export(objectslist, filename,argstring):
|
||||
|
||||
def parse(inputstring):
|
||||
"parse(inputstring): returns a parsed output string"
|
||||
print "postprocessing..."
|
||||
print("postprocessing...")
|
||||
|
||||
output = ""
|
||||
|
||||
@@ -95,7 +95,7 @@ def parse(inputstring):
|
||||
output += "N" + str(linenr + 30) + " G17 G80 G40 G90\n"
|
||||
output += "N" + str(linenr + 40) + " M99\n"
|
||||
|
||||
print "done postprocessing."
|
||||
print("done postprocessing.")
|
||||
return output
|
||||
|
||||
print __name__ + " gcode postprocessor loaded."
|
||||
print(__name__ + " gcode postprocessor loaded.")
|
||||
|
||||
@@ -60,7 +60,7 @@ def insert(filename,docname):
|
||||
|
||||
def parse(inputstring):
|
||||
"parse(inputstring): returns a parsed output string"
|
||||
print "preprocessing..."
|
||||
print("preprocessing...")
|
||||
|
||||
# split the input by line
|
||||
lines = inputstring.split("\n")
|
||||
@@ -93,9 +93,9 @@ def parse(inputstring):
|
||||
# no G or M command: we repeat the last one
|
||||
output += lastcommand + " " + l + "\n"
|
||||
|
||||
print "done preprocessing."
|
||||
print("done preprocessing.")
|
||||
return output
|
||||
|
||||
|
||||
print __name__ + " gcode preprocessor loaded."
|
||||
print(__name__ + " gcode preprocessor loaded.")
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#* *
|
||||
#***************************************************************************
|
||||
|
||||
from __future__ import print_function
|
||||
TOOLTIP='''Post processor for Maho M 600E mill
|
||||
|
||||
Machines with Philips or Heidenhain control should be very easy to adapt.
|
||||
@@ -285,7 +286,7 @@ def export(selection,filename,argstring):
|
||||
modalParamsDict[mp] = None
|
||||
for obj in selection:
|
||||
if not hasattr(obj,"Path"):
|
||||
print "the object " + obj.Name + " is not a path. Please select only path and Compounds."
|
||||
print("the object " + obj.Name + " is not a path. Please select only path and Compounds.")
|
||||
return
|
||||
myMachine = None
|
||||
for pathobj in selection:
|
||||
@@ -297,7 +298,7 @@ def export(selection,filename,argstring):
|
||||
else:
|
||||
UNITS = "G20"
|
||||
if myMachine is None:
|
||||
print "No machine found in this selection"
|
||||
print("No machine found in this selection")
|
||||
|
||||
gcode =''
|
||||
gcode+= mkHeader(selection)
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
# * USA *
|
||||
# * *
|
||||
# ***************************************************************************/
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
TOOLTIP='''
|
||||
This is a postprocessor file for the Path workbench. It is used to
|
||||
@@ -118,10 +118,10 @@ def export(objectslist, filename, argstring):
|
||||
global UNITS
|
||||
for obj in objectslist:
|
||||
if not hasattr(obj, "Path"):
|
||||
print "the object " + obj.Name + " is not a path. Please select only path and Compounds."
|
||||
print("the object " + obj.Name + " is not a path. Please select only path and Compounds.")
|
||||
return
|
||||
|
||||
print "postprocessing..."
|
||||
print("postprocessing...")
|
||||
gcode = ""
|
||||
|
||||
# Find the machine.
|
||||
@@ -137,7 +137,7 @@ def export(objectslist, filename, argstring):
|
||||
else:
|
||||
UNITS = "G20"
|
||||
if myMachine is None:
|
||||
print "No machine found in this selection"
|
||||
print("No machine found in this selection")
|
||||
|
||||
# write header
|
||||
if OUTPUT_HEADER:
|
||||
@@ -186,7 +186,7 @@ def export(objectslist, filename, argstring):
|
||||
else:
|
||||
final = gcode
|
||||
|
||||
print "done postprocessing."
|
||||
print("done postprocessing.")
|
||||
|
||||
if not filename == '-':
|
||||
gfile = pythonopen(filename, "wb")
|
||||
@@ -279,4 +279,4 @@ def parse(pathobj):
|
||||
return out
|
||||
|
||||
|
||||
print __name__ + " gcode postprocessor loaded."
|
||||
print(__name__ + " gcode postprocessor loaded.")
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
from __future__ import print_function
|
||||
import datetime
|
||||
from PathScripts import PostUtils
|
||||
|
||||
@@ -81,14 +82,14 @@ def export(objectslist, filename, argstring):
|
||||
if not hasattr(obj, "Path"):
|
||||
s = "the object " + obj.Name
|
||||
s += " is not a path. Please select only path and Compounds."
|
||||
print s
|
||||
print(s)
|
||||
return
|
||||
|
||||
CurrentState = {
|
||||
'X': 0, 'Y': 0, 'Z': 0, 'F': 0, 'S': 0,
|
||||
'JSXY': 0, 'JSZ': 0, 'MSXY': 0, 'MSZ': 0
|
||||
}
|
||||
print "postprocessing..."
|
||||
print("postprocessing...")
|
||||
gcode = ""
|
||||
|
||||
# write header
|
||||
@@ -136,7 +137,7 @@ def export(objectslist, filename, argstring):
|
||||
else:
|
||||
final = gcode
|
||||
|
||||
print "done postprocessing."
|
||||
print("done postprocessing.")
|
||||
|
||||
# Write the output
|
||||
gfile = pythonopen(filename, "wb")
|
||||
@@ -216,11 +217,11 @@ def move(command):
|
||||
txt += "," + format(command.Parameters["Z"], '.4f')
|
||||
txt += "\n"
|
||||
elif axis == "":
|
||||
print "warning: skipping duplicate move."
|
||||
print("warning: skipping duplicate move.")
|
||||
else:
|
||||
print CurrentState
|
||||
print command
|
||||
print "I don't know how to handle '{}' for a move.".format(axis)
|
||||
print(CurrentState)
|
||||
print(command)
|
||||
print("I don't know how to handle '{}' for a move.".format(axis))
|
||||
|
||||
return txt
|
||||
|
||||
@@ -255,7 +256,7 @@ def tool_change(command):
|
||||
|
||||
|
||||
def comment(command):
|
||||
print "a comment"
|
||||
print("a comment")
|
||||
return
|
||||
|
||||
|
||||
@@ -314,8 +315,8 @@ def parse(pathobj):
|
||||
if c.Parameters:
|
||||
CurrentState.update(c.Parameters)
|
||||
else:
|
||||
print "I don't know what the hell the command: ",
|
||||
print command + " means. Maybe I should support it."
|
||||
print("I don't know what the hell the command: ",end='')
|
||||
print(command + " means. Maybe I should support it.")
|
||||
return output
|
||||
|
||||
|
||||
@@ -323,6 +324,6 @@ def linenumber():
|
||||
return ""
|
||||
|
||||
|
||||
print __name__ + " gcode postprocessor loaded."
|
||||
print(__name__ + " gcode postprocessor loaded.")
|
||||
|
||||
# eof
|
||||
|
||||
@@ -46,6 +46,7 @@ TODO
|
||||
Many other OpenSBP commands not handled
|
||||
|
||||
'''
|
||||
from __future__ import print_function
|
||||
import FreeCAD
|
||||
import os, Path
|
||||
|
||||
@@ -81,7 +82,7 @@ def insert(filename,docname):
|
||||
|
||||
def parse(inputstring):
|
||||
"parse(inputstring): returns a list of parsed output string"
|
||||
print "preprocessing..."
|
||||
print("preprocessing...")
|
||||
# split the input by line
|
||||
lines = inputstring.split("\n")
|
||||
return_output = []
|
||||
@@ -182,7 +183,7 @@ def parse(inputstring):
|
||||
|
||||
if words[0] in ["CG"]: #Gcode circle/arc
|
||||
if words[1] != "": # diameter mode
|
||||
print "diameter mode not supported"
|
||||
print("diameter mode not supported")
|
||||
continue
|
||||
|
||||
else:
|
||||
@@ -201,9 +202,9 @@ def parse(inputstring):
|
||||
#Make sure all appended paths have at least one move command.
|
||||
if any (x in output for x in movecommand):
|
||||
return_output.append(output)
|
||||
print "done preprocessing."
|
||||
print("done preprocessing.")
|
||||
|
||||
return return_output
|
||||
|
||||
print __name__ + " gcode preprocessor loaded."
|
||||
print(__name__ + " gcode preprocessor loaded.")
|
||||
|
||||
|
||||
@@ -135,15 +135,15 @@ def xyarc(args, state):
|
||||
steps = 64 # TODO: specify max error instead
|
||||
points = arc.discretize(steps)
|
||||
# TODO: consider direction
|
||||
#print 'p = Part.ArcOfCircle(Part.Circle(FreeCAD.Vector(%f, %f), FreeCAD.Vector(0, 0, 1), %f), %f, %f)' % (center.x, center.y, radius, p0, p1)
|
||||
#print('p = Part.ArcOfCircle(Part.Circle(FreeCAD.Vector(%f, %f), FreeCAD.Vector(0, 0, 1), %f), %f, %f)' % (center.x, center.y, radius, p0, p1))
|
||||
for p in points:
|
||||
#print 'p', p.x, p.y
|
||||
#print('p', p.x, p.y)
|
||||
c += feed(p.x, p.y, state['Z'], state)
|
||||
return c
|
||||
|
||||
def speed(xy=None, z=None, state={}):
|
||||
c = []
|
||||
print xy, z, state
|
||||
print(xy, z, state)
|
||||
if xy is not None:
|
||||
xy = float(xy)
|
||||
if xy > 0.0 and xy != state['XYspeed']:
|
||||
@@ -235,7 +235,7 @@ def parse(inputstring):
|
||||
continue
|
||||
parsed = PostUtils.stringsplit(line)
|
||||
command = parsed['command']
|
||||
print 'cmd', line
|
||||
print('cmd', line)
|
||||
try:
|
||||
if command:
|
||||
code = convertgcode(command, parsed, state)
|
||||
@@ -243,8 +243,8 @@ def parse(inputstring):
|
||||
code = [ code ]
|
||||
if len(code) and code[0]:
|
||||
output += code
|
||||
except NotImplementedError, e:
|
||||
print e
|
||||
except NotImplementedError as e:
|
||||
print(e)
|
||||
|
||||
# footer
|
||||
output += motoroff()
|
||||
@@ -253,5 +253,5 @@ def parse(inputstring):
|
||||
|
||||
return '\n'.join(output)
|
||||
|
||||
print __name__ + " gcode postprocessor loaded."
|
||||
print (__name__ + " gcode postprocessor loaded.")
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ def insert(filename,docname):
|
||||
|
||||
def parse(inputstring):
|
||||
"parse(inputstring): returns a parsed output string"
|
||||
print "preprocessing..."
|
||||
print("preprocessing...")
|
||||
|
||||
# split the input by line
|
||||
lines = inputstring.split("\n")
|
||||
@@ -89,9 +89,9 @@ def parse(inputstring):
|
||||
# no G or M command: we repeat the last one
|
||||
output += lastcommand + " " + l + "\n"
|
||||
|
||||
print "done preprocessing."
|
||||
print("done preprocessing.")
|
||||
return output
|
||||
|
||||
|
||||
print __name__ + " gcode preprocessor loaded."
|
||||
print (__name__ + " gcode preprocessor loaded.")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user