Replace swatches and text?

Is it possible (with javascript code) to do the following?
1.  Prompt user to select a color from a predetermined set of colors (hard coded in the script) via a dropdown list
2.   Take the value that the user selects, and replace the color of all  items that use the swatch called "Primary" with the user selected color  (which is already a swatch name in the document)
3.  Find and  replace all text in the document from "Primary" to the text that the  user had previously selected from the drop down (it was also a swatch  name).
4.  Prompt the user to select another color (secondary  color) from a predetermined set of colors (hard coded in the script) via  a dropdown list
5.  Again, take the value that the user selects  here and replace the color of all items that use the swatch called  "Secondary" to the user selected swatch name.
6.  Find and replace  all text in the document from "Secondary" to the text  that the user  had previously selected from the drop down (it was also a  swatch name).
7.  Remove all unused swatches.
Steps 1 & 4 could be combined, if Javascript allows...but I don't know if it does or not.
Let me know if you think this is possible please.
Thanks!

In my made-up test document this worked but Im not sure what mileage you will get… Worth a test anyhows…
#target illustrator
// Global Variables
var aSel,bSel
// Main Window Dialog
function csDialog() {
     var fabGroup = app.activeDocument.swatchGroups.getByName('Fabrics');
     var allFabs = fabGroup.getAllSwatches();
     var fabNames = Array();
     for (var i = 0; i < allFabs.length; i++) {
          fabNames.push(allFabs[i].name);
          if (i < allFabs.length-1) fabNames.push('-');
     var csdlg = new Window('dialog', 'Tim\'s Fabric Picker…',[0,0,300,205]);
     // Panel 1
     csdlg.Pnl = csdlg.add('panel', [15,15,285,72], 'Pick your "Primary" fabric swap:');
     csdlg.Pnl.cs1 = csdlg.Pnl.add('dropdownlist', [15,20,255,37], fabNames);
     // Panel 2
     csdlg.Pn2 = csdlg.add('panel', [15,92,285,149], 'Pick your "Secondary" fabric swap:');
     csdlg.Pn2.cs3 = csdlg.Pn2.add('dropdownlist', [15,20,255,37], fabNames);
     // Standard Buttons     
     csdlg.cancelBtn = csdlg.add('button', [15,164,125,186], 'Cancel', {name:'cancel'});
     csdlg.okBtn = csdlg.add('button', [175,164,285,186], 'OK', {name:'ok'});
     // Panel 1 call backs
     csdlg.Pnl.cs1.onChange = function() {
          aSel = csdlg.Pnl.cs1.items[parseInt(this.selection)];
     // Panel 2 call back
     csdlg.Pn2.cs3.onChange = function() {
          bSel = csdlg.Pn2.cs3.items[parseInt(this.selection)];
     // Button call back
     csdlg.okBtn.onClick = function() {
          csdlg.close(1);
          colourSwapper(aSel,bSel); // Here call the process
     csdlg.center();
     csdlg.show();
// Main active document commands go here
function colourSwapper(a,b) {
     var uIL = app.userInteractionLevel;
     app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
     var docRef = app.activeDocument;
     recurseLayers(docRef.layers);
     alert('Now run Action:\r"Delete Unused Panel Items"');
     app.userInteractionLevel = uIL;
// Main active document check function
function activeDoc() {
     if (app.documents.length == 0) {
          alert('NO document open?');
          return;
     } else {
          csDialog();
activeDoc();
function recurseLayers(objArray) {
     for (var i = 0; i < objArray.length; i++) {
          var l = objArray[i].locked;
          if (l) objArray[i].locked = false;
          var v = objArray[i].visible;
          if (!v) objArray[i].visible = true;
          changeText(objArray[i].textFrames);
          changeColours(objArray[i].pathItems);
          if (objArray[i].layers.length > 0) {
               recurseLayers(objArray[i].layers)
          if (objArray[i].groupItems.length > 0) {
               recurseGroups(objArray[i].groupItems)
          if (objArray[i].compoundPathItems.length > 0) {
               loopCompounds(objArray[i].compoundPathItems)
          objArray[i].locked = l;
          objArray[i].visible = v;
function recurseGroups(objArray) {
     for (var i = 0; i < objArray.length; i++) {
          var l = objArray[i].locked;
          if (l) objArray[i].locked = false;
          var h = objArray[i].hidden;
          if (h) objArray[i].hidden = false;
          changeText(objArray[i].textFrames);
          changeColours(objArray[i].pathItems);
          if (objArray[i].groupItems.length > 0) {
               recurseGroups(objArray[i].groupItems)
          if (objArray[i].compoundPathItems.length > 0) {
               loopCompounds(objArray[i].compoundPathItems)
          objArray[i].locked = l;
          objArray[i].hidden = h;
function loopCompounds(objArray) {
     for (var i = 0; i < objArray.length; i++) {
          var l = objArray[i].locked;
          if (l) objArray[i].locked = false;
          var h = objArray[i].hidden;
          if (h) objArray[i].hidden = false;
          changeColours(objArray[i].pathItems);     
          objArray[i].locked = l;
          objArray[i].hidden = h;
function changeColours(objArray) {
     for (var i = objArray.length-1; i >= 0; i--) {
          var l = objArray[i].locked;
          if (l) objArray[i].locked = false;
          var h = objArray[i].hidden;
          if (h) objArray[i].hidden = false;
          if (objArray[i].fillColor instanceof SpotColor) {
               if (objArray[i].fillColor.spot.name == 'Primary') {
                    objArray[i].fillColor = app.activeDocument.swatches.getByName(aSel).color;
               if (objArray[i].fillColor.spot.name == 'Secondary') {
                    objArray[i].fillColor = app.activeDocument.swatches.getByName(bSel).color;
          objArray[i].locked = l;
          objArray[i].hidden = h;
function changeText(objArray) {
     for (var i = objArray.length-1; i >= 0; i--) {
          var l = objArray[i].locked;
          if (l) objArray[i].locked = false;
          var h = objArray[i].hidden;
          if (h) objArray[i].hidden = false;
          if (/Primary/.test(objArray[i].contents)) {
               objArray[i].contents = objArray[i].contents.replace('Primary', aSel)
          if (/Secondary/.test(objArray[i].contents)) {
               objArray[i].contents = objArray[i].contents.replace('Secondary', bSel)
          objArray[i].locked = l;
          objArray[i].hidden = h;
I left quite a bit of stuff that deals with hidden and locked items… If you don't require this it can be easily stripped out…

Similar Messages

  • Messages: replacing &V1& and &V2& in long text

    Hello,
    I have defined a message with short and long text.
    In the short text, I use &1 and &2, in the long text I use &V1& and &V2& as described in the ABAP help.
    I call the message like this:
    MESSAGE w050(zmessclass) WITH i_mess1 i_mess2
    I get replaced &1 and &2 in the short text but no replacement of &V1& and &V2&. How is it working in long text?
    Thanks
    Stephan.

    Hi,
    Instead of typing the &V1& and &V2& directly into the long text editor yourself, choose the "Insert Command" function (Ctrl-F9) instead.  In the popup for this function you will see several types of commands.  Within the "Symbols" section type in &V1& and press enter.  Repeat this for &V2&. 
    You will now see that &V1& and &V2& are highlighted (gray).  Activate your text and try again.  Your long text should now show the variables in place of &V1& and &V2&.
    Regards,
    Jamie

  • Got a replacement phone and its not letting me send text or make phone calls

    I just received a replacement phone and had to restore my phones info and contacts.  My new phone won't send or receive text messages or phone calls.

    Hi dreyes492,
    Since you're having an issue with both texts and phone calls, I would recommend going through this iPhone troubleshooting assistant:
    Calls and connection issues
    http://www.apple.com/support/iphone/assistant/calls/
    Take care,
    - Ari

  • Key and text replaced with "???" in variable selection after SPS Upgrade

    Hello community
    I have a problem regarding the variable screen.
    We recently upgraded to SAPKW70021 and SP19 in Java. After this a problem appeared in web reporting and variable selection. When users are prompted to enter a value for fiscal year for example, the input help displays "???" instead of years. When you choose an "???" randomly from the list and add to your selection, the year is displayed correctly.  The same issue is present with company code selection and other user input variables as well, the selection list is filled with "???" for both key and text.
    Does anyone have any suggestions on how to fix this problem?
    best regards
    Antti Lyytikäinen

    Hi,
    Note 1368055 describes this issue. You need to implement the mentioned java patch for the BI components and set the parameter mentioned in the note to solve this issue.
    Best regards,
    Janine

  • How can I change the space between a checkbox and text all at one time? I have a lot of checkboxes in my form.

    How can I change the space between a checkbox and text all at one time? I have a lot of checkboxes in my form.

    Okay, I haven't found a way to add an extra space using Find/replace, but you might be able to add some text wrap to the check boxes that will push the text away from them.
    Open Find/Replace and click the Object tab.
    Click the Specify attributes to find button to the right of the Find Object Format: field.
    Under Basic Attributes, choose Stroke and then the Black swatch (assuming the black swatch is applied to the strokes of your check boxes). If there are no other stand-alone objects in your form with a Black stroke, this should be all you need. (If there are Black strokes on your table cells, they will be ignored.)
    Click OK
    Click the Specify attributes to change button to the right of the Change Object Format: field.
    Under Basic Attributes, choose Text Wrap & Other > Text Wrap > Type: > Wrap around bounding box (2nd button from left)
    Under Offset, set a Right offset at the distance you'd like to add (I don't know what units you use, but the 3-5 points might work for your purposes...might take some trial-and-error to get it where you want)
    Click OK
    Click Change All

  • Having horrible service with 4GLTE I have had 3G for several weeks (I am not the only person I know having this problem), I have reset my network settings and it did not resolve the issue.  I am also unable to send SMS and text messages without them eithe

    Having horrible service with 4GLTE I have had 3G for several weeks (I am not the only person I know having this problem), I have reset my network settings and it did not resolve the issue.  I am also unable to send SMS and text messages without them either failing or not sending at all.  Is there an outage in the Cleveland, Ohio area (zip codes 44129, 44134, 44137) or anything else I can do to resolve this issue?

    Not that I'm a Verizon employee, but I have experience in the field. An LTE tower will only extend up to, on a perfect day, with no elevation, 6-7 miles. On a typical day, you will be lucky at four (4) miles. The three ZIP codes you've given are all within about a 12 mile radius. That would mean that 2-3 towers are currently down at the same time, and Verizon would know about it within the hour. Being it's Cleveland, I'm sure they would receive numerous calls regarding an outage of that size.
    My point is that if you're having issues in all three ZIP codes, chances are it's a phone issue. If you're handset is simply not receiving LTE, but still receiving 3G, that would signify a SIM card issue. You need to get your SIM card replaced.

  • Replacement path with text variable

    Hi experts,
    My client requirement is " when he enters the current year or current day then it should display the Description of that particular year r month r day."
    Can anyone explain me in detail how to create replacement path with text variable on FISCAL YEAR?
    Hope will solve my issue soon.
    Thanks in advance
    Jani Sk.

    Hi,
       goto the properties of your KF and click on the variable button side to that of the description field and click on new/Create option.Enter the technical name description for the text variable and select Replacement path as the Processing type and in the nxt screen select Fiscal year as the replacement variable and in nxt screen  specify as Key and provide offset values if necessary and click on finish.now select the variable by clickin on the variable button next to the description field.it comes after the description of the KF.Now run the query.
    Thanks,
    Sandeep

  • A very good friend of mine dropped her iphone into water and now it is not working.Her husband recently passed away and text messages from him and from well wishers after his decease are feared lost. Is there any way to retrieve them?

    A very good friend of mine dropped her iphone into water and now it is not working.Her husband recently passed away and text messages from him and from well wishers after his decease are feared lost. Is there any way to retrieve them?
    I suggested contacting Compub in Nassau St as the info is priceless and worth the trouble of trying to regain?
    Any thoughts? The poor lady is very distress

    If she has backed up her iPhone she can replace that iPhone and set up the new iPhone from her backup.
    You can put the iPhone that went into water into a plastic baggie with either new silica gel packets (preferred) or raw rice and let it sit for  4 - 5 days. After that time remove the phone and connect it to power for at least a half hour. While it is still connected to power reset it by holding down the power and hold button, wait for the Apple logo then let go of the buttons. Might take several tries. If it revives immediately back it up.

  • Messages has replaced all my text with a load of letter A's in boxes. What is that all about. When I type a new one it is fine until I hit enter then the same thing applies. Has anyone a fix for this?

    Messages has replaced all my text with a load of letter A's in boxes. What is that all about. When I type a new one it is fine until I hit enter then the same thing applies. Has anyone a fix for this?
    Picture below, many thanks for your help.
    Jason

    Back up all data before proceeding.
    Launch the Font Book application and validate all fonts. You must select the fonts in order to validate them. See the built-in help and this support article for instructions. If Font Book finds any issues, resolve them.
    Start up in safe mode to rebuild the font caches. Restart as usual and test.
    Note: If FileVault is enabled in OS X 10.9 or earlier, or if a firmware password is set, or if the startup volume is a software RAID, you can’t start in safe mode. In that case, ask for instructions.
    If you still have problems, then from the Font Book menu bar, select
              File ▹ Restore Standard Fonts...
    You'll be prompted to confirm, and then to enter your administrator login password.
    Also note that if you deactivate or remove any built-in fonts, for instance by using a third-party font manager, the system may become unstable.

  • JDOM and text embedded tags

    Hi all!
    I've just been using JDOM for some XML parsing right now and it works really fine. But I have one problem I can't find a solution (but I think it should be possible and quite simple).
    Given the following XML for example:
    <document>
      <item>
        Some text here
        <item> Hugh? </item>
        Some other text here...
      </item>
    </document>Now item.getText() returns me "Some text here Some other text here..." and item.getChild("item") returns me the embedded item. So far so good.
    But I need to translate this XML document to another format automatically. Therefore I need to replace the XML items with some other text - here is the problem that I need to get the text before the embedded tag then the tag itself and replace it and then the text afterwards. But getText() returns the entire text at once.
    Since (X)HTML can do this with a <div> inside a <p> there must be a way - but I can't find it (or maybe im totally blind).
    Thanks for any hints!
    Jan

    Hi
    Trying to get a picture of it.
    • Free Space on Your Start-Up (Mac OS) Hard Disk. How Much ?
    • Any other hard disks connected ?
    • If so - Formatted as ?
    Yours Bengt W

  • How to get Key and text for plant for which variable is created

    Hi All
    I have created one variable for Plant. User is going to give input for the plant for  execution of query.I am displaying the variable value which is user putting in the query. kindly let me know how to display key and text both for the query.as key is displaying presently.
    Regards
    Atul

    hi Atul kumar jais
    You have to create a text variable using replacement path for processing type and give the reference object which is the object which you created variable for, "replace with" one with key and anther one with text. Then you can display that in the header of the column or if you are using custom template, you can use webitem for it.
    thanks.
    Wond

  • Only safari and text edit work

    2 days ago my mac power cable was pulled out of the wall. When I turned the Mac Mini back on only programs such as Safari, Dashboard, and text edit worked. I can go to system preferences but that is all. All of my desktop icons have been deleted. itunes, iDVD, iCal, and others such as america online, and AIM do not work. When I shut the computer down and restart it a screen with a blinking folder with a question mark alternating with the mac logo appears and then starts up as normally. I do not have the CDs that came with the computer, is there anything i can do?

    nbakidd5...
    "I do not have the CDs that came with the computer, is there anything i can do?"
    It is possible to call Apple and pay them their fee to have them to send you some replacements.
    Forunately Apple isn't exactly like Microsoft requiring you to pay for a new retail version of their software.
    ...Ron

  • Problem in displaying dates for replacement path with text variable

    Hi all,
    I have to display dates in sequence as descriptions for 15 columns based on the the date entered by the user in Bex Report.I managed to display date as description using text variable with replacement path for single column.I could not able to increment date for other descriptions.Could you please help me to solve this issue.Its urgent.
    Ex: User enters 03/09/2007 then in the out put desciptions for the columns should be  03/09   04/09  05/09 ............ 17/09.
    Thanks in advance.
    Regards,
    Mandadi.

    Hi,
       goto the properties of your KF and click on the variable button side to that of the description field and click on new/Create option.Enter the technical name description for the text variable and select Replacement path as the Processing type and in the nxt screen select Fiscal year as the replacement variable and in nxt screen  specify as Key and provide offset values if necessary and click on finish.now select the variable by clickin on the variable button next to the description field.it comes after the description of the KF.Now run the query.
    Thanks,
    Sandeep

  • Using currency conversion and text variable at the same time

    Hi all,
    In a 3.5 bex query, i am applying currency conversion on a key figure with a variable of 0currency.
    as i know, to be able to apply currency conversion, variable of currency should not be in Free characteristics or in Filter.
    it has to be selected only on the key figure.
    but now, i want to use text variable for selected currency (with type replacement path). But as i know, to be able to use text variable, variable of currency has to be
    in Free characteristics or in Filter.
    Can you please advise, how to both use currency conversion and text variable on currency?
    Thanks in advance.
    Sancho

    Sancho,
    I'm not 100% sure about this, but I'm thinking that if you are pulling the text variable from a selection in a structure, you should not need it in the free characteristic or filter. Try creating a structure, placing the currency in it as a selection, and creating a text variable as the title for the selection that is based on the currency. This may help.
    Cheers,
    Rusty

  • Replacement path witth text

    hi,
    Here this is balaji.I have a need to work on reporting and reporting with replacement path with text.Anybody please explain me in details wt it does actually , how to use it and how to create it. If u found and have any documents regarding the same please sendit to my mail [email protected] it is an urgent requirement please respond with helpful answer ASAP.
    NOTE:Helpful answers ll be credited with points.
    regards
    balaji

    Hi,
    An application of Replacement path variable can be found here.
    http://www.sd-solutions.com/documents/SDS_BW_Replacement%20Path%20Variables.html
    Another application to get the Document Count: For example Number of Sales Orders.
    Query formula-Counter???
    Example for Replacement Path: Characteristic Variable.
    http://help.sap.com/saphelp_nw04/helpdata/en/2c/78a03c1178ad2ce10000000a114084/content.htm
    Variable Replacement Example
    http://help.sap.com/saphelp_nw04/helpdata/en/af/809528939d5b4fbff7e16a5bdc0d85/content.htm
    Example for Replacement Path: Formula Variable.
    http://help.sap.com/saphelp_nw04/helpdata/en/ca/5f9ac61a205a459d0e7ef313d10321/content.htm
    Hope this helps...Let me know
    Regards
    San!

Maybe you are looking for

  • Problems while deploying ear file

    Hi all, When I am trying to deploy the webdynpro application after packaging it as an ea file it is giving the following exception: <b>Deployment exception : Server los-angeles did not accept login request as admin on port 58818. Details: ERROR: Coul

  • Sockets & inetd

    Hello! It all worked just fine before I used inetd to start the server. When I use inetd I get this exception: Network error: Address already in useSo, the inetd-stuff works, because the server is started, but... This is my code: Client: public class

  • Issue while passing more than one promt value to bi publisher in 11.1.1.6

    Hi all , i have created a dashboard prompt with two columns . i want them to pass to bi publisher report to filter out the result. but for some reason it's not applying both filters. It just refreshes the page with default value. any idea how to reso

  • GVim color scheme - darkfix

    This is my custom gVim theme, based somewhat off of molokai. Optimized for PHP, HTML, CSS (still working on PHP, and Javascript). Download darkfix.vim http://theywillknow.us/uploads/darkfix-preview.png Last edited by ctruett (2010-10-11 17:59:40)

  • For my power shot S5IS, best camera settings for 4 X 6 prints?

    for my power shot S5IS, best camera settings for 4 X 6 prints? I would like to have the best setting so when i print out the photos,i do not need to crop or trim. It is close, but i feel it can be better.