• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

AE scripting Grid to Guides

Participant ,
Jun 23, 2022 Jun 23, 2022

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.

 

var window = new Window("palette", "Grid To Guides", undefined);
var startButton = window.add("button", undefined, "RUN");
var guidesVisButton = window.add("button", undefined, "VISIBILITY");


startButton.onClick = function(){
var comp = app.project.activeItem;
var layGrid = comp.selectedLayers[0];
var effX = layGrid.property("Effects").property("Grid").property(1);
var xGuideStart = comp.addGuide(1, effX.value);

alert(effX.name);
 
}
guidesVisButton.onClick = function(){
app.activeViewer.views[0].options.guidesVisibility;
}

 

 

 

 

TOPICS
How to , Scripting

Views

483

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 23, 2022 Jun 23, 2022

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.

 

Votes

Translate

Translate
Community Expert ,
Jun 23, 2022 Jun 23, 2022

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/

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 23, 2022 Jun 23, 2022

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:

 

button1.onClick = function(){
var comp = app.project.activeItem;
var layGrid = comp.selectedLayers[0];
var effA= layGrid.property("Effects").property("Grid").property(1); // anchor
var effW= layGrid.property("Effects").property("Grid").property(4); // width
var effH= layGrid.property("Effects").property("Grid").property(5); // height

var effX = effA.value[0]; // value of X anchor
var effY = effA.value[1]; // value of Y anchor
var effHor = effW.value; // value of Width
var effVer = effH.value; // value of Height

 

for (i = effX; i < 1920; i += effHor){

comp.addGuide(1, i);

}

for (i = effY; i < 1080; i += effVer){

comp.addGuide(0, i);

}
 
 
Any chance you can be generous enough to guide me on how to have "Visibility" working. Thank you in advance.

}
guidesVisButton.onClick = function(){
app.activeViewer.views[0].options.guidesVisibility;
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 23, 2022 Jun 23, 2022

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.

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 23, 2022 Jun 23, 2022

Copy link to clipboard

Copied

Thank you. Enabling visibility worked but

for some reason, the toggle option doesn't work. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 23, 2022 Jun 23, 2022

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 24, 2022 Jun 24, 2022

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;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 24, 2022 Jun 24, 2022

Copy link to clipboard

Copied

Oh, yes, cut & paste error, sorry.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 27, 2022 Jun 27, 2022

Copy link to clipboard

Copied

LATEST

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines