Forum Replies Created
-
Emre Mutlu
August 8, 2022 at 1:52 pm in reply to: Grouping layers in a comp with using prefix and precomposing them (Extendscript)I’ve solved it. I’m sharing the code block. Maybe it can help.
var selectAiFiles = File.openDialog([“Select scene *.ai file”], [“Illustrator:*.ai”], [true]);
for (var i = 0; i < selectAiFiles.length; i++) {
var importAiFiles = new ImportOptions(File(selectAiFiles[i]));
if (importAiFiles.canImportAs(ImportAsType.COMP_CROPPED_LAYERS)) {
importAiFiles.importAs = ImportAsType.COMP_CROPPED_LAYERS;
var aiComp = app.project.importFile(importAiFiles);
aiComp.name = selectAiFiles[i].name.slice(0, -3);
var layerNamesArr = new Array();
var layerIndexArr = new Array();
for (var k = 1; k <= aiComp.numLayers; k++) {
if (k == aiComp.numLayers) {
break;
}
var tempNameArr = [aiComp.layers[k]];
var tempIndexArr = [k];
for (var l = k + 1; l <= aiComp.numLayers; l++) {
if (aiComp.layers[k].name.slice(0, 2) == aiComp.layers[l].name.slice(0, 2)) {
tempNameArr.push(aiComp.layers[l]);
tempIndexArr.push(aiComp.layers[l].index);
}
}
var isContiune = false;
if (layerNamesArr.length >= 1) {
var checkIndex = layerNamesArr.length - 1;
for (var c = 0; c < layerNamesArr[checkIndex].length; c++) {
if (layerNamesArr[checkIndex][c].name === aiComp.layers[k].name) {
isContiune = true;
}
}
}
if (isContiune) {
continue;
}
layerNamesArr.push(tempNameArr);
layerIndexArr.push(tempIndexArr);
}
}
function makePreComposeIndexArray(count, content) {
var result = [];
for (var i = 0; i < count; i++) {
result.push(content(i));
}
return result;
}
for (var v = 0; v < layerIndexArr.length; v++) {
var preComposeIndexArr = layerIndexArr[v];
if (v !== 0) {
preComposeIndexArr = makePreComposeIndexArray(layerIndexArr[v].length, function(i) {
return i + v + 1;
});
}
aiComp.layers.precompose(preComposeIndexArr, layerNamesArr[v][0].name, true);
}
/* for (var d = 1; d <= aiComp.numLayers; d++) {
aiComp.layer(d).copyToComp(mainComp)
} */
}
}; var selectAiFiles = File.openDialog(["Select scene *.ai file"], ["Illustrator:*.ai"], [true]); for (var i = 0; i < selectAiFiles.length; i++) { var importAiFiles = new ImportOptions(File(selectAiFiles[i])); if (importAiFiles.canImportAs(ImportAsType.COMP_CROPPED_LAYERS)) { importAiFiles.importAs = ImportAsType.COMP_CROPPED_LAYERS; var aiComp = app.project.importFile(importAiFiles); aiComp.name = selectAiFiles[i].name.slice(0, -3); var layerNamesArr = new Array(); var layerIndexArr = new Array(); for (var k = 1; k <= aiComp.numLayers; k++) { if (k == aiComp.numLayers) { break; } var tempNameArr = [aiComp.layers[k]]; var tempIndexArr = [k]; for (var l = k + 1; l <= aiComp.numLayers; l++) { if (aiComp.layers[k].name.slice(0, 2) == aiComp.layers[l].name.slice(0, 2)) { tempNameArr.push(aiComp.layers[l]); tempIndexArr.push(aiComp.layers[l].index); } } var isContiune = false; if (layerNamesArr.length >= 1) { var checkIndex = layerNamesArr.length - 1; for (var c = 0; c < layerNamesArr[checkIndex].length; c++) { if (layerNamesArr[checkIndex][c].name === aiComp.layers[k].name) { isContiune = true; } } } if (isContiune) { continue; } layerNamesArr.push(tempNameArr); layerIndexArr.push(tempIndexArr); } } function makePreComposeIndexArray(count, content) { var result = []; for (var i = 0; i < count; i++) { result.push(content(i)); } return result; } for (var v = 0; v < layerIndexArr.length; v++) { var preComposeIndexArr = layerIndexArr[v]; if (v !== 0) { preComposeIndexArr = makePreComposeIndexArray(layerIndexArr[v].length, function(i) { return i + v + 1; }); } aiComp.layers.precompose(preComposeIndexArr, layerNamesArr[v][0].name, true); } } };
-
I’ll try it. Thank you Andrei.
-
Thank you Dan and Filip.
-
Emre Mutlu
July 1, 2022 at 7:34 am in reply to: Creating a textbox and align it to an area via extendscriptThank you very much guys. I was having trouble to change style of the text box which i’ve added but figure it out too. I’m adding my code here too. Looks like you should use TextDocument object to modify the style of text box.
var titleLayer = mainComp.layers.addBoxText([1250,500]);
// Title Text Properities ///////////////////////////////////////////
var titleTextDoc = new TextDocument(“Test Text”);
titleLayer.property(“Source Text”).setValue(titleTextDoc);
var textProp = titleLayer.property(“Source Text”);
titleTextDoc = textProp.value;
titleTextDoc.fontSize = 50;
titleTextDoc.text = title;
titleTextDoc.fillColor = [1,0,0];
titleTextDoc.justification = ParagraphJustification.CENTER_JUSTIFY;
textProp.setValue(titleTextDoc);
-
Looks like it’s a bug. I have delete the file and copy again and it works. Thank you.
-
Emre Mutlu
June 29, 2022 at 6:01 am in reply to: Using bounding box in extendscript (and using it to create a mask path)Thank you very much. This has been extremely helpful.
-
Emre Mutlu
June 28, 2022 at 9:49 pm in reply to: Using bounding box in extendscript (and using it to create a mask path)Thank you Dan. I tried your way and it worked.
I was talking about scripting. I post here because can’t find a scripting topic. How could i do it with script? Could you please explain the logic in this so that i can understand it 🙂 Also is there a way to create the mask point without using pen tool?
-
Thanks for your replies and your time guys.
-
Do you mean disabling “Use Display Color Management”? If so i’ve tried with it but couldn’t figure it out.
What’s the proper way of doing this? I’m sending my project also.