伪造查看器在查看器中隔离多个模型
Posted
技术标签:
【中文标题】伪造查看器在查看器中隔离多个模型【英文标题】:forge viewer isolatemulti models in the veiwer 【发布时间】:2021-11-07 20:22:21 【问题描述】:我正在尝试在包含多个模型的查看器中隔离一个 dbid 数组。但是问题有时会隔离模型 A 有时会隔离模型 B 有没有办法同时隔离两个模型?
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",
]);
【问题讨论】:
【参考方案1】:更新:我已经修复了
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);
【讨论】:
您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center。以上是关于伪造查看器在查看器中隔离多个模型的主要内容,如果未能解决你的问题,请参考以下文章