calling actions from a script and vice versa (CS)

Ask a Question related to Adobe Illustrator Macintosh, Design and Development.

  1. #1

    Default calling actions from a script and vice versa (CS)

    Hey

    I just realized that I can automate a lot of my workflow in illustrator with applescript (I never realized it was scriptable) and I'm running into a couple of problems.

    I have a text object in illustrator with a note "filename" that I can use an action to select ("select object with note" feature), and a script which changes the text of that object to "Filename: myfile.ai"

    originally, I had an action select the object and then call the scripts menuitem, but when I quit illustrator and relaunch, I lose the script calling step in my action. that's fine, right? why don't I just call the action from the script with the "do script "Filenamer" from "Automation"" command?

    Well, it works fine when I call it by itself, from the applescript application, but when I select the item from the scripts menu, the action never gets called and the script never completes.

    And is there any way I can give a script a keyboard shortcut? Whenever I quit illustrator, it resets my keyboard shortcuts for my scripts. blargh.

    any ideas?

    here's the script:



    tell application "Illustrator CS"
    set boldFont to text font "Arial-BoldMT"
    set regFont to text font "ArialMT"

    do script "Filenamer" from "Automation"
    --do script "Filenamer" as Unicode text from "Automation" as Unicode text

    if the class of item 1 of selection is text frame then
    set t to item 1 of the selection

    set the contents of t to ("Filename: " & name of front document)
    set the properties of (every word of t) to {text font:regFont}
    set the properties of (the first word of t) to {text font:boldFont}
    end if
    end tell



    Thanks in advance.
    spike_grobstein@adobeforums.com Guest

  2. Similar Questions and Discussions

    1. Howto display an ASP.net datagrid rows as columns and vice versa?
      Hi I want to display my datagrid with the columns horizontal and rows vertical, so just the other way around. For example instead of : name ...
    2. Converting data from DataGrid to Java and vice versa
      Hi all! Here is what I try to do (some pseudo-code): I have some POJO in Java, lets say Person - pls see the attached code. Now, I also have...
    3. Problem with configurating Apache for CF and vice versa
      Hello, until now I was working with a static web site, using Dreamweaver MX on Apache 2.0.52. Now I was told to change it to be a dynamic one and...
    4. Director to Flash converter and vice versa?
      Longshot but does anything exist to help (automatically) convert director to flash projects or vice versa (or even just convert Lingo to...
    5. Possible to read Textfile if other App accesses the same file + vice versa?
      Hi, I got two applications: Director and lets say 'xApp'. xApp writes a status (just a number) into a textfile every second. Director reads...
  3. #2

    Default Re: calling actions from a script and vice versa (CS)

    Spike,
    You have just mentioned 2 of the more annoying things that I have found in scripting Illustrator-
    1- You can't call an action from within a script, and have said script reside in your FILE, SCRIPTS menu.
    2- Illustrator does not save the keyboard shortcuts for scripts.

    You might want to try iKey, this is a application that allows you to program keboard shortcuts, I use it for just the reason that you need to and it works great. If you do a google search it should pop up, I think it is shareware.

    -Jason
    Jason_Howard@adobeforums.com Guest

  4. #3

    Default Re: calling actions from a script and vice versa (CS)

    do you have any experience with Unsanity's MenuMaster? Do you know if that would work?



    Has adobe admitted to there being a problem with calling actions from scripts when the script is being called from the File::Scripts menu?

    Have you figured out a workaround for calling actions when executing a script from the menu? Or, at least, do you know a way of selecting items with a note (a la the Attributes palette)?

    Unfortunately, my scripts rely heavily on some actions that I recorded. The only workaround I can think of would be to have my script call a separate external script to tell illustrator to execute an action.

    Adobe needs an illustrator scripting forum. =) <http://www.unsanity.com/haxies/menumaster>
    spike_grobstein@adobeforums.com Guest

  5. #4

    Default Re: calling actions from a script and vice versa (CS)

    I think Drop Draws will work as well and perhaps Launch Bar.
    Wade_Zimmerman@adobeforums.com Guest

  6. #5

    Default Re: calling actions from a script and vice versa (CS)

    Well, I'm trying to stay away from running too much extra stuff. Having extra launch bars and drawers and utilities installed kinda makes me distrust my system (hurt feelings still left over from the OS9 extension conflicts and such).

    I installed scriptmenu (in the applescript folder) and tried to set up a keyboard shortcut in the keyboard controlpanel, but that didn't like me...

    So, since I like unsanity, I'm using Menumaster and calling my script in the from the system-wide scriptmenu. It's a little slow to execute (kinda jumps to the finder first), but it's working pretty well. Now I just gotta pay 10$ to register this thing.

    Thanks for the help. At least I know it's a real issue and not something I was doing wrong.
    spike_grobstein@adobeforums.com Guest

  7. #6

    Default Re: calling actions from a script and vice versa (CS)

    Spike-
    Nope, I am not familiar with MenuMaster. iKey works great for me, I program my script to an F key, the script runs from outside Illustrator and calls the necessary action just fine. There is no noticable slowdown in using it, although the script tells Illustrator to 'activate' so it remains the frontmost application.

    The Illustrator CS scripting guide from Adobe, page 61 says-
    "It is not possible to execute scripts that contain the do script command from the Scripts menu. Attempting to do so will result in an error."

    From a script you can identify and select an object with a note by using something like-
    set VariableX to the first path item of document 1 whose note is "variable"
    set selection to VariableX

    Agreed about the Illustrator specific scripting forum.

    -Jason
    Jason_Howard@adobeforums.com Guest

  8. #7

    Default Re: calling actions from a script and vice versa (CS)

    In that case, I'll check out iKey. =)

    Ahh, I actually just perused the CS scripting documentation, since I had ordered a book on scripting illustrator a couple days before. Even though the book was on scripting for 10, I figured I could figure out how to do the examples in CS, which I have been. But, the book says that a script can call an action, but an action can't call a script. The book doesn't have any examples of calling an action from a script, so I looked it up in the dictionary. Blargh.

    I wonder why adobe doesn't have that functionality available... recursive action calling from a script would be very handy. Especially for some things that I need to do.

    The example you showed me isn't working for me. It's selecting what I want, but throwing an error:

    Illustrator CS got an error: Can't get every text path of document 1 whose note = "filename".



    set filenameItem to (first text frame whose note is "filename")
    set selection to filenameItem



    =(

    Yeah, there doesn't seem to be any online forums or even resources for illustrator scripts. I found a couple japanese sites, but I have no idea what they're talking about. ;)
    spike_grobstein@adobeforums.com Guest

  9. #8

    Default Re: calling actions from a script and vice versa (CS)

    I agree with you guys if there was a scripting forum for Illustrator I think more of us would jump into the mix.
    Wade_Zimmerman@adobeforums.com Guest

  10. #9

    Default Re: calling actions from a script and vice versa (CS)

    Spike,
    Just to be clear, you can call an action from a script, you just can not then have that script reside within the FILE, SCRIPTS menu within Illustrator. If you run the script from the menu bar scripts folder or set a key to run it (using iKey, or something similar) it should work just fine.

    Hmmm, your right, that doesn't work when trying to identify a text frame (vrs a path item). I'll mess around with this later, if I figure out someting I'll post it.

    -jason
    Jason_Howard@adobeforums.com Guest

  11. #10

    Default Re: calling actions from a script and vice versa (CS)

    I can actually live without that functionality since I can just say

    set the name of someObject to "someName"

    and when I save the file, it remembers that. I just need to be able to select certain objects to update variable content (ie- swatches in use, filenames, modification date, etc).

    Thanks for all the help. =)
    spike_grobstein@adobeforums.com Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139