Copy link to clipboard
Copied
so I have the following code, it works when the layer is not parented , but when the layer is parented to another layer it fails.
I know this happens because the transform properties of the parented layer doesnt change when you move the parent layer, is there a workaround for it?
app.beginUndoGroup("Add Guides to Anchor Points");
// Get the active composition
var comp = app.project.activeItem;
// Check if a composition is selected
if (!(comp instanceof CompItem)) {
alert("Please select a composition.");
return;
}
// Check if there are selected layers
if (comp.selectedLayers.length === 0) {
alert("Please select at least one layer.");
return;
}
// If "autoclear" is enabled, clear all existing guides
if (Autoclear.value) {
app.executeCommand(2276); // Clear all guides
}
// Loop through each selected layer
for (var i = 0; i < comp.selectedLayers.length; i++) {
var layer = comp.selectedLayers[i];
// Get the layer's anchor point and position
var anchorPoint = layer.anchorPoint.value;
var position = layer.position.value;
// Calculate the composition space position by adding anchor point to position
var guideX = position[0] ;
var guideY = position[1] ;
// Add guides at the calculated position
comp.addGuide(1, guideX); // Vertical guide (X position)
comp.addGuide(0, guideY); // Horizontal guide (Y position)
}
app.endUndoGroup();
AVLayers have a SourcePointToComp function to convert points from layer space to comp space:
https://ae-scripting.docsforadobe.dev/layers/avlayer.html#avlayer-sourcepointtocomp
Copy link to clipboard
Copied
AVLayers have a SourcePointToComp function to convert points from layer space to comp space:
https://ae-scripting.docsforadobe.dev/layers/avlayer.html#avlayer-sourcepointtocomp
Copy link to clipboard
Copied
Thank you so much.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now