Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude element without reading his full info #109

Open
g-rodigy opened this issue Jul 4, 2023 · 4 comments
Open

Exclude element without reading his full info #109

g-rodigy opened this issue Jul 4, 2023 · 4 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@g-rodigy
Copy link

g-rodigy commented Jul 4, 2023

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
Copy link
Member

xeolabs commented Jul 4, 2023

Looks like an issue with web-ifc..

@xeolabs xeolabs added good first issue Good for newcomers help wanted Extra attention is needed labels Jul 4, 2023
@g-rodigy
Copy link
Author

g-rodigy commented Jul 4, 2023

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

@xeolabs
Copy link
Member

xeolabs commented Jul 4, 2023

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
Copy link
Author

g-rodigy commented Jul 4, 2023

Not by ID, by element type as is in the constructor excludeTypes. If I understand correctly code

function parseRelatedItemsOfType(ctx, id, relation, related, type, parentMetaObjectId) {
const lines = ctx.ifcAPI.GetLineIDsWithType(ctx.modelID, type);
for (let i = 0; i < lines.size(); i++) {
const relID = lines.get(i);
const rel = ctx.ifcAPI.GetLine(ctx.modelID, relID);
const relatedItems = rel[relation];
let foundElement = false;
if (Array.isArray(relatedItems)) {
const values = relatedItems.map((item) => item.value);
foundElement = values.includes(id);
} else {
foundElement = (relatedItems.value === id);
}
if (foundElement) {
const element = rel[related];
if (!Array.isArray(element)) {
const ifcElement = ctx.ifcAPI.GetLine(ctx.modelID, element.value);
parseSpatialChildren(ctx, ifcElement, parentMetaObjectId);
} else {
element.forEach((element2) => {
const ifcElement = ctx.ifcAPI.GetLine(ctx.modelID, element2.value);
parseSpatialChildren(ctx, ifcElement, parentMetaObjectId);
});
}
}
}
}

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants