Add dumpSymbol method to DrawViewSymbol based classes

- this is mainly for debugging output from Arch/Draft
This commit is contained in:
WandererFan
2017-08-27 20:43:09 -04:00
committed by wmayer
parent 31535e9b53
commit 481008629b
4 changed files with 48 additions and 1 deletions

View File

@@ -1,6 +1,10 @@
#include "PreCompiled.h"
#include <Base/Console.h>
#include <Base/FileInfo.h>
#include <Base/Stream.h>
#include "DrawViewSymbol.h"
#include "DrawView.h"
@@ -17,6 +21,32 @@ std::string DrawViewSymbolPy::representation(void) const
return std::string("<DrawViewSymbol object>");
}
PyObject* DrawViewSymbolPy::dumpSymbol(PyObject *args)
{
const char* fileSpec;
if (!PyArg_ParseTuple(args, "s", &fileSpec)) {
throw Py::TypeError("** dumpSymbol bad args.");
}
auto dvs = getDrawViewSymbolPtr();
std::string symbolRepr;
if (dvs != nullptr) {
symbolRepr = dvs->Symbol.getValue();
}
Base::FileInfo fi(fileSpec);
std::ofstream outfile;
outfile.open(fi.filePath());
outfile.write (symbolRepr.c_str(),symbolRepr.size());
outfile.close();
if (outfile.good()) {
outfile.close();
} else {
std::string error = std::string("Can't write ");
error += fileSpec;
throw Py::Exception(error);
}
Py_Return;
}
PyObject *DrawViewSymbolPy::getCustomAttributes(const char* /*attr*/) const
{