Skip to content

Commit 1bdf20d

Browse files
committed
[CEXT-Dan#398] add userAttribute methods
1 parent ccdf0b2 commit 1bdf20d

File tree

3 files changed

+88
-0
lines changed

3 files changed

+88
-0
lines changed

PyRxCore/PyBrxCvDbPoint.cpp

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66
#include "PyDbObjectId.h"
77
#include "BrxCvDbPoint.h"
88

9+
#if defined(_BRXTARGET) && (_BRXTARGET == 260)
10+
#include "PyBrxCvAttribVariant.h"
11+
#endif
12+
13+
914
using namespace boost::python;
1015
void makePyBrxCvDbPointWrapper()
1116
{
@@ -54,6 +59,16 @@ void makePyBrxCvDbPointWrapper()
5459
.def("referencedEntityAt", &PyBrxCvDbPoint::referencedEntityAt, DS.ARGS({ "val : int" }))
5560
.def("update", &PyBrxCvDbPoint::update, DS.ARGS())
5661

62+
#if defined(_BRXTARGET) && (_BRXTARGET == 260)
63+
.def("addUserAttribute", &PyBrxCvDbPoint::addUserAttribute, DS.ARGS({ "name : str", "value : PyBrxCv.CvAttribVariant" }))
64+
.def("removeUserAttribute", &PyBrxCvDbPoint::removeUserAttribute, DS.ARGS({ "name : str", "value : PyBrxCv.CvDataType" }))
65+
.def("userAttributes", &PyBrxCvDbPoint::userAttributes, DS.ARGS())
66+
.def("userAttribute", &PyBrxCvDbPoint::userAttribute, DS.ARGS({ "name : str", "value : PyBrxCv.CvDataType" }))
67+
.def("userAttributeNames", &PyBrxCvDbPoint::userAttributeNames, DS.ARGS())
68+
.def("userAttributeCount", &PyBrxCvDbPoint::userAttributeCount, DS.ARGS())
69+
.def("userAttributeAt", &PyBrxCvDbPoint::userAttributeAt, DS.ARGS({ "index : int" }))
70+
#endif
71+
5772
.def("importPointsFromFile", &PyBrxCvDbPoint::importPointsFromFile,
5873
DS.SARGS({ "files: list[str]","fmtid: PyDb.ObjectId" })).staticmethod("importPointsFromFile")
5974
.def("assignPointToPointGroup", &PyBrxCvDbPoint::assignPointToPointGroup,
@@ -325,6 +340,57 @@ void PyBrxCvDbPoint::assignStylesToPoints(const boost::python::list& cvpoints, c
325340
#endif
326341
}
327342

343+
#if defined(_BRXTARGET) && (_BRXTARGET == 260)
344+
bool PyBrxCvDbPoint::addUserAttribute(const std::string& name, const PyBrxCvAttribVariant& value) const
345+
{
346+
return impObj()->addUserAttribute(utf8_to_wstr(name).c_str(), value.impl);
347+
}
348+
349+
bool PyBrxCvDbPoint::removeUserAttribute(const std::string& name, BrxCvDataType type) const
350+
{
351+
return impObj()->removeUserAttribute(utf8_to_wstr(name).c_str(), type);
352+
}
353+
354+
boost::python::list PyBrxCvDbPoint::userAttributes() const
355+
{
356+
PyAutoLockGIL lock;
357+
boost::python::list pylist;
358+
for (const auto& item : impObj()->userAttributes())
359+
pylist.append(PyBrxCvAttribVariant(item));
360+
return pylist;
361+
}
362+
363+
PyBrxCvAttribVariant PyBrxCvDbPoint::userAttribute(const std::string& name, BrxCvDataType spec) const
364+
{
365+
return PyBrxCvAttribVariant(impObj()->userAttribute(utf8_to_wstr(name).c_str(), spec));
366+
}
367+
368+
boost::python::list PyBrxCvDbPoint::userAttributeNames() const
369+
{
370+
PyAutoLockGIL lock;
371+
boost::python::list pylist;
372+
for (const auto& item : impObj()->userAttributeNames())
373+
pylist.append(wstr_to_utf8(item));
374+
return pylist;
375+
}
376+
377+
Adesk::UInt32 PyBrxCvDbPoint::userAttributeCount() const
378+
{
379+
return impObj()->userAttributeCount();
380+
}
381+
382+
boost::python::tuple PyBrxCvDbPoint::userAttributeAt(Adesk::UInt32 index) const
383+
{
384+
385+
PyAutoLockGIL lock;
386+
AcString name;
387+
BrxCvAttribVariant variant;
388+
bool flag = impObj()->userAttributeAt(index, name, variant);
389+
return boost::python::make_tuple(flag, wstr_to_utf8(name), PyBrxCvAttribVariant{ variant });
390+
}
391+
392+
#endif
393+
328394
std::string PyBrxCvDbPoint::className()
329395
{
330396
return "BrxCvDbPoint";

PyRxCore/PyBrxCvDbPoint.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,17 @@
33
#ifdef BRXAPP
44
#include "PyBrxCvObject.h"
55

6+
#if !defined(_BRXTARGET240)
7+
#include "BrxCvGlobal.h"
8+
#endif
9+
610
class BrxCvDbPoint;
711
class BrxCvDbPointReferencedEntity;
812
class BrxCvDbPointGroup;
913

1014
class PyBrxCvDbPointReferencedEntity;
1115
class PyDbObjectId;
16+
class PyBrxCvAttribVariant;
1217

1318
//-----------------------------------------------------------------------------------
1419
//PyBrxCvDbPoint
@@ -67,6 +72,16 @@ class PyBrxCvDbPoint : public PyBrxCvDbEntity
6772
static void assignPointsToPointGroup(const boost::python::list& cvpoints, const PyDbObjectId& groupId);
6873
static void assignStylesToPoints(const boost::python::list& cvpoints,const PyDbObjectId& symbolStyleId, const PyDbObjectId& labelStyleId);
6974

75+
#if defined(_BRXTARGET) && (_BRXTARGET == 260)
76+
bool addUserAttribute(const std::string& name, const PyBrxCvAttribVariant& value) const;
77+
bool removeUserAttribute(const std::string& name, BrxCvDataType type) const;
78+
boost::python::list userAttributes() const;
79+
PyBrxCvAttribVariant userAttribute(const std::string& name, BrxCvDataType spec) const;
80+
boost::python::list userAttributeNames() const;
81+
Adesk::UInt32 userAttributeCount() const;
82+
boost::python::tuple userAttributeAt(Adesk::UInt32 index) const;
83+
#endif
84+
7085
static std::string className();
7186
static PyRxClass desc();
7287
static PyBrxCvDbPoint cloneFrom(const PyRxObject& src);

pyrx/PyBrxCv.pyi

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,6 +1832,7 @@ class CvDbPoint(PyBrxCv.CvDbEntity):
18321832
/,
18331833
) -> None: ...
18341834
def __reduce__(self, /) -> Any: ...
1835+
def addUserAttribute(self, name: str, value: PyBrxCv.CvAttribVariant, /) -> bool: ...
18351836
@staticmethod
18361837
def assignPointToPointGroup(cvpoint: PyBrxCv.CvDbPoint, groupid: PyDb.ObjectId, /) -> None: ...
18371838
@staticmethod
@@ -1886,6 +1887,7 @@ class CvDbPoint(PyBrxCv.CvDbEntity):
18861887
def rawDescription(self, /) -> str: ...
18871888
def referencedEntityAt(self, val: int, /) -> CvDbPointReferencedEntity: ...
18881889
def referencedEntityCount(self, /) -> int: ...
1890+
def removeUserAttribute(self, name: str, value: PyBrxCv.CvDataType, /) -> bool: ...
18891891
def resetLabel(self, /) -> bool: ...
18901892
def setEasting(self, val: float, /) -> bool: ...
18911893
def setElevation(self, val: float, /) -> bool: ...
@@ -1904,6 +1906,11 @@ class CvDbPoint(PyBrxCv.CvDbEntity):
19041906
def symbolId(self, /) -> PyDb.ObjectId: ...
19051907
def symbolRotation(self, /) -> float: ...
19061908
def update(self, /) -> bool: ...
1909+
def userAttribute(self, name: str, value: PyBrxCv.CvDataType, /) -> CvAttribVariant: ...
1910+
def userAttributeAt(self, index: int, /) -> tuple: ...
1911+
def userAttributeCount(self, /) -> int: ...
1912+
def userAttributeNames(self, /) -> list: ...
1913+
def userAttributes(self, /) -> list: ...
19071914

19081915
class CvDbPointGroup(PyBrxCv.CvDbObject):
19091916
def __init__(

0 commit comments

Comments
 (0)