Wrote a code in Asset not working in CI

We wrote a code to hide and show mesh in asset level using custom script. but it doesn’t work in catalog item.

code

let player = undefined;

(async function () {
if (!player) player = api.enableApi(‘player’);
await player.when(‘rendered’);

const { configuration } = api;
// Option 1: Most simple and direct
const frames = api.scene.getAll({ name: /^Open_Frame/i, type: “PolyMesh” });
const names = Object.values(frames).map(item => item.name);
let frameNme = configuration[‘frameName’]
names.forEach(name => {
var flag=false;
if(frameNme==name)flag=true;
setVisibility(name,flag);
});

})();

function setVisibility(nodeName, flag) {
scene.set({
name: nodeName,
plug: ‘Properties’,
property: ‘visible’,
hierarchical: true,
}, flag)
}

Hi Prashant,

Can you try changing

api.scene.getAll({ name: /^Open_Frame/i, type: “PolyMesh” });

to be

api.scene.getAll({ name: /^Open_Frame/i, type: “PolyMesh”, hierarchical: true });

And if that doesn’t work,

api.scene.getAll({ name: /^Open_Frame/i, type: “PolyMesh”, hierarchical: true, from: api.instanceId });

If I’m not mistaken, by default:

  • scene queries will start from the top-most asset, eg. your item, because items are also assets
  • scene queries will not descend into other assets, eg. the query won’t descend from your item into your original asset

Adding hierarchical: true tells the query that it should descend into all assets. I don’t think you’ll need the from parameter I showed, the from parameter indicates where the query should start, in this case, api.instanceId would be the instance ID of your the asset/node your custom script is running from.

Thanks.. it is working as expected