[Sketcher] [Post 1.0] Allow CarbonCopy to work with SketchObjectPython (#15594)

This commit is contained in:
Syres916
2024-12-09 17:31:04 +00:00
committed by GitHub
parent fde778faeb
commit 74e7df9676
2 changed files with 16 additions and 6 deletions

View File

@@ -4557,30 +4557,38 @@ bool SketchObject::isExternalAllowed(App::Document* pDoc, App::DocumentObject* p
bool SketchObject::isCarbonCopyAllowed(App::Document* pDoc, App::DocumentObject* pObj, bool& xinv,
bool& yinv, eReasonList* rsn) const
{
if (rsn)
if (rsn) {
*rsn = rlAllowed;
}
std::string sketchArchType ("Sketcher::SketchObjectPython");
// Only applicable to sketches
if (pObj->getTypeId() != Sketcher::SketchObject::getClassTypeId()) {
if (rsn)
if (pObj->getTypeId() != Sketcher::SketchObject::getClassTypeId()
&& sketchArchType != pObj->getTypeId().getName()) {
if (rsn) {
*rsn = rlNotASketch;
}
return false;
}
SketchObject* psObj = static_cast<SketchObject*>(pObj);
// Sketches outside of the Document are NOT allowed
if (this->getDocument() != pDoc) {
if (rsn)
if (rsn) {
*rsn = rlOtherDoc;
}
return false;
}
// circular reference prevention
try {
if (!(this->testIfLinkDAGCompatible(pObj))) {
if (rsn)
if (rsn) {
*rsn = rlCircularReference;
}
return false;
}
}

View File

@@ -160,7 +160,9 @@ public:
throw Base::ValueError("Sketcher: Carbon Copy: Invalid object in selection");
}
if (obj->is<Sketcher::SketchObject>()) {
std::string sketchArchType("Sketcher::SketchObjectPython");
if (obj->is<Sketcher::SketchObject>() || sketchArchType == obj->getTypeId().getName()) {
try {
Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create a carbon copy"));