engine_components
engine_components copied to clipboard
Sort levels by height for exploding tool
Describe the bug 📝
I'm having some problems with the explode tool.
It appears to don't work well with levels that have negative elevation (I mean that this levels are positioned below the IFC origin). The elements are displayed in an incorrect position above the origin when you explode the model like in the screen captures.
There is something I can do to fix it? Thanks!
Reproduction ▶️
https://github.com/RASRC/FrontEnd_Course.git
Steps to reproduce 🔢
Activating the explode tool in the bottom menu of the app
System Info 💻
openbim-components
Used Package Manager 📦
npm
Error Trace/Logs 📃
No response
Validations ✅
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- [X] Make sure this is a IFC.js components issue and not a framework-specific issue. For example, if it's a THREE.js related bug, it should likely be reported to mrdoob/threejs instead.
- [X] Check that this is a concrete bug. For Q&A join our Discord Chat Server.
- [X] The provided reproduction is a minimal reproducible example of the bug.
Hi @agviegas
I write to ask you if there is a chance to solve this issue for the official release.
Thanks!
We'll try! Otherwise, we'll fix it after September 20. Cheers!
Hi @agviegas.
I send you the IFC file. It could be useful if you want to do some tests.
Thanks!
Hi @RASRC! I'm just following up this issue. Are still experiencing the same problems when updating to [email protected]?
Hi @HoyosJuan! Yes I have that version running and the issue is still there. I left the ifc file in a previous message if you want to do some tests. Thanks!
Hi @HoyosJuan! I'm using the 1.2.0 version of the library now and still have the same issue
Hi @HoyosJuan! Did you can test the FragmentExploder with the model I attached to the issue? Thanks.
Hey! After the big refactor of the library, this milestone we are checking and solving issues. We have also updated the exploder. Now, you can classify the model like this:
const classifier = components.get(OBC.Classifier);
await classifier.bySpatialStructure(model);
That won't sort the storeys by default because it's generic to any kind of relationship, but you can easily sort them by getting all the storeys and using its elevation information. Good thing about this approach is that even in those files where the elevation information is somewhere else, a custom sort method can be established for the exploder:
const storeys = await model.getAllPropertiesOfType(WEBIFC.IFCBUILDINGSTOREY);
if (storeys) {
const storeyList = Object.values(storeys);
storeyList.sort((a, b) => a.Elevation.value - b.Elevation.value);
const sortedIds = storeyList.map((item) => item.Name.value);
const newClassifiedStories: typeof classifier.list.spatialStructures = {};
for (const id of sortedIds) {
const classifiedStories = classifier.list.spatialStructures;
newClassifiedStories[id] = classifiedStories[id];
}
classifier.list.spatialStructures = newClassifiedStories;
}
This should be possible from @thatopen/[email protected], which I'm publishing right now. I'm also going to update the docs right away. Let me know if you face any issues with this. Cheers!