Assembly: Isolate joint components during selection and edit. (#23680)
* Core: Add signalBeforeOpenTransaction * Assembly: Isolate * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update src/App/AutoTransaction.cpp Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org> --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
This commit is contained in:
@@ -24,6 +24,7 @@
|
||||
#include <Base/Interpreter.h>
|
||||
#include <Base/PlacementPy.h>
|
||||
#include <Base/GeometryPyCXX.h>
|
||||
#include <App/DocumentObjectPy.h>
|
||||
|
||||
// inclusion of the generated files (generated out of ViewProviderAssemblyPy.xml)
|
||||
#include "ViewProviderAssemblyPy.h"
|
||||
@@ -130,3 +131,52 @@ int ViewProviderAssemblyPy::setCustomAttributes(const char* /*attr*/, PyObject*
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
PyObject* ViewProviderAssemblyPy::isolateComponents(PyObject* args)
|
||||
{
|
||||
PyObject* pyList = nullptr;
|
||||
int modeInt = 0;
|
||||
if (!PyArg_ParseTuple(args, "Oi", &pyList, &modeInt)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!PySequence_Check(pyList)) {
|
||||
PyErr_SetString(PyExc_TypeError, "First argument must be a sequence of DocumentObjects");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (modeInt < 0 || modeInt > 2) {
|
||||
PyErr_SetString(PyExc_ValueError, "Mode must be an integer between 0 and 2");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::set<App::DocumentObject*> partsSet;
|
||||
Py_ssize_t size = PySequence_Size(pyList);
|
||||
for (Py_ssize_t i = 0; i < size; ++i) {
|
||||
PyObject* item = PySequence_GetItem(pyList, i);
|
||||
if (item && PyObject_TypeCheck(item, &(App::DocumentObjectPy::Type))) {
|
||||
auto* pyObj = static_cast<App::DocumentObjectPy*>(item);
|
||||
App::DocumentObject* docObj = pyObj->getDocumentObjectPtr();
|
||||
if (docObj) {
|
||||
partsSet.insert(docObj);
|
||||
}
|
||||
}
|
||||
Py_XDECREF(item);
|
||||
}
|
||||
|
||||
auto mode = static_cast<ViewProviderAssembly::IsolateMode>(modeInt);
|
||||
getViewProviderAssemblyPtr()->isolateComponents(partsSet, mode);
|
||||
|
||||
Py_DECREF(Py_None);
|
||||
return Py_None;
|
||||
}
|
||||
|
||||
PyObject* ViewProviderAssemblyPy::clearIsolate(PyObject* args)
|
||||
{
|
||||
if (!PyArg_ParseTuple(args, "")) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
getViewProviderAssemblyPtr()->clearIsolate();
|
||||
return Py::new_reference_to(Py::None());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user