Sketcher: Reassign virtual space flag to constraints after modifying them through a default DHS

This commit is contained in:
theo-vt
2025-10-02 23:21:32 -04:00
committed by Chris Hennes
parent 63108f56a0
commit 2db0ac4403
2 changed files with 37 additions and 0 deletions

View File

@@ -1205,10 +1205,13 @@ protected:
Sketcher::PythonConverter::Mode::OmitInternalGeometry)
.c_str());
size_t initialConstraintCount = sketchgui->getSketchObject()->Constraints.getSize();
auto shapeConstraints = toPointerVector(ShapeConstraints);
Gui::Command::doCommand(
Gui::Command::Doc,
Sketcher::PythonConverter::convert(sketchObj, shapeConstraints).c_str());
reassignVirtualSpace(initialConstraintCount);
}
/** @brief Function to draw as an edit curve all the geometry in the ShapeGeometry vector.*/
@@ -1226,6 +1229,39 @@ protected:
//@}
private:
// Reassign the correct virtual space index for the added constraints
void reassignVirtualSpace(size_t startIndex)
{
if (ShapeConstraints.empty()) {
return;
}
std::stringstream stream;
bool hasConstraintsInVirtualSpace = false;
for (size_t i = 0; i < ShapeConstraints.size(); ++i) {
if (ShapeConstraints[i]->isInVirtualSpace) {
if (hasConstraintsInVirtualSpace) {
stream << ",";
}
stream << i + startIndex;
hasConstraintsInVirtualSpace = true;
}
}
if (!hasConstraintsInVirtualSpace) {
return;
}
try {
Gui::cmdAppObjectArgs(sketchgui->getObject(),
"setVirtualSpace([%s], True)",
stream.str().c_str());
}
catch (const Base::Exception& e) {
Base::Console().error("%s\n", e.what());
}
}
protected:
std::vector<std::vector<AutoConstraint>> sugConstraints;

View File

@@ -341,6 +341,7 @@ private:
return;
}
listOfFacadeIds.clear();
for (auto& geoId : listOfGeoIds) {
const Part::Geometry* pGeo = Obj->getGeometry(geoId);
long facadeId;