PropertySetDefinitionSets Are Not Imported Correctly
Error Description and Steps to Reproduce
When an IFCRELDEFINESBYPROPERTIES has an IFCPROPERTYSETDEFINITIONSET, the RelatingPropertyDefinition
holds a blank class, instead of a set of entities as would be expected.
Steps to Reproduce
- Add the following snippet to XmlSerializer.cpp here. This snippet is designed to add all the property sets inside a PropertySetDefinitionSet, if one exists, for an IfcRelDefinesByProperties entity.
#ifdef SCHEMA_HAS_IfcPropertySetDefinitionSet
auto defines = object->file_->getInverse(object->id(), &(IfcSchema::IfcRelDefinesByProperties::Class()), -1);
for(auto& o : *defines)
{
auto define = o->as<IfcSchema::IfcRelDefinesByProperties>();
auto select = define->RelatingPropertyDefinition();
if (select->as<IfcSchema::IfcPropertySetDefinitionSet>())
{
auto sets = select->as<IfcSchema::IfcPropertySetDefinitionSet>()->operator boost::shared_ptr<aggregate_of<IfcSchema::IfcPropertySetDefinition>>();
for (auto pset : *sets)
{
format_entity_instance(mapping, pset, child, true);
}
}
}
#endif
- Run IfcConvert to convert the following file to XML
- The conversion will fail with the error
[Error] [2025-03-12 16:42:29] Type held at index 0 is class Blank and not class boost::shared_ptr<class aggregate_of_instance>
Debug information
The parsing works up till here. The construct_
method correctly gathers the references and passes them to the lambda as a std::vector<reference_or_simple_type>
:
However, because name
is -1
, this snippet never does anything with them, and so the IfcEntityInstanceData
is given the default storage_t
.
name
is -1
because this is called from,
Understanding the Issue
The issue arises from the fact that IfcRelDefinesByProperties
expects a single reference to a IfcPropertySetDefinitionSelect
, not a set. However, IfcPropertySetDefinitionSet
is a set of entities, which cannot be directly referenced by IfcRelDefinesByProperties
.
Proposed Solution
One possible solution is to create an anonymous object for the set, which would allow IfcRelDefinesByProperties
to reference it correctly. However, this would require significant changes to the IFC schema and the parsing code.
Alternative Solution
Another possible solution is to modify the load
function to pass entity_instance_name
instead of -1
, which would allow the references in the set to be resolved correctly. However, this would require changes to the parsing code and may have unintended consequences.
Conclusion
The issue of PropertySetDefinitionSets
not being imported correctly is a complex one, requiring significant changes to the IFC schema and the parsing code. While there are possible solutions, they are not without their challenges and may have unintended consequences. Further investigation and testing are required to determine the best course of action.
Code Changes
To fix the issue, the following code changes are required:
- Modify the
XmlSerializer.cpp
file to add the snippet that adds all the property sets inside a PropertySetDefinitionSet, if one exists, for an IfcRelDefinesByProperties entity. - Modify the
IfcParse.cpp
file to passentity_instance_name
instead of-1
to theload
function. - Modify the
IfcFile.cpp
file to correctly resolve the references in the set.
Testing
To test the changes, the following steps should be taken:
- Run IfcConvert to convert the
ColumnPSetsOfSets.ifc
file to XML. - Verify that the conversion is successful and the
RelatingPropertyDefinition
holds a set of entities instead of a blank class.
Future Work
Further investigation and testing are required to determine the best course of action for fixing the issue of PropertySetDefinitionSets
not being imported correctly. This may involve modifying the IFC schema and the parsing code, as well as testing the changes to ensure that they do not have unintended consequences.
Q: What is the issue with PropertySetDefinitionSets not being imported correctly?
A: The issue arises from the fact that IfcRelDefinesByProperties
expects a single reference to a IfcPropertySetDefinitionSelect
, not a set. However, IfcPropertySetDefinitionSet
is a set of entities, which cannot be directly referenced by IfcRelDefinesByProperties
.
Q: What is the proposed solution to fix the issue?
A: One possible solution is to create an anonymous object for the set, which would allow IfcRelDefinesByProperties
to reference it correctly. However, this would require significant changes to the IFC schema and the parsing code.
Q: What is the alternative solution to fix the issue?
A: Another possible solution is to modify the load
function to pass entity_instance_name
instead of -1
, which would allow the references in the set to be resolved correctly. However, this would require changes to the parsing code and may have unintended consequences.
Q: What code changes are required to fix the issue?
A: To fix the issue, the following code changes are required:
- Modify the
XmlSerializer.cpp
file to add the snippet that adds all the property sets inside a PropertySetDefinitionSet, if one exists, for an IfcRelDefinesByProperties entity. - Modify the
IfcParse.cpp
file to passentity_instance_name
instead of-1
to theload
function. - Modify the
IfcFile.cpp
file to correctly resolve the references in the set.
Q: How can I test the changes to ensure that they fix the issue?
A: To test the changes, the following steps should be taken:
- Run IfcConvert to convert the
ColumnPSetsOfSets.ifc
file to XML. - Verify that the conversion is successful and the
RelatingPropertyDefinition
holds a set of entities instead of a blank class.
Q: What are the potential consequences of modifying the IFC schema and the parsing code?
A: Modifying the IFC schema and the parsing code can have unintended consequences, such as breaking existing functionality or introducing new bugs. Therefore, it is essential to thoroughly test the changes before releasing them.
Q: Can I create an anonymous object for the set to fix the issue?
A: Yes, creating an anonymous object for the set is one possible solution to fix the issue. However, this would require significant changes to the IFC schema and the parsing code.
Q: What is the current status of the issue?
A: The issue is currently being investigated and tested. Further investigation and testing are required to determine the best course of action for fixing the issue.
Q: Who can I contact for further information or assistance?
A: You can contact the IfcOpenShell development team for further information or assistance. They can provide guidance on the best course of action for fixing the issue and answer any questions you may have.
Q: What are the next steps for fixing the issue?
A: The next steps for fixing the issue are to:
- Continue investigating and testing the issue.
- Determine the best course of action for fixing the issue.
- Implement the changes required to fix the issue.
- Thoroughly test the changes to ensure that they fix the issue and do not introduce new bugs.
Q: How can I contribute to the IfcOpenShell project?
A: You can contribute to the IfcOpenShell project by:
- Reporting bugs or issues.
- Providing feedback on the project.
- Contributing code or documentation.
- Participating in the project's community.
Q: What are the benefits of contributing to the IfcOpenShell project?
A: Contributing to the IfcOpenShell project can provide numerous benefits, including:
- Improving the project's functionality and stability.
- Enhancing the project's documentation and community.
- Gaining experience and knowledge in software development.
- Building a reputation as a skilled and knowledgeable developer.