void CmdPartRefineShape::activated(int iMsg) { Gui::WaitCursor wc; Base::Type partid = Base::Type::fromName("Part::Feature"); std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType(partid); openCommand("Refine shape"); for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) { try { doCommand(Doc,"App.ActiveDocument.addObject('Part::Feature','%s').Shape=" "App.ActiveDocument.%s.Shape.removeSplitter()\n" "App.ActiveDocument.ActiveObject.Label=" "App.ActiveDocument.%s.Label\n" "Gui.ActiveDocument.%s.hide()\n", (*it)->getNameInDocument(), (*it)->getNameInDocument(), (*it)->getNameInDocument(), (*it)->getNameInDocument()); copyVisual("ActiveObject", "ShapeColor", (*it)->getNameInDocument()); copyVisual("ActiveObject", "LineColor", (*it)->getNameInDocument()); copyVisual("ActiveObject", "PointColor", (*it)->getNameInDocument()); } catch (const Base::Exception& e) { Base::Console().Warning("%s: %s\n", (*it)->Label.getValue(), e.what()); } } commitCommand(); updateActive(); }
void CmdPartCut::activated(int iMsg) { unsigned int n = getSelection().countObjectsOfType(Part::Feature::getClassTypeId()); if (n != 2) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select two shapes please.")); return; } std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection(); std::string FeatName = getUniqueObjectName("Cut"); std::string BaseName = Sel[0].FeatName; std::string ToolName = Sel[1].FeatName; openCommand("Part Cut"); doCommand(Doc,"App.activeDocument().addObject(\"Part::Cut\",\"%s\")",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.Base = App.activeDocument().%s",FeatName.c_str(),BaseName.c_str()); 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()); copyVisual(FeatName.c_str(), "ShapeColor", BaseName.c_str()); copyVisual(FeatName.c_str(), "DisplayMode", BaseName.c_str()); updateActive(); commitCommand(); }
void CmdPartFuse::activated(int iMsg) { unsigned int n = getSelection().countObjectsOfType(Part::Feature::getClassTypeId()); if (n < 2) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("Select two shapes or more, please.")); return; } std::string FeatName = getUniqueObjectName("Fusion"); std::vector<Gui::SelectionSingleton::SelObj> Sel = getSelection().getSelection(); std::stringstream str; std::vector<std::string> tempSelNames; str << "App.activeDocument()." << FeatName << ".Shapes = ["; for (std::vector<Gui::SelectionSingleton::SelObj>::iterator it = Sel.begin(); it != Sel.end(); ++it){ str << "App.activeDocument()." << it->FeatName << ","; tempSelNames.push_back(it->FeatName); } str << "]"; openCommand("Fusion"); doCommand(Doc,"App.activeDocument().addObject(\"Part::MultiFuse\",\"%s\")",FeatName.c_str()); runCommand(Doc,str.str().c_str()); for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it) doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str()); copyVisual(FeatName.c_str(), "ShapeColor", tempSelNames.front().c_str()); copyVisual(FeatName.c_str(), "DisplayMode", tempSelNames.front().c_str()); updateActive(); commitCommand(); }
void CmdPartSimpleCopy::activated(int iMsg) { Base::Type partid = Base::Type::fromName("Part::Feature"); std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType(partid); openCommand("Create Copy"); for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) { doCommand(Doc,"App.ActiveDocument.addObject('Part::Feature','%s').Shape=" "App.ActiveDocument.%s.Shape\n" "App.ActiveDocument.ActiveObject.Label=" "App.ActiveDocument.%s.Label\n", (*it)->getNameInDocument(), (*it)->getNameInDocument(), (*it)->getNameInDocument()); copyVisual("ActiveObject", "ShapeColor", (*it)->getNameInDocument()); copyVisual("ActiveObject", "LineColor", (*it)->getNameInDocument()); copyVisual("ActiveObject", "PointColor", (*it)->getNameInDocument()); } commitCommand(); updateActive(); }
void CmdPartSimpleCopy::activated(int iMsg) { Q_UNUSED(iMsg); Base::Type partid = Base::Type::fromName("Part::Feature"); std::vector<Gui::SelectionObject> objs = Gui::Selection().getSelectionEx(0, partid); openCommand("Create Copy"); for (std::vector<Gui::SelectionObject>::iterator it = objs.begin(); it != objs.end(); ++it) { doCommand(Doc,"App.ActiveDocument.addObject('Part::Feature','%s').Shape=" "App.ActiveDocument.%s.Shape\n" "App.ActiveDocument.ActiveObject.Label=" "App.ActiveDocument.%s.Label\n", it->getFeatName(), it->getFeatName(), it->getFeatName()); copyVisual("ActiveObject", "ShapeColor", it->getFeatName()); copyVisual("ActiveObject", "LineColor", it->getFeatName()); copyVisual("ActiveObject", "PointColor", it->getFeatName()); copyVisual("ActiveObject", "DiffuseColor", it->getFeatName()); } commitCommand(); updateActive(); }