FreeCAD

Форк
0
/
AttachExtensionPyImp.cpp 
100 строк · 3.6 Кб
1

2
/***************************************************************************
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
6
 *   This library is free software; you can redistribute it and/or         *
7
 *   modify it under the terms of the GNU Library General Public           *
8
 *   License as published by the Free Software Foundation; either          *
9
 *   version 2 of the License, or (at your option) any later version.      *
10
 *                                                                         *
11
 *   This library  is distributed in the hope that it will be useful,      *
12
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14
 *   GNU Library General Public License for more details.                  *
15
 *                                                                         *
16
 *   You should have received a copy of the GNU Library General Public     *
17
 *   License along with this library; see the file COPYING.LIB. If not,    *
18
 *   write to the Free Software Foundation, Inc., 59 Temple Place,         *
19
 *   Suite 330, Boston, MA  02111-1307, USA                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24

25
#include "AttachExtensionPy.h"
26
#include "AttachExtensionPy.cpp"
27
#include "AttachEnginePy.h"
28
#include "OCCError.h"
29

30

31
using namespace Part;
32

33
// returns a string which represents the object e.g. when printed in python
34
std::string AttachExtensionPy::representation() const
35
{
36
    return {"<Part::AttachableObject>"};
37
}
38

39
PyObject* AttachExtensionPy::positionBySupport(PyObject *args)
40
{
41
    if (!PyArg_ParseTuple(args, ""))
42
        return nullptr;
43
    bool bAttached = false;
44
    try{
45
        bAttached = this->getAttachExtensionPtr()->positionBySupport();
46
    } catch (Standard_Failure& e) {
47
        PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
48
        return nullptr;
49
    } catch (Base::Exception &e) {
50
        e.setPyException();
51
        return nullptr;
52
    }
53
    return Py::new_reference_to(Py::Boolean(bAttached));
54
}
55

56
PyObject* AttachExtensionPy::changeAttacherType(PyObject *args)
57
{
58
    const char* typeName;
59
    if (!PyArg_ParseTuple(args, "s", &typeName))
60
        return nullptr;
61
    bool ret;
62
    try{
63
        ret = this->getAttachExtensionPtr()->changeAttacherType(typeName);
64
    } catch (Standard_Failure& e) {
65
        PyErr_SetString(PartExceptionOCCError, e.GetMessageString());
66
        return nullptr;
67
    } catch (Base::Exception &e) {
68
        e.setPyException();
69
        return nullptr;
70
    }
71
    return Py::new_reference_to(Py::Boolean(ret));
72
}
73

74
Py::Object AttachExtensionPy::getAttacher() const
75
{
76
    try {
77
        this->getAttachExtensionPtr()->attacher(); //throws if attacher is not set
78
    } catch (Base::Exception&) {
79
        return Py::None();
80
    }
81

82
    try {
83
        return Py::Object( new Attacher::AttachEnginePy(this->getAttachExtensionPtr()->attacher().copy()), true);
84
    } catch (Standard_Failure& e) {
85
        throw Py::Exception(Part::PartExceptionOCCError, e.GetMessageString());
86
    } catch (Base::Exception &e) {
87
        e.setPyException();
88
        throw Py::Exception();
89
    }
90

91
}
92

93
PyObject *AttachExtensionPy::getCustomAttributes(const char* /*attr*/) const
94
{
95
    return nullptr;
96
}
97

98
int AttachExtensionPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
99
{
100
    return 0;
101
}
102

103

104

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.