Copy link to clipboard
Copied
how to separate layers in illustrator for after effects
is there better script or trick that release to layer sequence ???
Copy link to clipboard
Copied
Do you know about Overlord? Are you trying to find an alternative? A pure script that's comparable is not going to be easy to make but Overlord has a lot more functions than what's asked here. Separating objects as layers itself is pretty simple, but I wanted to check first.
Copy link to clipboard
Copied
overlord import ai objects as shapes and many shapes makes ae runs too slow
Copy link to clipboard
Copied
I'm not sure this would be any more performant, here's how I would do it:
// Converts an Illustrator collection to a normal Array
function get(type, parent) {
parent = parent ? parent : app.activeDocument
var result = [];
if (!parent[type]) return [];
for (var i = 0; i < parent[type].length; i++)
result.push(parent[type][i]);
return result || [];
}
// Syntactical sugar to act on each item within a normal Array
Array.prototype.forEach = function (callback) {
for (var i = 0; i < this.length; i++) callback(this[i], i, this);
};
// Do something to each pageItem
get('pageItems').forEach(function (pageItem) {
// Add a new layer per item
var layer = app.activeDocument.layers.add();
// If an item is named, have the layer inherit that name
if (pageItem.name) layer.name = pageItem.name;
// Move the item into the layer, then proceed in loop
pageItem.move(layer, ElementPlacement.PLACEATBEGINNING);
});
// Do something to each Layer
get('layers').forEach(function (layer) {
// If the layer is empty and was one we'd removed items from originally, remove it
if (!layer.pageItems.length) layer.remove();
})
But in case you're trying to learn scripting, the easiest way would be more like this:
var doc = app.activeDocument;
// Loop through all pageItems in current document
for (var i = 0; i < doc.pageItems.length; i++) {
// Identify item and create a new layer for this item
var item = doc.pageItems[i];
var layer = doc.layers.add();
// If an item is named, have the layer inherit that name
if (item.name) layer.name = item.name;
// Move the item into the layer, then proceed in loop
item.move(layer, ElementPlacement.PLACEATBEGINNING);
}
The first might seem far more complicated than it needs to be, but if you had more than one instance where you needed to loop through certain items (pageItems, compoudItems, rasterItems, etc) you'd begin to see how it would slim down the end result far more for complex requirements.
Copy link to clipboard
Copied
how can i use wat you just typed bro ?