Skip to content

Commit a58f23f

Browse files
committed
Missing introspection methods in Python
1 parent b696df0 commit a58f23f

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/ifcopenshell-python/ifcopenshell/entity_instance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ def __hash__(self):
120120
def __dir__(self):
121121
return sorted(set(itertools.chain(
122122
dir(type(self)),
123-
self.wrapped_data.get_attribute_names(),
124-
self.wrapped_data.get_inverse_attribute_names()
123+
map(str, self.wrapped_data.get_attribute_names()),
124+
map(str, self.wrapped_data.get_inverse_attribute_names())
125125
)))
126126

127127
def get_info(self, include_identifier=True, recursive=False):

src/ifcwrap/IfcParseWrapper.i

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,26 @@ private:
109109

110110
// id() is defined on IfcBaseEntity and not on IfcBaseClass, in order
111111
// to expose it to the Python wrapper it is simply duplicated here.
112+
// Same applies to the two methods reimplemented below.
112113
int id() const {
113114
return $self->entity->id();
114115
}
116+
117+
std::vector<std::string> getAttributeNames() const {
118+
if (IfcSchema::Type::IsSimple($self->type())) {
119+
return std::vector<std::string>(1, "wrappedValue");
120+
}
121+
IfcUtil::IfcBaseEntity* self_ = (IfcUtil::IfcBaseEntity*) self;
122+
return self_->getAttributeNames();
123+
}
124+
125+
std::vector<std::string> getInverseAttributeNames() const {
126+
if (IfcSchema::Type::IsSimple($self->type())) {
127+
return std::vector<std::string>(0);
128+
}
129+
IfcUtil::IfcBaseEntity* self_ = (IfcUtil::IfcBaseEntity*) self;
130+
return self_->getInverseAttributeNames();
131+
}
115132

116133
bool is_a(const std::string& s) {
117134
return self->is(IfcSchema::Type::FromString(boost::to_upper_copy(s)));

0 commit comments

Comments
 (0)