remove Application::runPythonCode
This commit is contained in:
parent
0ef07032fd
commit
afa37847b5
|
@ -622,16 +622,15 @@ void Application::exportTo(const char* FileName, const char* DocName, const char
|
|||
|
||||
std::string code = str.str();
|
||||
// the original file name is required
|
||||
if (runPythonCode(code.c_str(), false)) {
|
||||
// search for a module that is able to open the exported file because otherwise
|
||||
// it doesn't need to be added to the recent files list (#0002047)
|
||||
std::map<std::string, std::string> importMap = App::GetApplication().getImportFilters(te.c_str());
|
||||
if (!importMap.empty())
|
||||
getMainWindow()->appendRecentFile(QString::fromUtf8(File.filePath().c_str()));
|
||||
}
|
||||
Gui::Command::runCommand(Gui::Command::App, code.c_str());
|
||||
// search for a module that is able to open the exported file because otherwise
|
||||
// it doesn't need to be added to the recent files list (#0002047)
|
||||
std::map<std::string, std::string> importMap = App::GetApplication().getImportFilters(te.c_str());
|
||||
if (!importMap.empty())
|
||||
getMainWindow()->appendRecentFile(QString::fromUtf8(File.filePath().c_str()));
|
||||
|
||||
// allow exporters to pass _objs__ to submodules before deleting it
|
||||
runPythonCode("del __objs__", false);
|
||||
Gui::Command::runCommand(Gui::Command::App, "del __objs__");
|
||||
}
|
||||
catch (const Base::PyException& e){
|
||||
// Usually thrown if the file is invalid somehow
|
||||
|
@ -1363,49 +1362,6 @@ CommandManager &Application::commandManager(void)
|
|||
return d->commandManager;
|
||||
}
|
||||
|
||||
bool Application::runPythonCode(const char* cmd, bool gui, bool pyexc)
|
||||
{
|
||||
if (gui)
|
||||
d->macroMngr->addLine(MacroManager::Gui,cmd);
|
||||
else
|
||||
d->macroMngr->addLine(MacroManager::App,cmd);
|
||||
|
||||
try {
|
||||
Base::Interpreter().runString(cmd);
|
||||
return true;
|
||||
}
|
||||
catch (Base::PyException &e) {
|
||||
if (pyexc) {
|
||||
e.ReportException();
|
||||
Base::Console().Error("Stack Trace: %s\n",e.getStackTrace().c_str());
|
||||
}
|
||||
else {
|
||||
throw; // re-throw to handle in calling instance
|
||||
}
|
||||
}
|
||||
catch (Base::AbortException&) {
|
||||
}
|
||||
catch (Base::Exception &e) {
|
||||
e.ReportException();
|
||||
}
|
||||
catch (std::exception &e) {
|
||||
std::string str;
|
||||
str += "C++ exception thrown (";
|
||||
str += e.what();
|
||||
str += ")";
|
||||
Base::Console().Error(str.c_str());
|
||||
}
|
||||
catch (const char* e) {
|
||||
Base::Console().Error("%s\n", e);
|
||||
}
|
||||
#ifndef FC_DEBUG
|
||||
catch (...) {
|
||||
Base::Console().Error("Unknown C++ exception in command thrown\n");
|
||||
}
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
//**************************************************************************
|
||||
// Init, Destruct and ingleton
|
||||
|
||||
|
|
|
@ -178,8 +178,6 @@ public:
|
|||
Gui::MacroManager *macroManager(void);
|
||||
/// Reference to the command manager
|
||||
Gui::CommandManager &commandManager(void);
|
||||
/// Run a Python command
|
||||
bool runPythonCode(const char* cmd, bool gui=false, bool pyexc=true);
|
||||
/// helper which create the commands
|
||||
void createStandardOperations();
|
||||
//@}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#ifndef _PreComp_
|
||||
# include <sstream>
|
||||
# include <QApplication>
|
||||
# include <QByteArray>
|
||||
# include <QDir>
|
||||
# include <QKeySequence>
|
||||
# include <QMessageBox>
|
||||
|
|
|
@ -33,6 +33,8 @@
|
|||
#include <Base/Type.h>
|
||||
|
||||
class QWidget;
|
||||
class QByteArray;
|
||||
|
||||
typedef struct _object PyObject;
|
||||
|
||||
namespace App
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "DlgProjectUtility.h"
|
||||
#include "Application.h"
|
||||
#include "Command.h"
|
||||
#include "ui_DlgProjectUtility.h"
|
||||
|
||||
|
||||
|
@ -140,7 +141,7 @@ void DlgProjectUtility::on_extractButton_clicked()
|
|||
str << doctools << "\n";
|
||||
str << "extractDocument(\"" << (const char*)source.toUtf8()
|
||||
<< "\", \"" << (const char*)dest.toUtf8() << "\")";
|
||||
Application::Instance->runPythonCode(str.str().c_str());
|
||||
Gui::Command::runCommand(Gui::Command::App, str.str().c_str());
|
||||
}
|
||||
|
||||
void DlgProjectUtility::on_createButton_clicked()
|
||||
|
@ -162,7 +163,7 @@ void DlgProjectUtility::on_createButton_clicked()
|
|||
str << doctools << "\n";
|
||||
str << "createDocument(\"" << (const char*)source.toUtf8()
|
||||
<< "\", \"" << (const char*)dest.toUtf8() << "\")";
|
||||
Application::Instance->runPythonCode(str.str().c_str());
|
||||
Gui::Command::runCommand(Gui::Command::App, str.str().c_str());
|
||||
|
||||
if (ui->checkLoadProject->isChecked())
|
||||
Application::Instance->open((const char*)dest.toUtf8(),"FreeCAD");
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
#include <App/Document.h>
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
|
||||
#include <QDomDocument>
|
||||
|
@ -212,7 +213,7 @@ QString DocumentRecovery::createProjectFile(const QString& documentXml)
|
|||
str << doctools << "\n";
|
||||
str << "createDocument(\"" << (const char*)source.toUtf8()
|
||||
<< "\", \"" << (const char*)dest.toUtf8() << "\")";
|
||||
Application::Instance->runPythonCode(str.str().c_str());
|
||||
Gui::Command::runCommand(Gui::Command::App, str.str().c_str());
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "ui_Placement.h"
|
||||
#include <Gui/DockWindowManager.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
|
@ -230,7 +231,7 @@ void Placement::applyPlacement(const QString& data, bool incremental)
|
|||
.arg(data);
|
||||
}
|
||||
|
||||
Application::Instance->runPythonCode((const char*)cmd.toLatin1());
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@
|
|||
#include <App/DocumentObjectGroup.h>
|
||||
|
||||
#include "Tree.h"
|
||||
#include "Command.h"
|
||||
#include "Document.h"
|
||||
#include "BitmapFactory.h"
|
||||
#include "ViewProviderDocumentObject.h"
|
||||
|
@ -226,7 +227,7 @@ void TreeWidget::onCreateGroup()
|
|||
.arg(QString::fromLatin1(doc->getName())).arg(name);
|
||||
Gui::Document* gui = Gui::Application::Instance->getDocument(doc);
|
||||
gui->openCommand("Create group");
|
||||
Gui::Application::Instance->runPythonCode(cmd.toUtf8());
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toUtf8());
|
||||
gui->commitCommand();
|
||||
}
|
||||
else if (this->contextItem->type() == ObjectType) {
|
||||
|
@ -241,7 +242,7 @@ void TreeWidget::onCreateGroup()
|
|||
.arg(name);
|
||||
Gui::Document* gui = Gui::Application::Instance->getDocument(doc);
|
||||
gui->openCommand("Create group");
|
||||
Gui::Application::Instance->runPythonCode(cmd.toUtf8());
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toUtf8());
|
||||
gui->commitCommand();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -208,7 +208,7 @@ void ViewProviderDocumentObjectGroup::drop(const std::vector<const App::Document
|
|||
.arg(QString::fromLatin1(doc->getName()))
|
||||
.arg(QString::fromLatin1(par->getNameInDocument()))
|
||||
.arg(QString::fromLatin1(obj->getNameInDocument()));
|
||||
Gui::Application::Instance->runPythonCode(cmd.toUtf8());
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toUtf8());
|
||||
}
|
||||
|
||||
// build Python command for execution
|
||||
|
@ -219,7 +219,7 @@ void ViewProviderDocumentObjectGroup::drop(const std::vector<const App::Document
|
|||
.arg(QString::fromLatin1(grp->getNameInDocument()))
|
||||
.arg(QString::fromLatin1(obj->getNameInDocument()));
|
||||
|
||||
Gui::Application::Instance->runPythonCode(cmd.toUtf8());
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toUtf8());
|
||||
}
|
||||
gui->commitCommand();
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
|
||||
#include <Base/Tools.h>
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Interpreter.h>
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
|
@ -44,6 +45,7 @@
|
|||
#include <App/PropertyUnits.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
|
@ -53,7 +55,7 @@
|
|||
#include <Gui/QuantitySpinBox.h>
|
||||
|
||||
#include "PropertyItem.h"
|
||||
#include <SpinBox.h>
|
||||
#include <Gui/SpinBox.h>
|
||||
|
||||
using namespace Gui::PropertyEditor;
|
||||
|
||||
|
@ -353,7 +355,19 @@ void PropertyItem::setPropertyValue(const QString& value)
|
|||
App::PropertyContainer* parent = (*it)->getContainer();
|
||||
if (parent && !parent->isReadOnly(*it) && !(*it)->testStatus(App::Property::ReadOnly)) {
|
||||
QString cmd = QString::fromLatin1("%1 = %2").arg(pythonIdentifier(*it)).arg(value);
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toUtf8());
|
||||
try {
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toUtf8());
|
||||
}
|
||||
catch (Base::PyException &e) {
|
||||
e.ReportException();
|
||||
Base::Console().Error("Stack Trace: %s\n",e.getStackTrace().c_str());
|
||||
}
|
||||
catch (Base::Exception &e) {
|
||||
e.ReportException();
|
||||
}
|
||||
catch (...) {
|
||||
Base::Console().Error("Unknown C++ exception in PropertyItem::setPropertyValue thrown\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
|
@ -232,29 +233,28 @@ void CrossSections::apply()
|
|||
section->purgeTouched();
|
||||
}
|
||||
#else
|
||||
Gui::Application* app = Gui::Application::Instance;
|
||||
Base::SequencerLauncher seq("Cross-sections...", obj.size() * (d.size() +1));
|
||||
app->runPythonCode("import Part\n");
|
||||
app->runPythonCode("from FreeCAD import Base\n");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part\n");
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base\n");
|
||||
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
|
||||
App::Document* doc = (*it)->getDocument();
|
||||
std::string s = (*it)->getNameInDocument();
|
||||
s += "_cs";
|
||||
app->runPythonCode(QString::fromLatin1(
|
||||
Gui::Command::runCommand(Gui::Command::App, QString::fromLatin1(
|
||||
"wires=list()\n"
|
||||
"shape=FreeCAD.getDocument(\"%1\").%2.Shape\n")
|
||||
.arg(QLatin1String(doc->getName()))
|
||||
.arg(QLatin1String((*it)->getNameInDocument())).toLatin1());
|
||||
|
||||
for (std::vector<double>::iterator jt = d.begin(); jt != d.end(); ++jt) {
|
||||
app->runPythonCode(QString::fromLatin1(
|
||||
Gui::Command::runCommand(Gui::Command::App, QString::fromLatin1(
|
||||
"for i in shape.slice(Base.Vector(%1,%2,%3),%4):\n"
|
||||
" wires.append(i)\n"
|
||||
).arg(a).arg(b).arg(c).arg(*jt).toLatin1());
|
||||
seq.next();
|
||||
}
|
||||
|
||||
app->runPythonCode(QString::fromLatin1(
|
||||
Gui::Command::runCommand(Gui::Command::App, QString::fromLatin1(
|
||||
"comp=Part.Compound(wires)\n"
|
||||
"slice=FreeCAD.getDocument(\"%1\").addObject(\"Part::Feature\",\"%2\")\n"
|
||||
"slice.Shape=comp\n"
|
||||
|
|
|
@ -679,7 +679,7 @@ void DlgFilletEdges::changeEvent(QEvent *e)
|
|||
int id = model->data(model->index(i, 0), Qt::UserRole).toInt();
|
||||
model->setData(model->index(i, 0), QVariant(tr("Edge%1").arg(id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
|
@ -936,7 +936,7 @@ bool DlgFilletEdges::accept()
|
|||
"del __fillets__\n"
|
||||
"FreeCADGui.ActiveDocument.%2.Visibility = False\n")
|
||||
.arg(name).arg(shape);
|
||||
Gui::Application::Instance->runPythonCode((const char*)code.toLatin1());
|
||||
Gui::Command::runCommand(Gui::Command::App, code.toLatin1());
|
||||
activeDoc->commitTransaction();
|
||||
activeDoc->recompute();
|
||||
if (d->fillet) {
|
||||
|
|
|
@ -405,7 +405,7 @@ void DlgRevolution::accept()
|
|||
.arg(strAxisLink) //%12
|
||||
.arg(symmetric) //13
|
||||
;
|
||||
Gui::Application::Instance->runPythonCode((const char*)code.toLatin1());
|
||||
Gui::Command::runCommand(Gui::Command::App, code.toLatin1());
|
||||
QByteArray to = name.toLatin1();
|
||||
QByteArray from = shape.toLatin1();
|
||||
Gui::Command::copyVisual(to, "ShapeColor", from);
|
||||
|
|
|
@ -171,7 +171,7 @@ bool Mirroring::accept()
|
|||
.arg(this->document).arg(shape).arg(label)
|
||||
.arg(normx).arg(normy).arg(normz)
|
||||
.arg(basex).arg(basey).arg(basez);
|
||||
Gui::Application::Instance->runPythonCode((const char*)code.toLatin1());
|
||||
Gui::Command::runCommand(Gui::Command::App, code.toLatin1());
|
||||
QByteArray from = shape.toLatin1();
|
||||
Gui::Command::copyVisual("ActiveObject", "ShapeColor", from);
|
||||
Gui::Command::copyVisual("ActiveObject", "LineColor", from);
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
|
@ -66,8 +67,8 @@ public:
|
|||
LoftWidget::LoftWidget(QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part");
|
||||
|
||||
d->ui.setupUi(this);
|
||||
d->ui.selector->setAvailableLabel(tr("Vertex/Edge/Wire/Face"));
|
||||
|
@ -175,7 +176,7 @@ bool LoftWidget::accept()
|
|||
Gui::Document* doc = Gui::Application::Instance->getDocument(d->document.c_str());
|
||||
if (!doc) throw Base::Exception("Document doesn't exist anymore");
|
||||
doc->openCommand("Loft");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
doc->getDocument()->recompute();
|
||||
App::DocumentObject* obj = doc->getDocument()->getActiveObject();
|
||||
if (obj && !obj->isValid()) {
|
||||
|
|
|
@ -68,8 +68,8 @@ public:
|
|||
OffsetWidget::OffsetWidget(Part::Offset* offset, QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part");
|
||||
|
||||
d->offset = offset;
|
||||
d->ui.setupUi(this);
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
|
@ -85,29 +86,28 @@ namespace PartGui {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
class ShapeBuilderWidget::Private
|
||||
{
|
||||
public:
|
||||
|
||||
class ShapeBuilderWidget::Private
|
||||
{
|
||||
public:
|
||||
Ui_TaskShapeBuilder ui;
|
||||
QButtonGroup bg;
|
||||
ShapeSelection* gate;
|
||||
Private()
|
||||
{
|
||||
}
|
||||
~Private()
|
||||
{
|
||||
}
|
||||
};
|
||||
{
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part");
|
||||
}
|
||||
~Private()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/* TRANSLATOR PartGui::ShapeBuilderWidget */
|
||||
|
||||
ShapeBuilderWidget::ShapeBuilderWidget(QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
|
||||
d->ui.setupUi(this);
|
||||
d->ui.label->setText(QString());
|
||||
d->bg.addButton(d->ui.radioButtonEdgeFromVertex, 0);
|
||||
|
@ -157,10 +157,10 @@ void ShapeBuilderWidget::on_createButton_clicked()
|
|||
}
|
||||
doc->getDocument()->recompute();
|
||||
Gui::Selection().clearSelection();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
}
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::createEdgeFromVertex()
|
||||
|
@ -200,14 +200,14 @@ void ShapeBuilderWidget::createEdgeFromVertex()
|
|||
).arg(elements[0]).arg(elements[1]);
|
||||
|
||||
try {
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Edge");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Edge");
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::createFaceFromVertex()
|
||||
|
@ -252,14 +252,14 @@ void ShapeBuilderWidget::createFaceFromVertex()
|
|||
}
|
||||
|
||||
try {
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Face");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Face");
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::createFaceFromEdge()
|
||||
|
@ -304,14 +304,14 @@ void ShapeBuilderWidget::createFaceFromEdge()
|
|||
}
|
||||
|
||||
try {
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Face");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Face");
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::createShellFromFace()
|
||||
|
@ -367,14 +367,14 @@ void ShapeBuilderWidget::createShellFromFace()
|
|||
}
|
||||
|
||||
try {
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Shell");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Shell");
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::createSolidFromShell()
|
||||
|
@ -419,14 +419,14 @@ void ShapeBuilderWidget::createSolidFromShell()
|
|||
}
|
||||
|
||||
try {
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Solid");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Solid");
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::switchMode(int mode)
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
|
@ -127,8 +128,8 @@ public:
|
|||
SweepWidget::SweepWidget(QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part");
|
||||
|
||||
d->ui.setupUi(this);
|
||||
d->ui.selector->setAvailableLabel(tr("Vertex/Edge/Wire/Face"));
|
||||
|
@ -321,7 +322,7 @@ bool SweepWidget::accept()
|
|||
Gui::Document* doc = Gui::Application::Instance->getDocument(d->document.c_str());
|
||||
if (!doc) throw Base::Exception("Document doesn't exist anymore");
|
||||
doc->openCommand("Sweep");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
doc->getDocument()->recompute();
|
||||
App::DocumentObject* obj = doc->getDocument()->getActiveObject();
|
||||
if (obj && !obj->isValid()) {
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Mod/Part/App/PartFeatures.h>
|
||||
|
||||
|
||||
|
@ -90,8 +91,8 @@ public:
|
|||
ThicknessWidget::ThicknessWidget(Part::Thickness* thickness, QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part");
|
||||
|
||||
d->thickness = thickness;
|
||||
d->ui.setupUi(this);
|
||||
|
|
Loading…
Reference in New Issue
Block a user