It looks to me that there are some problems in the external geometry code.
I traced the cause as far as the SketchObject::onChanged code:
Code: Select all
void SketchObject::onChanged(const App::Property* prop)
...
else if (prop == &Support) {
// make sure not to change anything while restoring this object
if (!isRestoring()) {
// if support face was cleared then also clear the external geometry
if (!Support.getValue()) {
std::vector<DocumentObject*> obj;
std::vector<std::string> sub;
ExternalGeometry.setValues(obj, sub)
}
}
This code responds to changes in the SketchObject. If the Support has changed and Support.getValue() is zero (the sketch has been orphaned) it passes two empty vectors to ExternalGeometry.setValues presumably to clear the external geometry list.
Note that the external geometry list is only cleared if the support has changed to zero whereas, I would have thought that it should be cleared in any case that the support member changes, not only when it changes to zero.
It also appears that this resetting of the (App::PropertyLinkSubList) ExternalGeometry is having the knock on effect of breaking the constraints list. I've no idea how that's happening yet.
I have commented out this call to ExternalGeometry.setValues in my code and the constraints are preserved when orphaning a sketch.
Note that, as the code stands, you can remap a sketch to a different face and the external geometry list is not cleared. You can make a change in the tree that completely changes the edge/face numbering and the external geometry list is not cleared. It seems in this situation that there is little benefit in clearing the external geometry list in the SketchObject::onChanged code.