mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
Missing introspection methods in Python
This commit is contained in:
@@ -120,8 +120,8 @@ class entity_instance(object):
|
|||||||
def __dir__(self):
|
def __dir__(self):
|
||||||
return sorted(set(itertools.chain(
|
return sorted(set(itertools.chain(
|
||||||
dir(type(self)),
|
dir(type(self)),
|
||||||
self.wrapped_data.get_attribute_names(),
|
map(str, self.wrapped_data.get_attribute_names()),
|
||||||
self.wrapped_data.get_inverse_attribute_names()
|
map(str, self.wrapped_data.get_inverse_attribute_names())
|
||||||
)))
|
)))
|
||||||
|
|
||||||
def get_info(self, include_identifier=True, recursive=False):
|
def get_info(self, include_identifier=True, recursive=False):
|
||||||
|
|||||||
@@ -109,9 +109,26 @@ private:
|
|||||||
|
|
||||||
// id() is defined on IfcBaseEntity and not on IfcBaseClass, in order
|
// id() is defined on IfcBaseEntity and not on IfcBaseClass, in order
|
||||||
// to expose it to the Python wrapper it is simply duplicated here.
|
// to expose it to the Python wrapper it is simply duplicated here.
|
||||||
|
// Same applies to the two methods reimplemented below.
|
||||||
int id() const {
|
int id() const {
|
||||||
return $self->entity->id();
|
return $self->entity->id();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> getAttributeNames() const {
|
||||||
|
if (IfcSchema::Type::IsSimple($self->type())) {
|
||||||
|
return std::vector<std::string>(1, "wrappedValue");
|
||||||
|
}
|
||||||
|
IfcUtil::IfcBaseEntity* self_ = (IfcUtil::IfcBaseEntity*) self;
|
||||||
|
return self_->getAttributeNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> getInverseAttributeNames() const {
|
||||||
|
if (IfcSchema::Type::IsSimple($self->type())) {
|
||||||
|
return std::vector<std::string>(0);
|
||||||
|
}
|
||||||
|
IfcUtil::IfcBaseEntity* self_ = (IfcUtil::IfcBaseEntity*) self;
|
||||||
|
return self_->getInverseAttributeNames();
|
||||||
|
}
|
||||||
|
|
||||||
bool is_a(const std::string& s) {
|
bool is_a(const std::string& s) {
|
||||||
return self->is(IfcSchema::Type::FromString(boost::to_upper_copy(s)));
|
return self->is(IfcSchema::Type::FromString(boost::to_upper_copy(s)));
|
||||||
|
|||||||
Reference in New Issue
Block a user