23
#include "PreCompiled.h"
28
#include <App/Application.h>
29
#include <App/Document.h>
30
#include <Base/GeometryPyCXX.h>
33
#include "MeasurementPy.h"
34
#include "MeasurementPy.cpp"
37
using namespace Measure;
40
std::string MeasurementPy::representation() const
42
return "<Measure::Measurement>";
45
PyObject* MeasurementPy::PyMake(struct _typeobject*, PyObject*, PyObject*)
48
return new MeasurementPy(new Measurement);
52
int MeasurementPy::PyInit(PyObject* , PyObject* )
57
PyObject* MeasurementPy::addReference3D(PyObject* args)
61
if (!PyArg_ParseTuple(args, "ss:Give an object and subelement name", &ObjectName, &SubName)) {
66
App::DocumentObject* Obj = App::GetApplication().getActiveDocument()->getObject(ObjectName);
68
std::stringstream str;
69
str << ObjectName << "does not exist in the document";
70
PyErr_SetString(PyExc_ValueError, str.str().c_str());
75
if (this->getMeasurementPtr()->addReference3D(Obj, SubName) < 0) {
76
std::stringstream str;
77
str << "Not able to add reference";
78
PyErr_SetString(PyExc_ValueError, str.str().c_str());
85
PyObject* MeasurementPy::has3DReferences(PyObject* args)
87
PyObject* result = Py_False;
88
if (!PyArg_ParseTuple(args, "")) {
92
if (getMeasurementPtr()->has3DReferences()) {
100
PyObject* MeasurementPy::clear(PyObject* args)
102
if (!PyArg_ParseTuple(args, "")) {
106
this->getMeasurementPtr()->clear();
111
PyObject* MeasurementPy::delta(PyObject* args)
113
if (!PyArg_ParseTuple(args, "")) {
117
Py::Vector delta(this->getMeasurementPtr()->delta());
119
return Py::new_reference_to(delta);
122
PyObject* MeasurementPy::length(PyObject* args)
124
if (!PyArg_ParseTuple(args, "")) {
129
length = this->getMeasurementPtr()->length();
131
return Py::new_reference_to(length);
134
PyObject* MeasurementPy::lineLineDistance(PyObject* args)
136
if (!PyArg_ParseTuple(args, "")) {
141
length = this->getMeasurementPtr()->lineLineDistance();
143
return Py::new_reference_to(length);
146
PyObject* MeasurementPy::planePlaneDistance(PyObject* args)
148
if (!PyArg_ParseTuple(args, "")) {
153
length = this->getMeasurementPtr()->planePlaneDistance();
155
return Py::new_reference_to(length);
158
PyObject* MeasurementPy::volume(PyObject* args)
160
if (!PyArg_ParseTuple(args, "")) {
165
length = this->getMeasurementPtr()->volume();
167
return Py::new_reference_to(length);
170
PyObject* MeasurementPy::area(PyObject* args)
172
if (!PyArg_ParseTuple(args, "")) {
177
length = this->getMeasurementPtr()->area();
179
return Py::new_reference_to(length);
182
PyObject* MeasurementPy::radius(PyObject* args)
184
if (!PyArg_ParseTuple(args, "")) {
189
radius = this->getMeasurementPtr()->radius();
191
return Py::new_reference_to(radius);
194
PyObject* MeasurementPy::angle(PyObject* args)
196
if (!PyArg_ParseTuple(args, "")) {
201
angle = this->getMeasurementPtr()->angle();
203
return Py::new_reference_to(angle);
206
PyObject* MeasurementPy::com(PyObject* args)
208
if (!PyArg_ParseTuple(args, "")) {
212
Py::Vector com(this->getMeasurementPtr()->massCenter());
214
return Py::new_reference_to(com);
217
PyObject* MeasurementPy::getCustomAttributes(const char* ) const
222
int MeasurementPy::setCustomAttributes(const char* , PyObject* )