Fix handling of MultiTransform features when migrating to Body
This commit is contained in:
parent
f3fbf6f285
commit
d550506f28
|
@ -187,6 +187,17 @@ const bool Body::isAfterTip(const App::DocumentObject *f) {
|
||||||
return (it > tip);
|
return (it > tip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool Body::isMemberOfMultiTransform(const App::DocumentObject* f)
|
||||||
|
{
|
||||||
|
if (f == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// This can be recognized because the Originals property is empty (it is contained
|
||||||
|
// in the MultiTransform instead)
|
||||||
|
return (f->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()) &&
|
||||||
|
static_cast<const PartDesign::Transformed*>(f)->Originals.getValues().empty());
|
||||||
|
}
|
||||||
|
|
||||||
const bool Body::isSolidFeature(const App::DocumentObject* f)
|
const bool Body::isSolidFeature(const App::DocumentObject* f)
|
||||||
{
|
{
|
||||||
if (f == NULL)
|
if (f == NULL)
|
||||||
|
@ -194,12 +205,7 @@ const bool Body::isSolidFeature(const App::DocumentObject* f)
|
||||||
|
|
||||||
if (f->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId())) {
|
if (f->getTypeId().isDerivedFrom(PartDesign::Feature::getClassTypeId())) {
|
||||||
// Transformed Features inside a MultiTransform are not solid features
|
// Transformed Features inside a MultiTransform are not solid features
|
||||||
// They can be recognized because the Originals property is empty (it is contained
|
return !isMemberOfMultiTransform(f);
|
||||||
// in the MultiTransform instead)
|
|
||||||
if (f->getTypeId().isDerivedFrom(PartDesign::Transformed::getClassTypeId()) &&
|
|
||||||
static_cast<const PartDesign::Transformed*>(f)->Originals.getValues().empty())
|
|
||||||
return false;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,9 @@ public:
|
||||||
/// Remove the feature from the body
|
/// Remove the feature from the body
|
||||||
void removeFeature(App::DocumentObject* feature);
|
void removeFeature(App::DocumentObject* feature);
|
||||||
|
|
||||||
|
/// Return true if the given feature is member of a MultiTransform feature
|
||||||
|
static const bool isMemberOfMultiTransform(const App::DocumentObject* f);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return true if the given feature is a solid feature allowed in a Body. Currently this is only valid
|
* Return true if the given feature is a solid feature allowed in a Body. Currently this is only valid
|
||||||
* for features derived from PartDesign::Feature
|
* for features derived from PartDesign::Feature
|
||||||
|
|
|
@ -160,6 +160,9 @@ void switchToDocument(const App::Document* doc)
|
||||||
do {
|
do {
|
||||||
std::set<App::DocumentObject*> newInList;
|
std::set<App::DocumentObject*> newInList;
|
||||||
for (std::set<App::DocumentObject*>::const_iterator o = inList.begin(); o != inList.end(); o++) {
|
for (std::set<App::DocumentObject*>::const_iterator o = inList.begin(); o != inList.end(); o++) {
|
||||||
|
// Omit members of a MultiTransform from the inList, to avoid migration errors
|
||||||
|
if (PartDesign::Body::isMemberOfMultiTransform(*o))
|
||||||
|
continue;
|
||||||
std::vector<App::DocumentObject*> iL = doc->getInList(*o);
|
std::vector<App::DocumentObject*> iL = doc->getInList(*o);
|
||||||
newInList.insert(iL.begin(), iL.end());
|
newInList.insert(iL.begin(), iL.end());
|
||||||
}
|
}
|
||||||
|
@ -181,7 +184,14 @@ void switchToDocument(const App::Document* doc)
|
||||||
if (!modelString.empty()) {
|
if (!modelString.empty()) {
|
||||||
modelString = std::string("[") + modelString + "]";
|
modelString = std::string("[") + modelString + "]";
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Model = %s", activeBody->getNameInDocument(), modelString.c_str());
|
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Model = %s", activeBody->getNameInDocument(), modelString.c_str());
|
||||||
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Tip = App.activeDocument().%s", activeBody->getNameInDocument(), bodyFeatures.back()->getNameInDocument());
|
// Set the Tip, but not to a member of a MultiTransform!
|
||||||
|
for (std::vector<App::DocumentObject*>::const_reverse_iterator f = bodyFeatures.rbegin(); f != bodyFeatures.rend(); f++) {
|
||||||
|
if (PartDesign::Body::isMemberOfMultiTransform(*f))
|
||||||
|
continue;
|
||||||
|
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Tip = App.activeDocument().%s",
|
||||||
|
activeBody->getNameInDocument(), (*f)->getNameInDocument());
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize the BaseFeature property of all PartDesign solid features
|
// Initialize the BaseFeature property of all PartDesign solid features
|
||||||
|
|
Loading…
Reference in New Issue
Block a user