Quitter
  • Communauté internationale
    • Langue:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티

Illustrator Envelope Distort in Javascript

Nouveau ici ,
Apr 23, 2025 Apr 23, 2025

I have been struggling to find a way to do the following in javascript:

 

1) Open an .ai file that contains a shape (in this case its a warped rectangle)

2) Place a PNG file

3) Move the PNG file below the warped shape

4) Perform an envelope distort (Make with Top Object) on the shape + PNG file

 

This seems stupid simple, but I can't figure out a way to do the Make with Top Object envelope distort using javascript.

 

Any help would be amazing.

 

Thanks!

SUJETS
Scripting
433
Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines

correct answers 1 bonne réponse

Community Expert , Apr 23, 2025 Apr 23, 2025

Here's a JavaScript script for Adobe Illustrator that accomplishes those tasks. The key is using the envelopeDistort method for the "Make with Top Object" functionality:
javascript
// Get the active document
var doc = app.activeDocument;

// 1. Open .ai file - assuming it's already open for this script
// If you need to open it programmatically:
// app.open(File("/path/to/your/file.ai"));

// 2. Place PNG file
var pngFile = new File("/path/to/your/image.png");
var placedItem = doc.placedItems.add();
place

...
Traduire
Adobe
Community Expert ,
Apr 23, 2025 Apr 23, 2025

Hello! 

Have you used Actions in Illustrator? You can record step-by-step what you need and then apply it to one or multiple files as required.
@camiloadobe
Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines
Nouveau ici ,
Apr 23, 2025 Apr 23, 2025

Yes, use them all the time.  But I need a javascript solution.  This is part of a suite of tools that I have built in Javascript to sit on top of illustrator to automate a ton of our work.  

 

Thanks

Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines
Community Expert ,
Apr 23, 2025 Apr 23, 2025
LA PLUS RÉCENTE

Here's a JavaScript script for Adobe Illustrator that accomplishes those tasks. The key is using the envelopeDistort method for the "Make with Top Object" functionality:
javascript
// Get the active document
var doc = app.activeDocument;

// 1. Open .ai file - assuming it's already open for this script
// If you need to open it programmatically:
// app.open(File("/path/to/your/file.ai"));

// 2. Place PNG file
var pngFile = new File("/path/to/your/image.png");
var placedItem = doc.placedItems.add();
placedItem.file = pngFile;

// 3. Move PNG below the warped shape
// Assuming the warped rectangle is the topmost path item
var warpedShape = doc.pathItems[0];
placedItem.move(warpedShape, ElementPlacement.PLACEBELOW);

// 4. Perform Envelope Distort (Make with Top Object)
// Select both items
warpedShape.selected = true;
placedItem.selected = true;

// Create envelope distort
app.executeMenuCommand("Make Envelope");

Key notes:
Replace "/path/to/your/image.png" with the actual PNG file path

The script assumes the warped rectangle is the topmost path item

executeMenuCommand("Make Envelope") is equivalent to "Make with Top Object"

Make sure both items are selected before the envelope distort

Run this in Adobe Illustrator's ExtendScript Toolkit or as a .jsx file
If the .ai file isn't open, uncomment the app.open() line and provide the correct path. Let me know if you need help with file paths or error handling!

@camiloadobe
Traduire
Signaler
Directives de la communauté
Restez bienveillant et courtois, ne vous attribuez pas la paternité des créations d’autrui et assurez-vous de l’absence de doublons avant de poster du contenu. En savoir plus
community guidelines