diff --git a/src/ifcopenshell-python/ifcopenshell/entity_instance.py b/src/ifcopenshell-python/ifcopenshell/entity_instance.py index c6a18b42ab..9c56c09b73 100644 --- a/src/ifcopenshell-python/ifcopenshell/entity_instance.py +++ b/src/ifcopenshell-python/ifcopenshell/entity_instance.py @@ -232,6 +232,17 @@ class entity_instance(object): def __repr__(self): return repr(self.wrapped_data) + + def to_string(self, valid_spf=True): + """Returns a string representation of the current entity instance. + Equal to str(self) when valid_spf=False. When valid_spf is True + returns a representation of the string that conforms to valid Step + Physical File notation. The difference being entity names in upper + case and string attribute values with unicode values encoded per + the specific control directives. + """ + + return self.wrapped_data.to_string(valid_spf) def is_a(self, *args): """Return the IFC class name of an instance, or checks if an instance belongs to a class. diff --git a/src/ifcwrap/IfcParseWrapper.i b/src/ifcwrap/IfcParseWrapper.i index d0ba2301fe..00d7ac0347 100644 --- a/src/ifcwrap/IfcParseWrapper.i +++ b/src/ifcwrap/IfcParseWrapper.i @@ -250,6 +250,10 @@ static IfcUtil::ArgumentType helper_fn_attribute_type(const IfcUtil::IfcBaseClas return $self->data().toString(); } + std::string to_string(bool valid_spf) const { + return $self->data().toString(valid_spf); + } + // Just something to have a somewhat sensible value to hash size_t file_pointer() const { return reinterpret_cast($self->data().file);