Skip to content

Commit

Permalink
PD: Delete support if invalid after changing mapping mode
Browse files Browse the repository at this point in the history
  • Loading branch information
abdullahtahiriyo committed Apr 23, 2017
1 parent 444cfc3 commit 9117610
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/Mod/Part/App/AttachExtension.cpp
Expand Up @@ -30,6 +30,8 @@
#include <Base/Console.h>
#include <App/Application.h>

#include <App/DocumentObject.h>

#include <App/FeaturePythonPyImp.h>
#include "AttachExtensionPy.h"

Expand Down Expand Up @@ -135,8 +137,36 @@ short int AttachExtension::extensionMustExecute(void) {
App::DocumentObjectExecReturn *AttachExtension::extensionExecute()
{
if(this->isTouched_Mapping()) {

if (!_attacher)
throw Base::Exception("AttachExtension: can't positionBySupport, because no AttachEngine is set.");
updateAttacherVals();

SuggestResult sr;

_attacher->suggestMapModes(sr);

bool acceptableattachment = false;

for(std::vector<eMapMode>::const_iterator it = sr.allApplicableModes.begin() ; it != sr.allApplicableModes.end(); it++)
{
if ( (*it) == eMapMode(this->MapMode.getValue()))
acceptableattachment = true;
}

try{
positionBySupport();
if(acceptableattachment) {
positionBySupport();
}
else {
std::vector<App::DocumentObject*> Objects = this->Support.getValues();
std::vector<std::string> SubElements = this->Support.getSubValues();

Objects.clear();
SubElements.clear();

this->Support.setValues(Objects,SubElements);
}
} catch (Base::Exception &e) {
return new App::DocumentObjectExecReturn(e.what());
} catch (Standard_Failure &e){
Expand Down

0 comments on commit 9117610

Please sign in to comment.