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

Error: Numeric value expected when top paramater gets negative value

Explorer ,
Mar 19, 2018 Mar 19, 2018

f guys,

I'm adding text to the multiple artboards so want to change its positions inside artboard. But when I write negative value to "top" parameter, "Numeric value expected" error happens. Don't know why but after I skip error each time, text was moved to the right position but i stays behind the layer. Fun fact is icon.top working properly in my code, without error. Please help to move text top,left inside the artboard.

Any help appreciated !

                var layerText = myDocument.layers.add();

                layerText.name = "text";

                var text1 = layerText.textFrames.pointText([10,10]);

                text1.contents = son;

                text1.top = 50;

                text1.left = 50;

                var fontStyle = text1.textRange.characterAttributes;

                fontStyle.fillColor = makeColor(255,255,255);

                fontStyle.size = 31;

TOPICS
Scripting
1.7K
Translate
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
Valorous Hero ,
Mar 19, 2018 Mar 19, 2018

My test appears to work okay:

#target illustrator

function test(){

    var myDocument = app.activeDocument;

    var layerText = myDocument.layers.add(); 

    layerText.name = "text"; 

    var text1 = layerText.textFrames.pointText([10,10]); 

    text1.contents = "son"; 

    text1.top = -50; 

    text1.left = 50; 

    var fontStyle = text1.textRange.characterAttributes; 

    fontStyle.size = 31;

};

test();

Are you sure it's not because you're passing in a variable which you think is a number, but is actually a string? Such is the case when data is passed in from prompts or ScriptUI dialogs, and it's up to you to turn them into a number with some mathematics such as the (*= 1) operation. Or you may have this variable going through some function where it becomes a NaN?

Translate
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 ,
Mar 19, 2018 Mar 19, 2018

Above code is a part from my real code.

I've tried so many ways, but left can get negative value, but top can't.

Translate
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
Valorous Hero ,
Mar 19, 2018 Mar 19, 2018

Well, try my code and see if it does the thing.

Translate
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 ,
Mar 19, 2018 Mar 19, 2018

I tried just your script, it worked. But when I add your function to my script and run, same error happens.

Translate
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
Valorous Hero ,
Mar 19, 2018 Mar 19, 2018

I suppose we'd need to see more of your code then.

As you can tell, my function is modified from yours because in order to make it work, some variables had to be instantiated prior to the snippet - and I also encased ​son​ in quotes ("son");

Translate
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 ,
Mar 20, 2018 Mar 20, 2018

I'm just thinking can I try this method :

Outline (expand) text, and move its position like a path.

Is it possible or if it'll work ? What do you think ?

Note: I've script to outline it.

Translate
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
Valorous Hero ,
Mar 21, 2018 Mar 21, 2018
LATEST

I think there may be some simple bug in your code and we need to figure it out. There may be a time for drastic measures, but this does not look like one of them to me...

Translate
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
Advocate ,
Mar 20, 2018 Mar 20, 2018

bonjour,

avec ?

var text1 = layerText.textFrames.add();

      text1.contents = son ;

      text1.top = -50;

      text1.left = 50;

Translate
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 ,
Mar 20, 2018 Mar 20, 2018

same error happens, when I write it into my code. But searched and never found something that can create error.

Translate
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