New Numeric Value Expected Error

Explorer ,
Apr 05, 2022 Apr 05, 2022

Copy link to clipboard

Copied

I have this script I wrote called MatchObjects.jsx that I use almost every day via the JSX Launcher panel and it works just fine, but today I wanted to clean up some of the code and when I tried to run the script from the VS Code debugger, I got an Illegal Argument Error: 1242 – Numeric value expected. It had worked fine via the VS Code bugger in October of 2021 when I last worked on the script.

 

Screen Shot 2022-04-05 at 12.13.54.png

 

Since I had yet to change anything in the code this seemed weird to me. So, I placed the script in the Illustrator scripts folder, ran it, and got the same error. And when I checked the variable types in the array the error is complaining about, they are all numbers (numeric values).

 

Screen Shot 2022-04-05 at 12.16.34.png

 

Like I said above, if I run the script from JSX Launcher it works just fine, so I'm not sure when this behavior started. I'm testing on Illustrator 26.0.3. Any ideas?

TOPICS
Scripting

Views

145

Likes

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

correct answers 1 Correct answer

Advocate , Apr 05, 2022 Apr 05, 2022
You've redefined the built-in function getScaleMatrix(), but it appears that the original built-in function is being called.  This expects two numbers, not arrays.  Just call the function in question something else. 

Likes

Translate

Translate
Advocate ,
Apr 05, 2022 Apr 05, 2022

Copy link to clipboard

Copied

You've redefined the built-in function getScaleMatrix(), but it appears that the original built-in function is being called.  This expects two numbers, not arrays.  Just call the function in question something else. 

Likes

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
Explorer ,
Apr 05, 2022 Apr 05, 2022

Copy link to clipboard

Copied

Thanks for your suggestion but I'm not following... getScaleMatrix() is a script specific function that I wrote that takes object bounds (as an array) for the first two arguments, and then a setting from my dialog for the third argument. I use those bounds to calculate the scaling I need to apply to my target objects. And, that still wouldn't explain why it previously worked fine, and still works fine through the JSX Launcher panel.

Likes

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 Professional ,
Apr 05, 2022 Apr 05, 2022

Copy link to clipboard

Copied

Hi @jduncan@femkeblanco is right. There is a native global getScaleMatrix function already. (Try doing $.writeln(getScaleMatrix).) Illustrator is notorious for polluting the global scope with "shortcuts", eg. you can just ask for "selection" which is the same as "app.selection".

 

First thing to do it change the name of the function and see if it works. Maybe using JSX Launcher also starts and targets a different engine?

- Mark

Likes

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
Explorer ,
Apr 05, 2022 Apr 05, 2022

Copy link to clipboard

Copied

Awesome! That was it! This is actually the first thing I thought when I read your first comment, and I even did a quick search of the API for getScaleMatrix and didn't find anything so I moved on. I guess this is something they added/enabled in the last few versions... Either way, it's working just fine now, so THANKS FOR YOUR HELP 👍!

Likes

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 Professional ,
Apr 05, 2022 Apr 05, 2022

Copy link to clipboard

Copied

Another approach is to wrap your (currently globally scoped) code in an IIFE.

(function () {

    // your code here

})()

 I tried it with your code and it worked.

- Mark

Likes

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
Explorer ,
Apr 05, 2022 Apr 05, 2022

Copy link to clipboard

Copied

I'm a dummy 🤦‍:male_sign:! I even call app.getScaleMatrix() in the return statement of my getScaleMatrix() function. Forest for the trees I guess... Thanks again!

Likes

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 Professional ,
Apr 05, 2022 Apr 05, 2022

Copy link to clipboard

Copied

quote

I even did a quick search of the API for getScaleMatrix and didn't find anything so I moved on. I guess this is something they added/enabled in the last few versions...

By @jduncan

 

that's strange, getScaleMatrix() function has been there since the time of the dinosaurs

Likes

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
Explorer ,
Apr 07, 2022 Apr 07, 2022

Copy link to clipboard

Copied

LATEST

Yeah, at the time I was on my phone searching the Illustrator Scripting Guide and if you search for "getScaleMatrix()" no results are returned. I had to search explicitly for "Application.getScaleMatrix()" to find it which I figured out after I commented. The funniest part is I was actually using getScaleMatrix() in my return statement of the offending function. I don't script for Illustrator that often so I just forgot about it 🤦‍:male_sign:.

Likes

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