I’m curious if there’s a reason the ShapeDiver API doesn’t include a function to retrieve scenePaths by name? Maybe relying on this is risky for some reason?
Following Hide/Show objects - #4 by edsahergom, I’m using the fuction below to retrieve scenePaths for use in ShapeDiver API functions:
function getScenePathByName(name, viewer = "api", type = "material", runtimeId = "CommPlugin_1") {
if (name && type && viewer && runtimeId) {
let nameScenePaths = [];
const getScenePaths = (name) => {
let typeScenePaths = [];
const typeData = viewer.scene.get({name: name}, runtimeId).data.filter(d => d[type]);
typeData.forEach((td) => typeScenePaths = [...typeScenePaths, td.scenePath]);
return (typeScenePaths.length > 1) ? typeScenePaths : typeScenePaths[0];
}
if (Array.isArray(name)) {
name.forEach((n) => {
nameScenePaths = [...nameScenePaths, getScenePaths(n)];
});
} else {
nameScenePaths = getScenePaths(name);
}
return (nameScenePaths.length > 1) ? nameScenePaths : nameScenePaths[0];
}
}
I want to be sure I’m not creating a problem. Thanks