Base objects in Blocks (#1600)

* Fixed a displaying issue with blocks that contain non-direct-convertible objects.

* Revert "Fixed a displaying issue with blocks that contain non-direct-convertible objects."

This reverts commit dc44a07d79e605e42e605befde1b09fdc95429d5.

* Different approach on fixing the Base object with display values in Blocks which should not generate regression since it's restricted only to blocks and works the same way for other situations except this one

* Added 'elements' lookup as well

* Check if display values or elements exist before destructuring them
This commit is contained in:
Alexandru Popovici
2023-05-29 16:23:09 +03:00
committed by GitHub
parent 9427686d42
commit de48e2c453
2 changed files with 33 additions and 5 deletions
+4 -1
View File
@@ -262,7 +262,10 @@ const getStream = () => {
// 'https://latest.speckle.dev/streams/92b620fb17/commits/f9063fe647'
// 'https://speckle.xyz/streams/be0f962efb/objects/37639741c363a123100eda8044f2fe3f'
// 'https://latest.speckle.dev/streams/92b620fb17/objects/a4e2fad01e69cd886ecbfedf221f5301'
'https://latest.speckle.dev/streams/3f895e614f/commits/7e16d2ab71'
// 'https://latest.speckle.dev/streams/3f895e614f/commits/7e16d2ab71'
// 'https://latest.speckle.dev/streams/c1faab5c62/objects/d3466547df9df86397eb4dff7ac9713f'
// 'https://latest.speckle.dev/streams/c1faab5c62/commits/140c443886'
'https://latest.speckle.dev/streams/e258b0e8db/commits/108971810d'
)
}
@@ -359,6 +359,34 @@ export default class Coverter {
// return hash
// }
/** This is only used for Blocks to search for convertible objects, without using the main 'traverse' function
* It's only looking for 'elements' and 'displayValues'
* I think it can be used for RevitInstances as well to replace it's current lookup, but I'm afraid to do it
*/
private async displayableLookup(obj, node) {
if (this.directNodeConverterExists(obj)) {
await this.convertToNode(obj, node)
} else {
const displayValues = this.getDisplayValue(obj)
const elements = this.getElementsValue(obj)
const entries = [
...(displayValues ? displayValues : []),
...(elements ? elements : [])
]
for (const entry of entries) {
const value = await this.resolveReference(entry)
const valueNode: TreeNode = this.tree.parse({
id: this.getNodeId(value),
raw: Object.assign({}, value),
atomic: false,
children: []
})
this.tree.addNode(valueNode, node)
await this.displayableLookup(value, valueNode)
}
}
}
private async BlockInstanceToNode(obj, node) {
const definition = await this.resolveReference(this.getBlockDefinition(obj))
node.model.raw.definition = definition
@@ -372,11 +400,8 @@ export default class Coverter {
children: []
})
this.tree.addNode(childNode, node)
// console.warn(
// `Added child node with id ${childNode.model.id} to parent node ${node.model.id}`
// )
await this.convertToNode(ref, childNode)
this.displayableLookup(ref, childNode)
}
}