我使用大的revit文件,并且在通过getProperties(id)
访问属性时使用。
是否存在按属性筛选的最佳实践方法,因为它会导致性能问题?
我的方法:
/**
* Looks inside the Autodesk-Database for the material category and looks if the material is concrete.
* Returns asynchronously an array with all ids which represent parts built with concrete material
* @returns {Promise<Array | void>}
*/
async getConcreteIds() {
const wallfloorids = await this.getWallFloorIds()
let concreteIds = []
let filterCategory = 'Materialien und Oberflächen'
let filterValue = 'Concrete'
let promises = wallfloorids.map(id => {
let p1 = this.getProperties(id)
return p1
.then((props) => {
console.log(props)
for (let prop of props) {
let filtercondition =
prop.displayCategory === filterCategory &&
prop.displayValue.contains(filterValue)
if (filtercondition) {
concreteIds.push(id)
}
}
})
.catch(err => console.log(err))
})
return Promise.all(promises)
.then( concreteIds)
.catch(err => console.log('Err', err))
}
/**
* acquires properties of a part out of Autodesk Database
* @param dbId
* @returns {Promise<any>}
*/
getProperties(dbId): Promise<any> {
return new Promise((resolve, reject) => {
this.viewer.getProperties(
dbId,
args => {
resolve(args.properties)
},
reject
)
})
}
直到我使用一个小文件时,此方法才起作用,因为该小文件没有那么多的属性和dbId。
答案 0 :(得分:0)
这是一个名为List<T> objects = ...;
List<Result> result = objects.parallelStream().map(object -> {
return compute(object);
}).collect(Collectors.toList());
的函数,可用于搜索具有特定值的属性:
Viewer3D#search
或者您可以使用viewer.search('Concrete',
function(dbIds) {
console.log( dbIds );
},
function( error ) {
console.error( error )
},
['Structural Material']
);
来获取给定Viewer3D#getBulkProperties
的许多与传递的属性名称匹配的属性:
dbIds
检查她的参考文献
希望有帮助。