Copy link to clipboard
Copied
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;
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Well, try my code and see if it does the thing.
Copy link to clipboard
Copied
I tried just your script, it worked. But when I add your function to my script and run, same error happens.
Copy link to clipboard
Copied
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");
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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...
Copy link to clipboard
Copied
bonjour,
avec ?
var text1 = layerText.textFrames.add();
text1.contents = son ;
text1.top = -50;
text1.left = 50;
Copy link to clipboard
Copied
same error happens, when I write it into my code. But searched and never found something that can create error.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now