Fixed post processors and Command constructor (wasn't dealing with parameters being optional).
This commit is contained in:
parent
eb9e9096ce
commit
6b69276342
|
@ -52,18 +52,18 @@ std::string CommandPy::representation(void) const
|
|||
str << " ]";
|
||||
return str.str();
|
||||
}
|
||||
|
||||
|
||||
|
||||
PyObject *CommandPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper
|
||||
{
|
||||
// create a new instance of CommandPy and the Twin object
|
||||
// create a new instance of CommandPy and the Twin object
|
||||
return new CommandPy(new Command);
|
||||
}
|
||||
|
||||
// constructor method
|
||||
int CommandPy::PyInit(PyObject* args, PyObject* kwd)
|
||||
{
|
||||
PyObject *parameters;
|
||||
PyObject *parameters = NULL;
|
||||
char *name = "";
|
||||
static char *kwlist[] = {"name", "parameters", NULL};
|
||||
if ( PyArg_ParseTupleAndKeywords(args, kwd, "|sO!", kwlist, &name, &PyDict_Type, ¶meters) ) {
|
||||
|
@ -73,7 +73,7 @@ int CommandPy::PyInit(PyObject* args, PyObject* kwd)
|
|||
getCommandPtr()->setFromGCode(name);
|
||||
PyObject *key, *value;
|
||||
Py_ssize_t pos = 0;
|
||||
while (PyDict_Next(parameters, &pos, &key, &value)) {
|
||||
while (parameters && PyDict_Next(parameters, &pos, &key, &value)) {
|
||||
if ( !PyObject_TypeCheck(key,&(PyString_Type)) || (!PyObject_TypeCheck(value,&(PyFloat_Type)) && !PyObject_TypeCheck(value,&(PyInt_Type))) ) {
|
||||
PyErr_SetString(PyExc_TypeError, "The dictionary can only contain string:number pairs");
|
||||
return -1;
|
||||
|
@ -91,7 +91,7 @@ int CommandPy::PyInit(PyObject* args, PyObject* kwd)
|
|||
return 0;
|
||||
}
|
||||
PyErr_Clear(); // set by PyArg_ParseTuple()
|
||||
|
||||
|
||||
if ( PyArg_ParseTupleAndKeywords(args, kwd, "|sO!", kwlist, &name, &(Base::PlacementPy::Type), ¶meters) ) {
|
||||
std::string sname(name);
|
||||
boost::to_upper(sname);
|
||||
|
@ -222,8 +222,8 @@ PyObject *CommandPy::getCustomAttributes(const char* attr) const
|
|||
int CommandPy::setCustomAttributes(const char* attr, PyObject* obj)
|
||||
{
|
||||
std::string satt(attr);
|
||||
if (satt.length() == 1) {
|
||||
if (isalpha(satt[0])) {
|
||||
if (satt.length() == 1) {
|
||||
if (isalpha(satt[0])) {
|
||||
boost::to_upper(satt);
|
||||
double cvalue;
|
||||
if (PyObject_TypeCheck(obj,&(PyInt_Type))) {
|
||||
|
|
|
@ -25,6 +25,8 @@ SET(PathScripts_SRCS
|
|||
PathScripts/linuxcnc_post.py
|
||||
PathScripts/centroid_post.py
|
||||
PathScripts/comparams_post.py
|
||||
PathScripts/dynapath_post.py
|
||||
PathScripts/generic_post.py
|
||||
PathScripts/dumper_post.py
|
||||
PathScripts/rml_post.py
|
||||
PathScripts/TooltableEditor.py
|
||||
|
|
|
@ -60,6 +60,7 @@ class ObjectPathJob:
|
|||
posts = glob.glob(path + '/*_post.py')
|
||||
|
||||
allposts.extend([ str(os.path.split(os.path.splitext(p)[0])[1][:-5]) for p in posts])
|
||||
allposts.sort()
|
||||
|
||||
# obj.addProperty("App::PropertyFile", "PostProcessor", "CodeOutput", "Select the Post Processor file for this project")
|
||||
obj.addProperty("App::PropertyFile", "OutputFile", "CodeOutput", QtCore.QT_TRANSLATE_NOOP("App::Property","The NC output file for this project"))
|
||||
|
|
|
@ -27,6 +27,8 @@ import FreeCAD
|
|||
import Path, PathScripts
|
||||
from PathScripts import PostUtils
|
||||
|
||||
SHOW_EDITOR=True
|
||||
|
||||
def fmt(num):
|
||||
fnum = ""
|
||||
fnum += '%.3f' % (num)
|
||||
|
@ -98,7 +100,8 @@ def export(obj,filename,argstring):
|
|||
gfile.close()
|
||||
else:
|
||||
FreeCAD.Console.PrintError('Select a path object and try again\n')
|
||||
if obj[0].Editor:
|
||||
|
||||
if SHOW_EDITOR:
|
||||
FreeCAD.Console.PrintMessage('Editor Activated\n')
|
||||
dia = PostUtils.GCodeEditorDialog()
|
||||
dia.editor.setText(gcode)
|
||||
|
|
|
@ -123,7 +123,7 @@ def export(objectslist,filename,argstring):
|
|||
#Find the machine.
|
||||
#The user my have overriden post processor defaults in the GUI. Make sure we're using the current values in the Machine Def.
|
||||
myMachine = None
|
||||
for pathobj in selection:
|
||||
for pathobj in objectslist:
|
||||
if hasattr(pathobj,"MachineName"):
|
||||
myMachine = pathobj.MachineName
|
||||
if hasattr(pathobj, "MachineUnits"):
|
||||
|
|
|
@ -119,7 +119,7 @@ def export(objectslist, filename, argstring):
|
|||
# The user my have overriden post processor defaults in the GUI. Make
|
||||
# sure we're using the current values in the Machine Def.
|
||||
myMachine = None
|
||||
for pathobj in selection:
|
||||
for pathobj in objectslist:
|
||||
if hasattr(pathobj,"MachineName"):
|
||||
myMachine = pathobj.MachineName
|
||||
if hasattr(pathobj, "MachineUnits"):
|
||||
|
|
Loading…
Reference in New Issue
Block a user