Relink embedded envelope distorted images in code?
Hi all,
My coding experience is minimal, though I am trying to automate the creation of marketing images using a template in Illustrator. Some artboards contain 'In-Situ' images with envelope-distorted files, and this I ask for advice for only a portion of what I'm trying to do. Though here's some context of the overall functionality of the JavaScript script i'm trying to write:
1) .ai file is located to replace main image
- user is given pop up to input comma separated list of SKUs to search (ex. ART001,ART002, ...)
- locates folder names with SKUs in (ex. /ART001-a house)
- locates .ai files in that folder
- opens if there's one
- asks user to select .ai file if there's many
2) Create Main Image by replacing linked .ai file - as shown to the left of Image 1
- script recognises orientation of .ai file chosen by user
- export for screens the Artboard with correct orientation
3) Create Marketing Images using recently exported Main Image
- orientation is remembered and keeps appropriate layers hidden
- Symbol is amended
- orientation
- object within symbol is relinked with recently exported Main Image
- export for screens all marketing artboards

(Image 1 - Main Images of the left, marketing images on right)
I can access the orientation and file selection aspects of 1) , I am looking for help with sections 2) and 3) with regards to the relink feature.
As envelope-distort feature is prefers embedded images, i am looking for a way to replace embedded images through JavaScript. Within illustrator, i can clearly see and use the relink button on embedded items. However within code and in searching through the Scripting Guide, I can't seem to find any relink function like placedItem.replace() for embedded items. I thought the solution was in pageItems as:
I tried going from another angle to relinking all images at once through symbols. So far it has worked where I manually relink and embed the object inside the symbol, so that all instances, even those envelope-distorted, are updated. However, when transferring this to JavaScript, i can't see any way of accessing the objects within the symbol object, but even if it is manageable, the same problem arises where there's no ability to relink a pluginItem.

(Image 2 - Replacing linked image in symbol)
Thanks for your time reading through this. If you have any advice, that would be muchly appreciated!
