Copy link to clipboard
Copied
Bonjour,
J'ai créé un script avec Chat GPT pour ajouter une propriété Réduire les tracés (TrimPath), mais cela ne fonctionne pas.
J'obtiens un message :
Voici le code :
// Check if a shape layer is selected
if (app.project.activeItem instanceof CompItem && app.project.activeItem.selectedLayers.length > 0) {
var selectedLayer = app.project.activeItem.selectedLayers[0];
// Check if the selected layer is a shape layer
if (selectedLayer instanceof ShapeLayer) {
// Create a new shape
var newShape = new Shape();
// Create a trim path
var trimPath = new ShapeTrimPath();
// Add trim path to the shape
newShape.property("ADBE Root Vectors Group").addProperty("ADBE Vector Shape - Group").addProperty(trimPath);
// Add the shape to the layer
selectedLayer.property("ADBE Root Vectors Group").addProperty(newShape);
alert("Trim Paths property added to the selected shape layer.");
} else {
alert("Please select a shape layer.");
}
} else {
alert("Please select a composition and a shape layer.");
}
La ligne 11 correspondrait à : var trimPath = new ShapeTrimPath();
Comme je ne connais rien à ce langage, je ne vois pas enquoi consiste l'erreur.
Quelle serait la bonne syntaxe ?
Merci.
Parfait !
Je vais gagner beaucoup de temps.
Merci beaucoup.
Copy link to clipboard
Copied
Pour ajouter une propriété trim path à un calque de forme, il faut faire comme ça:
var proj = app.project;
var thisComp = proj.activeItem;
if (thisComp instanceof CompItem && thisComp.selectedLayers.length > 0) {
var selectedLayer = thisComp.selectedLayers[0];
if (selectedLayer instanceof ShapeLayer) {
var shapeGroup = selectedLayer.property("ADBE Root Vectors Group");
// ajout trim path
shapeGroup.addProperty("ADBE Vector Filter - Trim");
// ajout d'images clés sur la propriété Fin
shapeGroup.property("ADBE Vector Filter - Trim").property("ADBE Vector Trim End").setValueAtTime(0, 0);
shapeGroup.property("ADBE Vector Filter - Trim").property("ADBE Vector Trim End").setValueAtTime(thisComp.duration, 0);
}
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Là, tu peux sélectionner un ou plusieurs groupes :
var proj = app.project;
var thisComp = proj.activeItem;
if (thisComp instanceof CompItem && thisComp.selectedLayers.length > 0) {
var selectedLayer = thisComp.selectedLayers[0];
var selectedProperties = selectedLayer.selectedProperties;
if (selectedLayer instanceof ShapeLayer) {
app.beginUndoGroup("Undo");
for (var i = 0; i < selectedProperties.length; i++) {
var shapeGroup = selectedProperties[i]("ADBE Vectors Group");
// ajout trim path
shapeGroup.addProperty("ADBE Vector Filter - Trim");
// ajout d'images clés sur la propriété Fin
shapeGroup.property("ADBE Vector Filter - Trim").property("ADBE Vector Trim End").setValueAtTime(0, 0);
shapeGroup.property("ADBE Vector Filter - Trim").property("ADBE Vector Trim End").setValueAtTime(thisComp.duration, 0);
}
app.endUndoGroup();
}
}
Copy link to clipboard
Copied
Parfait !
Je vais gagner beaucoup de temps.
Merci beaucoup.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more