From 6f09fd8aa45cbe3b7e3cedb50365ce9befbd62de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lorenz=20H=C3=BCdepohl?= Date: Fri, 30 Dec 2016 22:33:15 +0100 Subject: [PATCH 1/3] Path: linuxcnc_post without GUI A simple fix to be able to easily use the linuxcnc_post module without the GUI present --- src/Mod/Path/PathScripts/linuxcnc_post.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Mod/Path/PathScripts/linuxcnc_post.py b/src/Mod/Path/PathScripts/linuxcnc_post.py index 4d625c5fe7..ecb32bee4f 100644 --- a/src/Mod/Path/PathScripts/linuxcnc_post.py +++ b/src/Mod/Path/PathScripts/linuxcnc_post.py @@ -40,7 +40,7 @@ Arguments for linuxcnc: --line-numbers,--no-line-numbers ... prefix with line numbers (--no-lin-numbers) --show-editor, --no-show-editor ... pop up editor before writing output(--show-editor) ''' - +import FreeCAD import datetime from PathScripts import PostUtils @@ -50,7 +50,10 @@ now = datetime.datetime.now() OUTPUT_COMMENTS = True OUTPUT_HEADER = True OUTPUT_LINE_NUMBERS = False -SHOW_EDITOR = True +if FreeCAD.GuiUp: + SHOW_EDITOR = True +else: + SHOW_EDITOR = False MODAL = False # if true commands are suppressed if the same as previous line. COMMAND_SPACE = " " LINENR = 100 # line number starting value From 4db41b0b4b57d0de41f50b741ef289b9d559b277 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 30 Dec 2016 22:51:17 +0100 Subject: [PATCH 2/3] register Quantity type for shiboken2, handle exception to fix abort when setting quantity property of InputField via Python --- src/Gui/InputField.cpp | 9 +++++++-- src/Gui/WidgetFactory.cpp | 6 +----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index 5498560e40..8b57df3493 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -492,8 +492,13 @@ void InputField::setMinimum(double m) void InputField::setUnitText(const QString& str) { - Base::Quantity quant = Base::Quantity::parse(str); - setUnit(quant.getUnit()); + try { + Base::Quantity quant = Base::Quantity::parse(str); + setUnit(quant.getUnit()); + } + catch (...) { + // ignore exceptions + } } QString InputField::getUnitText(void) diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index 253e771830..03017daf15 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -108,7 +108,7 @@ PyTypeObject** SbkPySide2_QtWidgetsTypes=NULL; using namespace Gui; -#if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE) +#if defined (HAVE_SHIBOKEN) namespace Shiboken { template<> struct Converter { @@ -150,13 +150,9 @@ PythonToCppFunc toCppPointerCheckFuncQuantity(PyObject* obj) void registerTypes() { -#if defined (HAVE_SHIBOKEN2) - //FIXME: This crashes with Shiboken2 -#else SbkConverter* convert = Shiboken::Conversions::createConverter(&Base::QuantityPy::Type, toPythonFuncQuantity); Shiboken::Conversions::setPythonToCppPointerFunctions(convert, toCppPointerConvFuncQuantity, toCppPointerCheckFuncQuantity); Shiboken::Conversions::registerConverterName(convert, "Base::Quantity"); -#endif } #endif From 0e040fd6e06b1bb340e0606651792245df97f4fc Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Sat, 31 Dec 2016 15:48:01 -0200 Subject: [PATCH 3/3] Draft: Do not import non-instanciated blocks - fixes #2822 --- src/Mod/Draft/App/DraftDxf.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/App/DraftDxf.cpp b/src/Mod/Draft/App/DraftDxf.cpp index a8b50c3751..cf5db5e18a 100644 --- a/src/Mod/Draft/App/DraftDxf.cpp +++ b/src/Mod/Draft/App/DraftDxf.cpp @@ -210,8 +210,10 @@ void DraftDxfRead::AddObject(Part::TopoShape *shape) vec.push_back(shape); layers[LayerName()] = vec; if (!optionGroupLayers) { - Part::Feature *pcFeature = (Part::Feature *)document->addObject("Part::Feature", "Shape"); - pcFeature->Shape.setValue(*shape); + if(LayerName().substr(0, 6) != "BLOCKS") { + Part::Feature *pcFeature = (Part::Feature *)document->addObject("Part::Feature", "Shape"); + pcFeature->Shape.setValue(shape->getShape()); + } } }