PartDesign Body migration: Fix migration of MultiTransform sub-features

This commit is contained in:
jrheinlaender 2013-07-26 15:56:56 +02:00 committed by Stefan Tröger
parent b2dd70e635
commit 36a00f45b6
2 changed files with 23 additions and 0 deletions

View File

@ -34,6 +34,7 @@
#include <Gui/Application.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/PartDesign/App/FeatureSketchBased.h>
#include <Mod/PartDesign/App/FeatureMultiTransform.h>
#include <Mod/PartDesign/App/DatumLine.h>
#include <Mod/PartDesign/App/DatumPlane.h>
#include <algorithm>
@ -120,6 +121,14 @@ std::vector<App::DocumentObject*> ViewProviderBody::claimChildren(void)const
if (sketch != NULL)
OutSet.insert(sketch);
}
// Transformations of a MultiTransform feature get claimed under the feature, too
if ((*it)->isDerivedFrom(PartDesign::MultiTransform::getClassTypeId())) {
std::vector<App::DocumentObject*> trfs = static_cast<PartDesign::MultiTransform*>(*it)->Transformations.getValues();
for (std::vector<App::DocumentObject*>::const_iterator t = trfs.begin(); t != trfs.end(); t++)
if ((*t) != NULL)
OutSet.insert(*t);
}
}
// remove the otherwise handled objects, preserving their order so the order in the TreeWidget is correct

View File

@ -50,6 +50,7 @@
#include <Mod/PartDesign/App/Body.h>
#include <Mod/PartDesign/App/Feature.h>
#include <Mod/PartDesign/App/FeatureSketchBased.h>
#include <Mod/PartDesign/App/FeatureMultiTransform.h>
#include <Mod/Part/App/DatumFeature.h>
#include <Mod/Sketcher/App/SketchObject.h>
@ -141,6 +142,19 @@ void switchToDocument(const App::Document* doc)
}
}
// Set BaseFeature property to NULL for members of MultiTransform
for (std::vector<App::DocumentObject*>::const_iterator f = features.begin(); f != features.end(); f++) {
if ((*f)->getTypeId().isDerivedFrom(PartDesign::MultiTransform::getClassTypeId())) {
std::vector<App::DocumentObject*> trfs = static_cast<PartDesign::MultiTransform*>(*f)->Transformations.getValues();
for (std::vector<App::DocumentObject*>::const_iterator t = trfs.begin(); t != trfs.end(); t++) {
if ((*t) != NULL) {
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.BaseFeature = None",
(*t)->getNameInDocument());
}
}
}
}
// Re-route all sketches without support to the base planes
Gui::Command::openCommand("Migrate part to Body feature");
std::vector<App::DocumentObject*>::const_iterator prevf;