Ensure we set up a valid sketch even with invalid external references

This commit is contained in:
bgbsww
2024-04-21 16:04:39 -04:00
committed by Yorik van Havre
parent 4ea1ad58c8
commit d7ade12dc3
2 changed files with 66 additions and 1 deletions

View File

@@ -7434,6 +7434,7 @@ void SketchObject::validateExternalLinks()
const std::string SubElement = SubElements[i];
TopoDS_Shape refSubShape;
bool removeBadLink = false;
try {
if (Obj->isDerivedFrom<Part::Datum>()) {
const Part::Datum* datum = static_cast<const Part::Datum*>(Obj);
@@ -7445,7 +7446,15 @@ void SketchObject::validateExternalLinks()
refSubShape = refShape.getSubShape(SubElement.c_str());
}
}
catch ( Base::IndexError& indexError) {
removeBadLink = true;
Base::Console().Warning(
this->getFullLabel(), (indexError.getMessage() + "\n").c_str());
}
catch (Standard_Failure&) {
removeBadLink = true;
}
if ( removeBadLink ) {
rebuild = true;
Objects.erase(Objects.begin() + i);
SubElements.erase(SubElements.begin() + i);
@@ -9548,7 +9557,7 @@ std::pair<std::string,std::string> SketchObject::getElementName(
// Todo: Toponaming Project March 2024: This method override breaks the sketcher - selection and deletion
// of constraints ceases to work. See #13169. We need to prove that this works before
// enabling it. For now, bypass it.
return Part2DObject::getElementName(name,type);
// return Part2DObject::getElementName(name,type);
std::pair<std::string, std::string> ret;
if(!name) return ret;