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

Script works on one device but not another (Error -54)

New Here ,
Oct 16, 2024 Oct 16, 2024

Copy link to clipboard

Copied

Hi, I have a script which works fine on my device, but not on the device of the person I made the script for, both devices are windows and using the same Illustrator version. The script fails on the file opening section. Here is the error message they get:

Error 1200: an Illustrator error occured: -54 (ÿÿÿÊ)

unnamed (8).png

The code for the script is below.

Any help would be appreciated, thanks.

 

 

var input = 'G:/Shared drives/Creative Drive/Test Input';
var output = 'G:/Shared drives/Creative Drive/Test Output';
var inputFolder = Folder(input);
var outputFolder = Folder(output);
var theFiles = inputFolder.getFiles();
var thePath = outputFolder.path;
main();
function main(){
	if (theFiles) {
		for (var m = 0; m < theFiles.length; m++) { 
			var filename = theFiles[m].name.toString();
			if (filename.indexOf(".ai") > 0){
				var splits = filename.split("_");
				var fileRef = new File( input+'/'+filename );
				var doc_a = app.open(fileRef);
				var illustratorDoc = app.activeDocument;

				// Select everything in the Illustrator document
				illustratorDoc.selectObjectsOnActiveArtboard();

				// Copy selected objects
				app.copy();
				// Launch Photoshop
				var psApp = null;

				try {
					// Try to get a reference to Photoshop
					psApp = BridgeTalk.getSpecifier("photoshop");
			
					// If Photoshop isn't running, launch it
					if (!psApp) {
						var photoshopApp = new File(app.path + "/../Adobe Photoshop/Photoshop.exe");
						photoshopApp.execute();
						$.sleep(3000); // Wait for Photoshop to launch
					}
				} catch (e) {
					alert("Error: Unable to communicate with Photoshop.");
				}
				if (splits[1].toUpperCase() == "A6"){
					var psWidth = "2719";
					var psHeight = "1987"; 
				}
				else if (splits[1].toUpperCase() == "7X5"){
					var psWidth = "3275";
					var psHeight = "2375"; 
				}
				else if (splits[1].toUpperCase() == "SQ"){
					var psWidth = "4404";
					var psHeight = "2340"; 
				}

				// Create a new Photoshop document
				var bt = new BridgeTalk();
				bt.target = "photoshop";
				var nam = filename.replace(".ai","")
				bt.body = "app.documents.add("+psWidth+", "+psHeight+", 300, '"+nam+"');"; // Adjust dimensions/resolution as needed
				bt.send(5);

				// Now paste the Illustrator contents into Photoshop
				bt.body = "app.activeDocument.paste();";
				bt.send(5);

				// Specify the path to the Photoshop script file
				var scriptFilePath = 'G:/Shared drives/Creative Drive/PS Script.jsx';
				// Read the contents of the script file
				var scriptFile = new File(scriptFilePath);
				scriptFile.open('r');
				var scriptContents = scriptFile.read();
				scriptFile.close();

				// Execute the Photoshop script
				bt.body = scriptContents;
				bt.send(300);
			}
		}
	}
}

 

TOPICS
Bug , Scripting

Views

273

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
Adobe
Community Expert ,
Oct 16, 2024 Oct 16, 2024

Copy link to clipboard

Copied

Do both machines have the same mapping for G drive?

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
New Here ,
Oct 16, 2024 Oct 16, 2024

Copy link to clipboard

Copied

Yes they do

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 ,
Oct 16, 2024 Oct 16, 2024

Copy link to clipboard

Copied

Hi @maddygale, great script. Unfortunately I have no idea why it is throwing the error. I had a search around and there was another case where app.paste() was giving error 1200.

 

Can I just double-check: is there a reason why you can't script this in Photoshop as normal place linked (or embedded) images? That would seem to avoid the complexities of BridgeTalk.

 

If that doesn't work in your case, a more robust approach might be to export the .ai document's artboard(s) either as .ai (or maybe as .psd?) and then Photoshop does the place linked command. I'm only exploring this because I always avoid app.copy/paste if I can help it, especially if I am handing the script off to someone else.

- Mark

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
New Here ,
Oct 16, 2024 Oct 16, 2024

Copy link to clipboard

Copied

Unfortunetly I've not found a way around not using bridge script yet, I need to preserve the layers and layer names from the illustrator file which so far the only way I've got working is copying and pasting from illustrator to photoshop.  Exporting as a PSD with write layers and maximum editability doesnt seem to preserve the layers

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 ,
Oct 16, 2024 Oct 16, 2024

Copy link to clipboard

Copied

Interesting! When I run your script, it sometimes fails on the first try saying something about [Paste] menu is not available. It works on second and subsequent times, but it doesn't preserve layers—I get a single layer with Illustrator content combined always called "Layer 1", even with basic appearances. I'm on MacOS though, so maybe the copy/paste works differently.

 

Exporting as a PSD with write layers and maximum editability doesnt seem to preserve the layers

 

It depends on your artwork. It will flatten anything that it thinks it needs to flatten to preserve the appearance. Certain things (sorry I can't remember what they are) *always* cause the flattening and avoiding them in your artwork will prevent the flattening. Still, no help if you must have those things.

- Mark

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
New Here ,
Oct 22, 2024 Oct 22, 2024

Copy link to clipboard

Copied

LATEST

I dont think its the Mac, but it defaults to flattening it when pasting, to get it to do layers you first have to manually copy something from Illustrator then paste in photoshop it'll give you a few options, select layers then run the script and it will save that selection, annoyingly it doesnt save after closing and reopening photoshop.

maddygale_0-1729599017270.png

 

I'm not the one who does the artwork so I dont know if they need to use the things that always flatten or not tbh, any chance you know what gets automatically flattened when trying to export as layers?

 

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