Copy link to clipboard
Copied
I am trying to create a simple script where Guides will be generated from the Grid. I know all of this is pretty basic, but I am having a problem accessing "Anchor" in the "Grid" effect. As you can see I am trying to test it just by accessing the name but even that doesn't work. I do not have a problem accessing for example property(4) which is "Width" and I can access the value of the same but with Anchor, I can not. Also, I would like to access each of the Anchor values [x,y] individually. Another question is the guides on/off visibility. I have used the line from "AE scripting guide 2022" but I am obviously missing something basic.
So to summarize:
1) how do I access Anchor in the Grid effect?
2) how do I access Anchor each [x,y] value individually?
3) what and I missing to enable/disable guides visibility with click on the "Visibility" button?
I am working in Visual Studio Code and this is what I wrote so far. Thank you in advance.
1 Correct answer
you need to set the guides visibility to true to enable it:
app.activeViewer.views[0].options.guidesVisibility = true;
Or if you want to toggle it you can use
app.activeViewer.views[0].options.guidesVisibility = !app.activeViewer.views[0].options.guidesVisibility = true;
which sets it to true if it has been false before and vice versa.
Copy link to clipboard
Copied
Maybe my tool GridGuide is already a solution for what you need, such that you don't need to implement anything yourself? If is not using the Grid effect, but shape layers:
https://aescripts.com/gridguide-for-after-effects/
Copy link to clipboard
Copied
Thank you, Mathias,
I have definitely seen your great tool/tools but what I am trying to do here is the following. I already have a grid automatically created by expressions based on text using Webdings square symbol. I am creating automated boxes with different numbers of rows/columns. The grid is resizing with the creation of boxes but as the grid is not snappable I wanted to create guides based on the grid so I can snap the text to the middle of each box. So far I have figured out a few questions I asked above with the following:
Copy link to clipboard
Copied
you need to set the guides visibility to true to enable it:
app.activeViewer.views[0].options.guidesVisibility = true;
Or if you want to toggle it you can use
app.activeViewer.views[0].options.guidesVisibility = !app.activeViewer.views[0].options.guidesVisibility = true;
which sets it to true if it has been false before and vice versa.
Copy link to clipboard
Copied
Thank you. Enabling visibility worked but
for some reason, the toggle option doesn't work.
Copy link to clipboard
Copied
When adding "toggle lines" to the script I am getting the following error message
"Can't appear on the left hand side of an assignment, because it is read-only."
Any idea why is that? Thank you in advance
Copy link to clipboard
Copied
For anyone wondering for toggle on/off correct line is without = true at the end.
app.activeViewer.views[0].options.guidesVisibility = !app.activeViewer.views[0].options.guidesVisibility;
Copy link to clipboard
Copied
Oh, yes, cut & paste error, sorry.
Copy link to clipboard
Copied
The above lines to toggle on/off property work beautifully but is there any way to create the default state for example if I want to toggle on/off for the guides snap, the guides lock, and guides visibility how do I create a default that all of these values are for example off before I make the first click on the button. Thank you in advance.
Copy link to clipboard
Copied
You can set the values for Guides in this way:
var viewerOptions = app.activeViewer.views[0].options;
viewerOptions.guidesSnap = true;
viewerOptions.guidesLocked = false;
viewerOptions.guidesVisibility = true;
Here are all the available properties for the Viewer object:
// app.activeViewer
{
"active": true,
"activeViewIndex": 0,
"maximized": false,
"type": 7612,
"views": [ // app.activeViewer.views[0]
{
"active": true,
"options": { // app.activeViewer.views[0].options
"channels": 7812, // 7812 = RGB (Default); 7813 = Red; 7814 = Green; 7815 = Blue; 7816 = Alpha; 7820 = RGB Straight;
"checkerboards": false, // Transparency Grid
"exposure": 0, // Reset Exposure
"fastPreview": 8012, // 8012 = Off (Final Quality); 8012 = Adaptive Resolution; 8016 = Wireframe;
"guidesLocked": false,
"guidesSnap": true,
"guidesVisibility": true,
"rulers": false,
"zoom": 0.5 // 0.5 = 100%; (100 / 200 = 0.5)
}
}
]
}

