[TD]trap wrong selection for ArchSection
This commit is contained in:
@@ -103,6 +103,14 @@ App::DocumentObjectExecReturn *DrawViewArch::execute(void)
|
||||
}
|
||||
|
||||
App::DocumentObject* sourceObj = Source.getValue();
|
||||
//if (sourceObj is not ArchSection) return
|
||||
App::Property* proxy = sourceObj->getPropertyByName("Proxy");
|
||||
if (proxy == nullptr) {
|
||||
Base::Console().Error("DVA::execute - %s is not an ArchSection\n", sourceObj->Label.getValue());
|
||||
//this is definitely not an ArchSection
|
||||
return DrawView::execute();
|
||||
}
|
||||
|
||||
if (sourceObj) {
|
||||
std::string svgFrag;
|
||||
std::string svgHead = getSVGHead();
|
||||
|
||||
@@ -30,7 +30,9 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <Base/Exception.h>
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/PyObjectBase.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
@@ -1153,6 +1155,43 @@ void CmdTechDrawArchView::activated(int iMsg)
|
||||
QObject::tr("Select exactly one object."));
|
||||
return;
|
||||
}
|
||||
//if the docObj doesn't have a Proxy property, it definitely isn't an ArchSection
|
||||
App::DocumentObject* frontObj = objects.front();
|
||||
App::Property* proxy = frontObj->getPropertyByName("Proxy");
|
||||
if (proxy == nullptr) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Selected object is not ArchSection."));
|
||||
return;
|
||||
}
|
||||
App::PropertyPythonObject* proxyPy = dynamic_cast<App::PropertyPythonObject*>(proxy);
|
||||
Py::Object proxyObj = proxyPy->getValue();
|
||||
std::stringstream ss;
|
||||
bool proceed = false;
|
||||
if (proxyPy != nullptr) {
|
||||
Base::PyGILStateLocker lock;
|
||||
try {
|
||||
if (proxyObj.hasAttr("__module__")) {
|
||||
Py::String mod(proxyObj.getAttr("__module__"));
|
||||
ss << (std::string)mod;
|
||||
}
|
||||
if (ss.str() == "ArchSectionPlane") {
|
||||
proceed = true;
|
||||
}
|
||||
}
|
||||
catch (Py::Exception&) {
|
||||
Base::PyException e; // extract the Python error text
|
||||
e.ReportException();
|
||||
proceed = false;
|
||||
}
|
||||
} else {
|
||||
proceed = false;
|
||||
}
|
||||
|
||||
if (!proceed) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
|
||||
QObject::tr("Selected object is not ArchSection."));
|
||||
return;
|
||||
}
|
||||
|
||||
std::string PageName = page->getNameInDocument();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user