Part: fix Part_RefineShape and Part_Section

This commit is contained in:
wmayer
2024-04-06 02:09:20 +02:00
parent 4aa140d066
commit 262a218b6b
2 changed files with 15 additions and 14 deletions

View File

@@ -925,7 +925,7 @@ void CmdPartSection::activated(int iMsg)
doCommand(Doc,"App.activeDocument().%s.Tool = App.activeDocument().%s",FeatName.c_str(),ToolName.c_str());
doCommand(Gui,"Gui.activeDocument().hide('%s')",BaseName.c_str());
doCommand(Gui,"Gui.activeDocument().hide('%s')",ToolName.c_str());
doCommand(Gui,"Gui.activeDocument().%s.LineColor = Gui.activeDocument().%s.ShapeAppearance.DiffuseColor",FeatName.c_str(),BaseName.c_str());
doCommand(Gui,"Gui.activeDocument().%s.LineMaterial = Gui.activeDocument().%s.ShapeAppearance[0]",FeatName.c_str(),BaseName.c_str());
updateActive();
commitCommand();
}

View File

@@ -28,10 +28,11 @@
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <App/DocumentObserver.h>
#include <Base/Exception.h>
#include <Base/Interpreter.h>
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/CommandT.h>
#include <Gui/MainWindow.h>
#include <Gui/Selection.h>
#include <Gui/SelectionObject.h>
@@ -368,19 +369,19 @@ void CmdPartRefineShape::activated(int iMsg)
openCommand(QT_TRANSLATE_NOOP("Command", "Refine shape"));
std::for_each(objs.begin(), objs.end(), [](App::DocumentObject* obj) {
try {
doCommand(Doc,"App.ActiveDocument.addObject('Part::Refine','%s').Source="
"App.ActiveDocument.%s\n"
"App.ActiveDocument.ActiveObject.Label="
"App.ActiveDocument.%s.Label\n"
"Gui.ActiveDocument.%s.hide()\n",
obj->getNameInDocument(),
obj->getNameInDocument(),
obj->getNameInDocument(),
obj->getNameInDocument());
App::DocumentObjectT objT(obj);
Gui::cmdAppDocumentArgs(obj->getDocument(), "addObject('Part::Refine','%s')",
obj->getNameInDocument());
Gui::cmdAppDocumentArgs(obj->getDocument(), "ActiveObject.Source = %s",
objT.getObjectPython());
Gui::cmdAppDocumentArgs(obj->getDocument(), "ActiveObject.Label = %s.Label",
objT.getObjectPython());
Gui::cmdAppObjectHide(obj);
copyVisual("ActiveObject", "ShapeAppearance", obj->getNameInDocument());
copyVisual("ActiveObject", "LineColor", obj->getNameInDocument());
copyVisual("ActiveObject", "PointColor", obj->getNameInDocument());
auto newObj = App::GetApplication().getActiveDocument()->getActiveObject();
Gui::copyVisualT(newObj->getNameInDocument(), "ShapeAppearance", obj->getNameInDocument());
Gui::copyVisualT(newObj->getNameInDocument(), "LineColor", obj->getNameInDocument());
Gui::copyVisualT(newObj->getNameInDocument(), "PointColor", obj->getNameInDocument());
}
catch (const Base::Exception& e) {
Base::Console().Warning("%s: %s\n", obj->Label.getValue(), e.what());