MCPcopy Create free account
hub / github.com/FreeCAD/FreeCAD / addProperty

Method addProperty

src/App/DocumentObjectPyImp.cpp:98–151  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98PyObject* DocumentObjectPy::addProperty(PyObject* args, PyObject* kwd)
99{
100 char *sType, *sName = nullptr, *sGroup = nullptr, *sDoc = nullptr;
101 short attr = 0;
102 PyObject *ro = Py_False, *hd = Py_False, *lk = Py_False;
103 PyObject* enumVals = nullptr;
104 const std::array<const char*, 10> kwlist {"type",
105 "name",
106 "group",
107 "doc",
108 "attr",
109 "read_only",
110 "hidden",
111 "locked",
112 "enum_vals",
113 nullptr};
114 if (!Base::Wrapped_ParseTupleAndKeywords(args,
115 kwd,
116 "ss|sethO!O!O!O",
117 kwlist,
118 &sType,
119 &sName,
120 &sGroup,
121 "utf-8",
122 &sDoc,
123 &attr,
124 &PyBool_Type,
125 &ro,
126 &PyBool_Type,
127 &hd,
128 &PyBool_Type,
129 &lk,
130 &enumVals)) {
131 return nullptr;
132 }
133
134 Property* prop = getDocumentObjectPtr()->addDynamicProperty(sType,
135 sName,
136 sGroup,
137 sDoc,
138 attr,
139 Base::asBoolean(ro),
140 Base::asBoolean(hd));
141
142 prop->setStatus(Property::LockDynamic, Base::asBoolean(lk));
143
144 // enum support
145 auto* propEnum = dynamic_cast<App::PropertyEnumeration*>(prop);
146 if (propEnum && enumVals) {
147 propEnum->setPyObject(enumVals);
148 }
149
150 return Py::new_reference_to(this);
151}
152
153PyObject* DocumentObjectPy::removeProperty(PyObject* args)
154{

Callers

nothing calls this directly

Calls 6

asBooleanFunction · 0.85
new_reference_toFunction · 0.85
addDynamicPropertyMethod · 0.45
setStatusMethod · 0.45
setPyObjectMethod · 0.45

Tested by

no test coverage detected