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

executeMenuCommand and doScript problem in VS Code ExtendScript Debugger 2.0.3

Community Beginner ,
Nov 14, 2022 Nov 14, 2022

Copy link to clipboard

Copied

Hello everyone. 

I finally ran into a problem with which I decided to write here. A few days ago I decided to take a chance on debugging in VS Code. Everything was well but today I lost several hours in the process of writing a draft of one of the functions trying to figure out what was doing wrong. And then I decided to run the same code in ESTK and - surprise! - it worked as it should.
Win10, Illustrator 2023

The problem occurred when calling Pathfinder -> Substract (and Minus Back).
At first I did it via app.executeMenuCommand("Live Pathfinder Subtract"), but it just didn't work (or was wrong sometimes). I carefully checked everything and tried different options, nothing helped and I decided to use app.doScript. This worked if it was the only line in the script. But when it's inside a function, the illustrator just freezes at the moment the action is executed.
I have another calls of executeMenuCommand and doScript in my current developing script and it works as it should be.
I've tried restarting VS Code and Illustrator, googled a lot, restarted the computer couple times. Nothing helped until I remembered that there is an old, but familiar ESTK, open it and app.doScript worked without problems. Although app.executeMenuCommand("Live Pathfinder Subtract") still doesn't work. As a result, I reinstalled the ExtendScript Debugger extension by reducing the version to 1.1.2 and in VS Code it now also works.

So, the question is: the problem is in me and can it be fixed, or is it better not to upgrade to the latest version yet so that with every error I don’t think it’s me stupid or the debugger again decided to waste a couple of hours of life? Perhaps I need to somehow clear the test results that remain in memory ...
Thank you for your attention, I will be grateful for any comments.

TOPICS
Scripting

Views

132

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 ,
Nov 14, 2022 Nov 14, 2022

Copy link to clipboard

Copied

Hi @itsenouphoto, we need some more information. Can you post a short script/demo file that shows the problem? Then we can try to reproduce your problem and we'll know how widespread the problem is I think.

- 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
Community Beginner ,
Nov 15, 2022 Nov 15, 2022

Copy link to clipboard

Copied

LATEST

Hi @m1b . Sorry for the long answer, I decided that first I need to complete the task with the tools that allow it, and then figure out how the new ones work.

Here is the link to the all files: https://drive.google.com/drive/folders/1J6t0FxhRAKnTs0bIRRw9R0C21s_3HtwF?usp=sharing (.aia Action file is not supported here)

And the text of the function:

 

var targetDoc = app.activeDocument;
cleanByBotL();
$.writeln("\n---rdy");


function cleanByBotL(){
	var targetObj = targetDoc.layers[0].pageItems.getByName("Traced_Image");
	var lrsList = [];
	for (i = 0; i< targetObj.pageItems.length; i++){
		lrsList[i] = targetObj.pageItems[i].name; 
	}
	lrsList = lrsList.reverse();

	//for (i = 0; i< 1; i++){
		//$.writeln("Fix lrsList["+i+"] = " + lrsList[i]);
		var i = 3;		// for test on one item
		var groupToMin = targetObj.groupItems.add();
		groupToMin.name = "grToMinus";
		groupToMin.move(targetObj.pageItems.getByName(lrsList[i]), ElementPlacement.PLACEBEFORE);

		var numGr = i;
		targetDoc.selection = null;
		for (numGr; numGr < lrsList.length-1 ; ){
			numGr++;
			targetObj.pageItems.getByName(lrsList[numGr]).duplicate(groupToMin);
			$.writeln("Fix lrsList["+ numGr +"] = " + lrsList[numGr]);
		}

		targetDoc.selection = null;
		groupToMin.selected = true;
		app.executeMenuCommand("compoundPath");
		targetObj.pageItems.getByName(lrsList[i]).selected = true;
		
		$.writeln("tst 1"); // Here I can see where the AI freesing
		app.doScript("Path_2" , "Lines_js_action", false); 	// So thats the problem
		//app.executeMenuCommand("Live Pathfinder Subtract");  // Here too, but it just not working
		$.writeln("tst 2"); //or not freesing 

		app.executeMenuCommand("compoundPath"); 
		targetDoc.selection[0].name = lrsList[i];
		targetObj.pageItems.getByName(lrsList[i]).selected = true;
		$.writeln("targetDoc.selection = " + targetDoc.selection);
	//}
}

 

By the way, I tried a few more tests and realized that after reinstalling the VS Code ExtendScript extension  to any version, most often this line works when I start it for the first time. And then it starts crashing again.

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