Reputation: 149
i am trying to isolate an array of dbid in the viewer that contains multi models. but the problem sometimes isolate model A and sometimes model B is there any way to isolate both models at the same time?
function getExternalIds(model: any): any {
return new Promise(function(resolve, reject) {
model.getExternalIdMapping(resolve, reject);
});
}
//---------------------------------------------
async function isolateAndColorObject(
viewer: any,
externalId ? : string[],
color ? : any
) {
const externalIds = await getExternalIds(viewer.model);
let arr: any = [];
externalId ? .forEach((id) => {
const dbid = externalIds[id];
arr.push(dbid);
});
for (const model of viewer.getAllModels()) { //viewer.getVisibleModels()
viewer.isolate(arr, model);
}
}
//calling the function:
isolateAndColorObject(viewer, [
"5aa7c220-434e-47ec-966b-7aa35a5327a9-001c988b",
"5cd83cb7-08c9-4bb2-bf3a-523af6622a4f-000e9567",
"4845d7d6-c3ba-433c-9418-acbdb1ff7e5f-0011d9e2",
"7e6d9dcb-b26f-4e71-9eb2-3169d28411da-001e3370",
]);
Upvotes: 0
Views: 160
Reputation: 149
update: I have fixed
function getExternalIds(
model: Autodesk.Viewing.Model
): Promise<{ [key: string]: number }> {
return new Promise(function (resolve, reject) {
model.getExternalIdMapping(resolve, reject);
});
}
async function isolateAndColorObject(
viewer: Autodesk.Viewing.GuiViewer3D,
externalIds: string[]
) {
let neededDbId: number[] = [];
const allModels = viewer.getAllModels();
if (allModels) {
for await (const model of allModels) {
const iExIds = await getExternalIds(model);
if (iExIds) {
externalIds.forEach((id: string) => {
const dbid = iExIds[id];
neededDbId.push(dbid);
});
}
viewer.isolate(neededDbId, model);
}
}
}
Upvotes: 1