You may want to programmatically duplicate a layer. In my case, it's some animated text, everything about the animated text is the same, except for the sourceText.
One hack is to manually duplicate it and manage indexes on your own. This gets messy very quickly.
My logic is to duplicate the layers ahead of time, then treat each of the layers as an asset in the render.
The problem with this is the duplication happens as an asset itself and has the same runtime. So the other assets are unaware of the duplicate layers on execution. So you can't create a duplicate layer script in the assets option. The other assets won't recognize the new layers.
// Nexrender Render
await render(
{
template: {
src: `file://${AEP_PATH}/main.aep`,
composition: "Comp 1"
},
assets: [
{
src: `file:///${__dirname + "/scripts/duplicateLayers.jsx"}`,
type: "script",
parameters: [
{
key: "layerName",
value: "Layer5"
}
]
},
...mainProperties
],
actions: {
postrender: [
{
module: "@nexrender/action-encode",
preset: "mp4",
output: "encoded.mp4"
},
{
module: "@nexrender/action-copy",
input: "encoded.mp4",
output
}
]
},
onRenderProgress: (progress) => {
updateProgress(18 * (progress.renderProgress / 100) + 80, "Rendering some sweet stuff");
}
}
);
// Duplicate layer
nexrender.selectLayersByName(null, NX.get("layerName"), function(layer) {
var newLayer;
newLayer = layer.duplicate();
newLayer.name = "[" + NX.get("layerName") + "_0]"; // hardcode 0 for testing
});
How can we execute a script pre-render so that we can inject duplicate layers before the actual execution? The goal is to get the assets to recognize the duplicates. Doing this via script is needed for reducing bottlenecks.
Any ideas?
Unfortunately, I have no real ideas for that.
The only thing I could suggest is to create some sort of no-render job, that would run aerender, run script, and re-save project via Scripting. And then somehow use that project second time to render the job. That sounds a bit weird, but might be the direction that could work. What do you think?
I think that is a great idea. I just tried it and it worked.
The key was app.project.save() after duplication. I haven't wired it up all the way yet but this seems promising and to me is a very powerful feature :)
Glad to hear that :D
For the record, this is an amazing resource http://docs.aenhancers.com/
I am running into a roadblock where duplicated layers dont work as they need to be duplicated in the project panel then added to the timeline. So I am going through the docs to see if I can make that possible. If anyone has some insight hit me up please.
For this particular question. I am going to close it as that is the correct approach.
Render an .aep file programmatically using the nexrender render function with skipRender set to true. Then get your layers in order. Then use the new .aep file in the actual rendering. It works well!