Add dumpSymbol method to DrawViewSymbol based classes
- this is mainly for debugging output from Arch/Draft
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user