Hi,
not really an issue here, but I can't get this piece of code returning correctly the toReturn array, so I'm here to ask for help.
Let's say I want to get all the ifcwalls in a project with a particular ifcwalltype via javascript api.
I would like to know if there is a better way than my solution to archieve this and how can I get the
toReturn array back to the calling method, because now, probably due to timing issues, sometimes is empty, no matter how I return back the data.
var BimServerGetElementsWithType = function(projectid,typeoid) { //project oid, ifcwalltype oid
var toReturn = new Array();
Global.bimServerApi.call("Bimsie1ServiceInterface", "getProjectByPoid", {poid: projectid}, function(project) {
Global.bimServerApi.call("Bimsie1LowLevelInterface", "getDataObjectByOid", {roid: project.lastRevisionId, oid: typeoid},
function(data) {
data.values.forEach(function(value){
if (value.__type == "SListDataValue" && value.fieldName =="ObjectTypeOf") {
value.values.forEach(function(listItem, index) {
if (listItem.__type == "SReferenceDataValue" && listItem.typeName == "IfcRelDefinesByType") {
Global.bimServerApi.call("Bimsie1LowLevelInterface", "getDataObjectByOid", {roid: project.lastRevisionId, oid: listItem.oid},
function(data) {
data.values.forEach(function(value){
if (value.__type == "SListDataValue") {
value.values.forEach(function(listItem, index){
if (listItem.__type == "SReferenceDataValue") {
Global.bimServerApi.call("Bimsie1LowLevelInterface", "getDataObjectByOid", {roid: project.lastRevisionId, oid: listItem.oid},
function(data){
toReturn.push(data); // push all the walls with type "typeoid" into the array.
});
};
});
};
});
});
}
});
}
});
});
});
};
Hi, not really an issue here, but I can't get this piece of code returning correctly the
toReturn
array, so I'm here to ask for help.Let's say I want to get all the ifcwalls in a project with a particular ifcwalltype via javascript api. I would like to know if there is a better way than my solution to archieve this and how can I get the toReturn array back to the calling method, because now, probably due to timing issues, sometimes is empty, no matter how I return back the data.
TIA for your time.