Attacher: Py: implement Attacher attribute of AttachableObject
This commit is contained in:
parent
7000d551b7
commit
dcc8926236
|
@ -78,7 +78,7 @@ public:
|
|||
*/
|
||||
bool changeAttacherType(const char* typeName);
|
||||
|
||||
Attacher::AttachEngine &attacher(void) const {return *_attacher;}
|
||||
Attacher::AttachEngine &attacher(void) const {if(!_attacher) throw Base::Exception("AttachableObject: no attacher is set."); return *_attacher;}
|
||||
|
||||
|
||||
App::PropertyString AttacherType;
|
||||
|
|
|
@ -30,5 +30,12 @@ typename: string. The following are accepted so far:
|
|||
'Attacher::AttachEnginePoint'</UserDocu>
|
||||
</Documentation>
|
||||
</Methode>
|
||||
|
||||
<Attribute Name="Attacher" ReadOnly="true">
|
||||
<Documentation>
|
||||
<UserDocu>AttachEngine object driving this AttachableObject. Returns a copy.</UserDocu>
|
||||
</Documentation>
|
||||
<Parameter Name="Attacher" Type="Object" />
|
||||
</Attribute>
|
||||
</PythonExport>
|
||||
</GenerateModel>
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "Mod/Part/App/AttachableObject.h"
|
||||
#include "OCCError.h"
|
||||
|
||||
#include "AttachEnginePy.h"
|
||||
|
||||
// inclusion of the generated files (generated out of AttachableObjectPy.xml)
|
||||
#include "AttachableObjectPy.h"
|
||||
#include "AttachableObjectPy.cpp"
|
||||
|
@ -53,6 +55,24 @@ PyObject* AttachableObjectPy::changeAttacherType(PyObject *args)
|
|||
return Py::new_reference_to(Py::Boolean(ret));
|
||||
}
|
||||
|
||||
Py::Object AttachableObjectPy::getAttacher(void) const
|
||||
{
|
||||
try {
|
||||
this->getAttachableObjectPtr()->attacher(); //throws if attacher is not set
|
||||
} catch (Base::Exception) {
|
||||
return Py::None();
|
||||
}
|
||||
|
||||
try {
|
||||
return Py::Object( new Attacher::AttachEnginePy(this->getAttachableObjectPtr()->attacher().copy()), true);
|
||||
} catch (Standard_Failure) {
|
||||
Handle_Standard_Failure e = Standard_Failure::Caught();
|
||||
throw Py::Exception(Part::PartExceptionOCCError, e->GetMessageString());
|
||||
} catch (Base::Exception &e) {
|
||||
throw Py::Exception(Base::BaseExceptionFreeCADError, e.what());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
PyObject *AttachableObjectPy::getCustomAttributes(const char* /*attr*/) const
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue
Block a user