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!