From 295b2fb56b31d866ef415af1b036d12f171cc8be Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Thu, 2 Apr 2020 06:04:38 +0200 Subject: [PATCH] More documentation --- .../ifcopenshell/entity_instance.py | 18 ++++++++++++++++++ src/ifcopenshell-python/ifcopenshell/file.py | 2 ++ 2 files changed, 20 insertions(+) diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index ad977e3dc6..313e898e1f 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -153,6 +153,24 @@ class entity_instance(object): return repr(self.wrapped_data) def is_a(self, *args): + """Return the IFC class name of an instance, or checks if an instance belongs to a class. + + The check will also return true if a parent class name is provided. + + :param args: If specified, is a case insensitive IFC class name to check + :type args: string + :returns: Either the name of the class, or a boolean if it passes the check + :rtype: string|bool + + Example:: + + f = ifcopenshell.file() + f.create_entity('IfcPerson') + f.is_a() + >>> 'IfcPerson' + f.is_a('IfcPerson') + >>> True + """ return self.wrapped_data.is_a(*args) def id(self): diff --git a/src/ifcopenshell-python/ifcopenshell/file.py b/src/ifcopenshell-python/ifcopenshell/file.py index d74d03d15b..4e0cb0bae8 100644 --- a/src/ifcopenshell-python/ifcopenshell/file.py +++ b/src/ifcopenshell-python/ifcopenshell/file.py @@ -128,6 +128,8 @@ class file(object): def by_type(self, type): """Return IFC objects filtered by IFC Type and wrapped with the entity_instance class. + If an IFC type class has subclasses, all entities of those subclasses are also returned. + :param type: The case insensitive type of IFC class to return. :type type: string :returns: A list of ifcopenshell.entity_instance.entity_instance objects