xeokit / xeokit-convert

Convert various AEC model formats for efficient viewing in the browser with xeokit.
https://xeokit.github.io/xeokit-convert/docs/
Other
51 stars 54 forks source link

Exclude element without reading his full info #109

Open g-rodigy opened 1 year ago

g-rodigy commented 1 year ago

When I try to convert ifc model wich has element IfcGrid without axis names, parse failing even if set excludeTypes: ['IfcGrid'].

Code example

const {convert2xkt} = require('@xeokit/xeokit-convert/dist/convert2xkt.cjs.js')
const WebIFC = require('web-ifc/web-ifc-api-node.js')

const file = 'path/to/model'
const output = 'path/to/output'

convert2xkt({
    WebIFC,
    source: file,
    output,
    excludeTypes: ['IfcGrid', 'IfcGridAxis'],
})

Log output:

INFO:  Parsing Model using IFC2X3 Schema
TypeError: Cannot read properties of null (reading 'map')
    at 3009204131 (...\node_modules\web-ifc\web-ifc-api-node.js:12645:381)
    at IfcAPI2.GetLine (....\node_modules\web-ifc\web-ifc-api-node.js:63239:84)
    at ...\node_modules\@xeokit\xeokit-convert\dist\convert2xkt.cjs.js:15944:51
    at Array.forEach (<anonymous>)
    at parseRelatedItemsOfType (...\node_modules\@xeokit\xeokit-convert\dist\convert2xkt.cjs.js:15942:25)
    at parseSpatialChildren (...\node_modules\@xeokit\xeokit-convert\dist\convert2xkt.cjs.js:15890:5)
    at ...\node_modules\@xeokit\xeokit-convert\dist\convert2xkt.cjs.js:15946:21
    at Array.forEach (<anonymous>)
    at parseRelatedItemsOfType (...\node_modules\@xeokit\xeokit-convert\dist\convert2xkt.cjs.js:15942:25)
    at parseSpatialChildren (...\node_modules\@xeokit\xeokit-convert\dist\convert2xkt.cjs.js:15882:5)
xeolabs commented 1 year ago

Looks like an issue with web-ifc..

g-rodigy commented 1 year ago

Yes, it is web-ifc issue, but i mean can skip element before fully reading his data?

xeolabs commented 1 year ago

If I understand correctly, we have no means to configure conversion to ignore certain IFC elements by ID. This seems to be a useful potential feature though, but outside of our priorities at the moment. If anyone has time for to make a PR, I'd consider merging that though.

g-rodigy commented 1 year ago

Not by ID, by element type as is in the constructor excludeTypes. If I understand correctly code https://github.com/xeokit/xeokit-convert/blob/ef646ca47ffee6777ebc96097e8c01131f33841c/src/parsers/parseIFCIntoXKTModel.js#L279-L320 Firstrly take some element, then his releated elements and read their data, if element type is excluded then he skiped. The bug happen just in the place where the data is reading (.getLine(...)) for after checking type and other.