diff --git a/src/App/Application.cpp b/src/App/Application.cpp index b0214707a0..26eebff5e5 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -100,6 +100,7 @@ #include "OriginFeature.h" #include "Origin.h" #include "MaterialObject.h" +#include "MaterialPy.h" #include "Expression.h" // If you stumble here, run the target "BuildExtractRevision" on Windows systems @@ -233,6 +234,8 @@ Application::Application(std::map &mConfig) Base::Interpreter().addType(&Base::RotationPy ::Type,pBaseModule,"Rotation"); Base::Interpreter().addType(&Base::AxisPy ::Type,pBaseModule,"Axis"); + Base::Interpreter().addType(&App::MaterialPy::Type, pAppModule, "Material"); + //insert Base and Console Py_INCREF(pBaseModule); PyModule_AddObject(pAppModule, "Base", pBaseModule); diff --git a/src/App/MaterialPy.xml b/src/App/MaterialPy.xml index 0697aa3d42..3007e54dc9 100644 --- a/src/App/MaterialPy.xml +++ b/src/App/MaterialPy.xml @@ -9,6 +9,7 @@ Namespace="App" FatherInclude="Base/PyObjectBase.h" FatherNamespace="Base" + Constructor="true" Delete="true"> diff --git a/src/App/MaterialPyImp.cpp b/src/App/MaterialPyImp.cpp index ef766334f9..cbae386dce 100644 --- a/src/App/MaterialPyImp.cpp +++ b/src/App/MaterialPyImp.cpp @@ -31,6 +31,54 @@ using namespace App; +PyObject *MaterialPy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper +{ + // create a new instance of MaterialPy and the Twin object + return new MaterialPy(new Material); +} + +// constructor method +int MaterialPy::PyInit(PyObject* args, PyObject* kwds) +{ + PyObject* diffuse = 0; + PyObject* ambient = 0; + PyObject* specular = 0; + PyObject* emissive = 0; + PyObject* shininess = 0; + PyObject* transpareny = 0; + static char* kwds_colors[] = { "DiffuseColor", "AmbientColor", "SpecularColor", "EmissiveColor", "Shininess", "Transparency", NULL }; + + if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOOOO", kwds_colors, + &diffuse, &ambient, &specular, &emissive, &shininess, &transpareny)) + return -1; + + if (diffuse) { + setDiffuseColor(Py::Tuple(diffuse)); + } + + if (ambient) { + setAmbientColor(Py::Tuple(ambient)); + } + + if (specular) { + setSpecularColor(Py::Tuple(specular)); + } + + if (emissive) { + setEmissiveColor(Py::Tuple(emissive)); + } + + if (shininess) { + setShininess(Py::Float(shininess)); + } + + if (transpareny) { + setTransparency(Py::Float(transpareny)); + } + + return 0; +} + // returns a string which represents the object e.g. when printed in python std::string MaterialPy::representation(void) const {