PyObject* AttachEnginePy::readParametersFromFeature(PyObject* args) { PyObject* obj; if (!PyArg_ParseTuple(args, "O!",&(App::DocumentObjectPy::Type),&obj)) return NULL; // NULL triggers exception try{ App::DocumentObjectPy* dobjpy = static_cast<App::DocumentObjectPy*>(obj); App::DocumentObject* dobj = dobjpy->getDocumentObjectPtr(); if (! dobj->hasExtension(Part::AttachExtension::getExtensionClassTypeId())){ throw Py::TypeError("Supplied object has no Part::AttachExtension"); } Part::AttachExtension* feat = dobj->getExtensionByType<Part::AttachExtension>(); AttachEngine &attacher = *(this->getAttachEnginePtr()); attacher.setUp(feat->Support, eMapMode(feat->MapMode.getValue()), feat->MapReversed.getValue(), feat->MapPathParameter.getValue(), 0.0,0.0, feat->AttachmentOffset.getValue()); return Py::new_reference_to(Py::None()); } ATTACHERPY_STDCATCH_METH; }
PyObject* AttachEnginePy::writeParametersToFeature(PyObject* args) { PyObject* obj; if (!PyArg_ParseTuple(args, "O!",&(App::DocumentObjectPy::Type),&obj)) return NULL; // NULL triggers exception try{ App::DocumentObjectPy* dobjpy = static_cast<App::DocumentObjectPy*>(obj); App::DocumentObject* dobj = dobjpy->getDocumentObjectPtr(); if (! dobj->hasExtension(Part::AttachExtension::getExtensionClassTypeId())){ throw Py::TypeError("Supplied object has no Part::AttachExtension"); } Part::AttachExtension* feat = dobj->getExtensionByType<Part::AttachExtension>(); const AttachEngine &attacher = *(this->getAttachEnginePtr()); AttachEngine::verifyReferencesAreSafe(attacher.references); feat->Support.Paste(attacher.references); feat->MapMode.setValue(attacher.mapMode); feat->MapReversed.setValue(attacher.mapReverse); feat->MapPathParameter.setValue(attacher.attachParameter); feat->AttachmentOffset.setValue(attacher.attachmentOffset); return Py::new_reference_to(Py::None()); } ATTACHERPY_STDCATCH_METH; }
void ShapeBinder::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop) { App::Document* doc = getDocument(); if (!doc || doc->testStatus(App::Document::Restoring)) return; if (this == &Obj) return; if (!TraceSupport.getValue()) return; if (!Prop.getTypeId().isDerivedFrom(App::PropertyPlacement::getClassTypeId())) return; Part::Feature* obj = nullptr; std::vector<std::string> subs; ShapeBinder::getFilteredReferences(&Support, obj, subs); if (obj) { if (obj == &Obj) { // the directly referenced object has changed enforceRecompute(); } else if (Obj.hasExtension(App::GroupExtension::getExtensionClassTypeId())) { // check if the changed property belongs to a group-like object // like Body or Part std::vector<App::DocumentObject*> chain; std::vector<App::DocumentObject*> list = getInListRecursive(); chain.insert(chain.end(), list.begin(), list.end()); list = obj->getInListRecursive(); chain.insert(chain.end(), list.begin(), list.end()); auto it = std::find(chain.begin(), chain.end(), &Obj); if (it != chain.end()) { enforceRecompute(); } } } }