Add documentation and APIs to support crawling the model
See original GitHub issueAs my questions in StackOverflow explain (Q1, Q2) I’m trying to write an exported from IFC to a simpler format like OBJ For that the glTF example was very useful (thanks @agviegas!)
But there’s still an unresolved problem of how can I access all types in a given IFC as opposed to what all examples focus on which is given a list of types, how do I access them in the IFC.
I was able to get close to getting all types in the following code, but I still can’t make it work for multiple reasons:
const allTypes = {}
ifcLoader.ifcManager.getSpatialStructure(bimModel.modelID).then(ifcProject => {
let currentElement = ifcProject
const children = [...currentElement.children]
const ids = []
while (children.length) {
currentElement = children.pop()
children.push(...currentElement.children)
if (!currentElement.children.length) {
console.log(currentElement.type, typeof currentElement.type)
allTypes[currentElement.type] = true
ids.push(currentElement.expressID)
}
}
Object.keys(allTypes).forEach(type => {
this.getGeometriesOfType(type).then(geometries => {
// enjoy the geometries
})
})
})
Mainly because currentElement.type
returns the string 'IFCDOOR'
and not the enum (int) IFCDOOR
as Q2 says
I’m not familiar enough with the project, but maybe during parsing of the IFC the list of types can be maintained and then easily accessed through the ifcManager/ifcProject without having to reiterate everything recursively.
Issue Analytics
- State:
- Created a year ago
- Comments:16 (4 by maintainers)
We could perhaps make a function to get all types present in a file (and all elements)? 🤔
Hi, About your Question 2 if you’re expecting the following result : where {key : IFCENTITY: int , …}
You could check the web-ifc-api there is a helper method for inspiration here.
Just as an exemple
@agviegas is it possible to add a getter IfcApi.properties.getTypes(). here or giving public access to getAllTypesOfModel(modelID: number)