-
1. Re: how do i place a textframe central to the artboard
Muppet Mark Apr 16, 2012 2:19 AM (in response to tonyxamax)For your artboards which one do you intend to place the text on first, last all?
As for your text… It is by default point text therefore you could position the point and centre align the contents ( thats what I would do )
There are several scripts already knocking about that add such fluff like name & path to a file…
-
2. Re: how do i place a textframe central to the artboard
tonyxamax Apr 16, 2012 2:49 AM (in response to Muppet Mark)I'ts always on the first artboard.
Centre align the contents is the "magic button" im searching for!
My background is Illustrator, not scripting, and I have used other scripts and find them fantastic but i really wanted to have a go myself,
this script is my "baby steps" script.
I know once i get my head round all the syntax that scripting will make my life so much easier but its very tempting to give in when you try to do something so simple and you just simply dont know the correct syntax.
-
3. Re: how do i place a textframe central to the artboard
Muppet Mark Apr 16, 2012 3:29 AM (in response to tonyxamax)1 person found this helpfulThis should help you along…
#target illustrator app.coordinateSystem = CoordinateSystem.ARTBOARDCOORDINATESYSTEM; var doc = app.activeDocument; doc.artboards.setActiveArtboardIndex( 0 ); var abRect = doc.artboards[0].artboardRect; var txt = doc.textFrames.add(); txt.position = [ abRect[2]/2, abRect[3]/2 ]; txt.textRange.paragraphAttributes.justification = Justification.CENTER; txt.contents = 'Some strings…';
-
4. Re: how do i place a textframe central to the artboard
tonyxamax Apr 16, 2012 4:23 AM (in response to Muppet Mark)Works perfectly Mark !
Thank you
I didnt explain fully what i wanted so i have tweaked it a little ( sound like a pro ! but i am SO not !)
I am still struggling with the numbers in the [ ] parenthesis but I will get there,
Slow drips wear away stones.
I was a little reluctant to post here asking for help in case i either sounded like a noddy or offended someone by mistake or bad grammar!
You have been very helpful thank you
-
5. Re: how do i place a textframe central to the artboard
Muppet Mark Apr 16, 2012 6:01 AM (in response to tonyxamax)1 person found this helpfulOnly the people who demand a script or solution ( like it's there right ) are frowned upon… Those wanting help almost never… You will find in all the scripting forums here people are willing to help those who want to learn… ( the teach a man to fish approach ). Im muppet cos thats what I was when I was a noob asking here… still am…
The numbers in the square brackets indicate an item of an array ( list ) the rectangular bounds of an artboard are a 4 item Array [ '0', '0', '200', '100' ] javascript is zero based so first item is [0] and so on…
-
6. Re: how do i place a textframe central to the artboard
tonyxamax Apr 26, 2012 8:47 AM (in response to Muppet Mark)I am in the middle of reading the relevant documentation honest!!, but it is a slow process ( or maybe I am a slow process!!).
It is almost like giving a man a Spanish dictionary and expecting him to be able to write a piece of classic literature in perfect Spanish.
So in the eternal hope of a quick fix could you guide me in the intricacies of how to display a filename with out all the "%20" gubbings? ( "gubbings" = A yorkshire word that roughly translates into "stuff i don't understand"
This is not essential but i just dont like the way it looks.
I am currently fumbling blindly with .name and .fullName
I have seen some scripts on here that run a filter through the string looking for the odd characters and replacing them with spaces i wanted to ask the question, "am I missing the obvious?"
Can i return the filename without the URL formatting?
// CODE BEGIN
var docRef = app.activeDocument
var pointTextRef = docRef.textFrames.add();
pointTextRef.contents = docRef.name + ' ' + docRef.fullName;
pointTextRef.top = 635;
pointTextRef.left = 20;
// CODE END
.name returns my document name with normal spacing, but .fullName returns the document name and file location in a URL format. Is this purely the nature of the beast? or is it because the file is stored on a network drive?
Thanks
-
7. Re: how do i place a textframe central to the artboard
Larry G. Schneider Apr 26, 2012 9:21 AM (in response to tonyxamax)1 person found this helpful.fullName is the entire file path to the file. It will return the same form with a few less parts if it is located on your local hard drive. Try making a file and saving it to your desktop and then run your script. If you only want the name of the file and not the path to the file then just use .name.
The "%20" is just computerese for a space character.
-
8. Re: how do i place a textframe central to the artboard
Muppet Mark Apr 26, 2012 9:31 AM (in response to Larry G. Schneider)1 person found this helpfuldecodeURI( docRef.fullName );
-
9. Re: how do i place a textframe central to the artboard
tonyxamax Apr 26, 2012 12:09 PM (in response to Muppet Mark)oh never!!! was it so simple???
how will i ever get my head round this scripting lark?
thank you for the help but please tell me , where did you find this nugget of information? am I looking in the wrong place?
-
10. Re: how do i place a textframe central to the artboard
Muppet Mark Apr 26, 2012 12:48 PM (in response to tonyxamax)That would depend on where you looked? What resources are you using to help you?
-
11. Re: how do i place a textframe central to the artboard
tonyxamax Apr 26, 2012 1:51 PM (in response to Muppet Mark)Object Model Viewer in ESTK
slowly (very slowly) working my way through these ...