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

Create jsx file?

Community Beginner ,
Jan 18, 2020 Jan 18, 2020

Im trying to create a jsx file. I thought you did this out of the Adobe Extendscript Toolkit, which appears to no longer be available in the app manager. I changed the preferences to show older apps, still isnt showing up. Does anyone know what the issue is? Is there another way to create a jsx file?

TOPICS
Expressions , How to , Scripting , User interface or workspaces
30.1K
Translate
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

Enthusiast , Jan 18, 2020 Jan 18, 2020

Hi, a .jsx file is just a text file with the extension ".jsx". You can use any program to create them (or manually rename any file into .jsx) and any text editor to write your code without ever touching the ESTK. That said, I'd recommend VSCode since it's amazing as a source code editor, free and open source from Microsoft, and Adobe has moved ESTK support to VSCode

Translate
Enthusiast ,
Jan 18, 2020 Jan 18, 2020

Hi, a .jsx file is just a text file with the extension ".jsx". You can use any program to create them (or manually rename any file into .jsx) and any text editor to write your code without ever touching the ESTK. That said, I'd recommend VSCode since it's amazing as a source code editor, free and open source from Microsoft, and Adobe has moved ESTK support to VSCode

Translate
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
Enthusiast ,
Jan 18, 2020 Jan 18, 2020

If you want a sample of how VSCode feels, here's a sandbox browser version setup for After Effects scripting. Try typing app and a period, then press the info icon in the popup menu to expand and see the intellisense for the app DOM.

 

Also mandatory plug for Adobe Script Runner from renderTom so you can launch scripts from VSCode as you type them

Translate
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
Explorer ,
May 05, 2021 May 05, 2021

Hi All,  

I tried creating scripts for both versions and they worked I used Text Edit, saved as jsx, added the script toAI scripts, and was able to see the script in Adobe Illustrator upon relaunching.

Is it possible that it will no longer work for the later versions of AI? I am currently using AI 2021 25.2.3.

I receive the below error message:

patd61312907_0-1620228939380.pngexpand image

I removed the .rtf extension and replaced it with .jsx, is this correct?

Perhaps I am missing something...

 

Translate
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
New Here ,
Jun 24, 2021 Jun 24, 2021

Hi, you are indeed missing something.

You are changing the file format to .jsx and that is fine, but the error you are getting happens because the file does not comply with UTF-8 (character encoding).

 

To fix it, if you are using the "TextEdit" from mac, you should go to:

 

TextEdit -> Preferences -> Plain Text

 

Now, you can save the file in Unicode (UTF-8), then, change the file extension to .jsx just like you did before.

Translate
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
New Here ,
Jul 01, 2021 Jul 01, 2021

hey, got the same error message, after changing the text to plain text.

any help?

Translate
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
New Here ,
Oct 12, 2021 Oct 12, 2021

Hi, I had this issue to and I was able to resolve it. Make sure when you save to plain text that you add .js to the end of the filename. Format is [yourfilename].js

This should work.

Translate
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
New Here ,
Sep 17, 2021 Sep 17, 2021

Copy an existing .jsx file from the folder Apps/Adobe Illustrator 2021/Scripting, replace the content with the suggested code and save it. After that, I was able to load the script into Illustrator. 

When I created a totally new jsx file, I also got the error message (syntax error)

Translate
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
New Here ,
Oct 20, 2022 Oct 20, 2022

Genius! @twiceav 

Translate
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
New Here ,
Jan 09, 2024 Jan 09, 2024

<>
// Get the active composition var comp = app.project.activeItem; // Check if a
composition is open if(comp != null &amp;&amp; comp instanceof CompItem){"{"}
// Check if the square layer exists var squareLayer = comp.layer("Square");
if(squareLayer != null &amp;&amp; squareLayer instanceof AVLayer &amp;&amp;
squareLayer.source instanceof SolidSource){"{"}
// Set keyframes for scale and color over 15 frames var duration = 15; var
endTime = squareLayer.startTime + duration; // Set keyframes for scale
squareLayer.property("Scale").setValuesAtTimes([squareLayer.startTime,
endTime], [[100, 100], [0, 0]]); // Set keyframes for color
squareLayer.property("ADBE Color
Control-0001").setValuesAtTimes([squareLayer.startTime, endTime], [[1, 1, 1],
[1, 1, 0]]);
{"}"} else {"{"}
alert("Square layer not found or is not a solid layer.");
{"}"}
{"}"} else {"{"}
alert("No active composition found.");
{"}"}
</>

Translate
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
New Here ,
Feb 18, 2025 Feb 18, 2025
LATEST

(function moveOnProximity() {
var comp = app.project.activeItem;
if (!comp || !(comp instanceof CompItem)) {
alert("Please select a composition.");
return;
}

var layers = comp.selectedLayers;
if (layers.length < 2) {
alert("Select at least two layers (one leader and others to be affected).");
return;
}

var leader = layers[0]; // The first selected layer is the leader
var others = layers.slice(1);

app.beginUndoGroup("Proximity Movement");

for (var i = 0; i < others.length; i++) {
var layer = others[i];

// Add expression to the position property
var expr = `
leader = thisComp.layer("${leader.name}");
leaderPos = leader.position;
myPos = position;
threshold = 150; // Distance at which movement happens
force = 50; // How much the object moves

dist = length(leaderPos, myPos);
if (dist < threshold) {
moveDir = normalize(myPos - leaderPos);
myPos + moveDir * force * (1 - dist / threshold);
} else {
myPos;
}
`;

layer.property("Position").expression = expr;
}

app.endUndoGroup();
})();

Translate
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