color fusion scripts

I need to change the RGB values (imported from the word) of specific CMYK values in Indesign (this isn't a straight swop) so I need a script or a similar plug-in that allows me the contribution of color to CMYK values, so they change automatically... the doc I work on is huge and im importing from a file word several times so I need to save time!

Can someone help me?

Thank you!

Hi baby.

Please try the JS code below.

var myIDOc = app.activeDocument;
var mySwatch = myIDOc.swatches;
for (j=mySwatch.length-1; j>=0; j--){
    try{
         if(mySwatch[j].space ==ColorSpace.RGB){
             if(mySwatch[j].name=="Word_R122_G75_B153"){
                mySwatch[j].remove("C=48 M=72 Y=0 K=0");
                }
            else if(mySwatch[j].name=="Word_R255_G0_B255"){
                mySwatch[j].remove("C=0 M=100 Y=0 K=0");
                }
            else if(mySwatch[j].name=="Word_R0_G0_B255"){
                mySwatch[j].remove("C=100 M=0 Y=0 K=0");
                }
            else if(mySwatch[j].name=="Word_R0_G0_B0"){
                mySwatch[j].remove("Black");
                }
            else if(mySwatch[j].name=="Word_R234_G229_B255"){
                mySwatch[j].remove("C=8 M=10 Y=0 K=0");
                }
             }
         }catch(e){}
     }

THX,

csm_phil

Tags: InDesign

Similar Questions

  • Chaning color Illustrator script?

    Hello community! I have about 600 files that I need to change the colors of pale green/dark green to light blue/dark blue, and I need a script for this. Here are a few simple letters divided in two and everything I need is the upper part to be dark blue instead of dark green and the lower part to be light blue instead of the original light green. Is this possible? I use windows 10 as my operating system. Any help is very appreciated!

    Kind regards

    David.

    This code should you select a folder and then loop through all files with. EPS file extensions.
    Note that this script assumes that all colors are exactly the same two Greens as in this sample file you sent.

    You will need to replace the RGB values of the above colors in the marking lines.<- here"="" with="" the="" values="" for="" the="" new="" blue="">

    function ConvertColors() {
    
        /* REPLACE THESE RGB VALUES */
        var topColor = new RGBColor();
    
        topColor.red = 0;    // <- HERE
        topColor.green = 0;    // <- HERE
        topColor.blue = 255;   // <-HERE
    
        var bottomColor = new RGBColor();
    
        bottomColor.red = 255;   // <- HERE
        bottomColor.green = 0;   // <- HERE
        bottomColor.blue = 0;  // <- HERE
    
        /* ~~~~~~~~~~~~~~~~~~~ */
    
        // we'll just use the Red value of the top to identify which color we have
        var oldTopColor = 140;
    
        var dir = Folder.selectDialog("Where?");
        var files = dir.getFiles("*.eps");
    
        // loop through all the files in the selected directory
        for(var f = 0; f < files.length; f++){
            var doc = app.open(files[f]);
    
            // loop through all paths and change the colors based on current fill
            var paths = doc.pathItems;
            for( var i = 0, ii = paths.length; i < ii; i++ ) {
                var curPath = paths[i];
    
                // check the fill color to see if it has the same Red value as the old top color
                if( curPath.fillColor.red == oldTopColor ) {
                    curPath.fillColor = topColor;
                }
                // if not it must be the bottom color
                else {
                    curPath.fillColor = bottomColor;
                }
            }
    
            // close and save the changes
            doc.close(SaveOptions.SAVECHANGES);
        }
    }
    
    ConvertColors();
    

    I hope this helps!

  • Color conversion script?

    I am looking for a way to print the CMYK, RGB, HEX easily, in the text, and possibly another representation of certain colors, I thought I'd write a quick script... easy, right? Apparently not.

    Although I have never used, it seems that Photoshop has the 'SolidColor' object, which has properties for 'cmyk', 'rgb', 'gray' etc... exactly what I need, except I want to do that in Illustrator. Illustrator has the "CMYKColor', 'RGBColor" etc. objects with, from what I can tell, no way to convert any other color mode.

    Then. am I missing something obvious? Or y at - it no way to easily get representations of different a color in artificial intelligence object color mode? I know that the conversion will be different according to the profiles of boards etc., but the UI color picker has the right values that already and, apparently, Photoshop can do it without problem so I'm hoping that I'm missing just something obvious!

    I tried to change the "TypeName" of the Color object, I've seen suggested, but it made no difference (the docs say it is read only).

    The only other options I can think is to create a new document in color mode I want to convert, to create a new color from the existing (which from reading the reference sounds like it will be auto-convertir it in this color mode) read the values of the new color and close the newly created document. But that seems to be a horrible workaround. Or, set up my own conversion function, which seems so horrible (since I thought it would be easy to write quick script!)

    Any input would be appreciated!

    Your code has been very useful Silly-V, convertSampleColor(), it was exactly what I was looking for! If you or anyone is interested, now is my script. Havn't tried a lot and it could probably be cleaned up a bit, but it should work (it does for me with CS6 on OS X).

    It takes all your selected samples and print the CMYK, RGB and HEX (and name if it is a spot color) all these samples selected in a txt file. The txt file is saved with the same name and in the same folder as your Illustrator file. If your Illustrator file is unregistered, it records the txt file in your home directory.

    // Color Modes To Text
    // ===================
    
    // Prints CMYK values, RGB values and HEX value of all selected swatches to a .txt file
    // The .txt file is saved with the same file name and inc the same folder as the .ai file
    // If the .ai file hasn't been saved, the .txt file is saved in the users home directory
    
    main();
    function main()
    {
        var doc = app.activeDocument;
        var selectedSwatches = doc.swatches.getSelected();
    
        if (selectedSwatches.length > 0)
        {
            var text = "";
    
            for (var i = 0; i < selectedSwatches.length; i++)
            {
                var swatch = selectedSwatches[i]
                var color = swatch.color;
    
                // Spot
                if (color.typename == "SpotColor") {
                    text += color.spot.name + "\n";
                    color = color.spot.color;
                }
    
                // CMYK Source
                if (color.typename == "CMYKColor")
                {
                    // CMYK Values
                    text += "C=" + Math.round(color.cyan) + " M=" + Math.round(color.magenta) + " Y=" + Math.round(color.yellow) + " K=" + Math.round(color.black) + "\n";
    
                    // RGB Values
                    var rgb = convertColor("CMYK", "RGB", [Math.round(color.cyan), Math.round(color.magenta), Math.round(color.yellow), Math.round(color.black)]);
                    text += "R=" + Math.floor(rgb[0]) + " G=" + Math.floor(rgb[1]) + " B=" + Math.floor(rgb[2]) + "\n";
    
                    // HEX Values
                    text += rgbToHex(Math.floor(rgb[0]), Math.floor(rgb[1]), Math.floor(rgb[2])) + "\n";
                    text += "\n";
                }
                // RGB Source
                else if (color.typename == "RGBColor")
                {
                    // CMYK Values
                    var cmyk = convertColor("RGB", "CMYK", [Math.round(color.red), Math.round(color.green), Math.round(color.blue)]);
                    text += "C=" + Math.round(cmyk[0]) + " M=" + Math.round(cmyk[1]) + " Y=" + Math.round(cmyk[2]) + " K=" + Math.round(cmyk[3]) + "\n";
    
                    // RGB Values
                    text += "R=" + Math.floor(color.red) + " G=" + Math.floor(color.green) + " B=" + Math.floor(color.blue) + "\n";
    
                    // HEX Values
                    text += rgbToHex(Math.floor(color.red), Math.floor(color.green), Math.floor(color.blue)) + "\n";
                    text += "\n";
                }
            }
            saveTxt(text);
        }
        else {
            alert("No Swatches Selected.");
        }
    }
    
    function convertColor(src, dest, clrArr)
    {
        return app.convertSampleColor(ImageColorSpace[src], clrArr, ImageColorSpace[dest], ColorConvertPurpose.defaultpurpose);
    }
    
    function componentToHex(c)
    {
        var hex = c.toString(16);
        return hex.length == 1 ? "0" + hex : hex;
    }
    
    function rgbToHex(r, g, b)
    {
        return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
    }
    
    function saveTxt(txt)
    {
        var name = app.activeDocument.name.replace(/\.[^\.]+$/, '');
        var path = (app.activeDocument.path != "") ? app.activeDocument.path : "~";
    
        var saveFile = new File(path + "/" + name + ".txt");
    
        if(saveFile.exists)
            saveFile.remove();
    
        saveFile.encoding = "UTF8";
        saveFile.open("e", "TEXT");
        saveFile.writeln(txt);
        saveFile.close();
    
        alert("Saved to File:\n" + saveFile.fullName)
    }
    
  • How to remove colors custom Script UI control?

    Dear forum,

    I am writing a script for batch renaming links in InDesign.

    1.jpg

    If the user types the text edit field the new name which coincides with name of the original link (1st static text in the Group), the script gives a warning and he painted red.

    2.jpg

    3.jpg

    When the user solves the problem by making the new different name, the script he painted black.

    15-11-2015 20-30-37.jpg

    Here's where I got so far:

    g.et.onChange = function() {
        if (this.parent.children[0].text.replace(/\.[^\.]+$/, '') == this.text) {
            alert("\"" + this.text + "\" - the new name is the same as the old one! The file won't be renamed.", "Error", true);
            this.graphics.foregroundColor = this.graphics.newPen(this.graphics.PenType.SOLID_COLOR, [1, 0, 0], 1);
        }
        else {
            if (this.graphics.foregroundColor != undefined) {
                $.writeln("Names are different: change the name from red to black.");                        
                this.graphics.foregroundColor = this.graphics.newPen(this.graphics.PenType.SOLID_COLOR, [0, 0, 0], 1);
            }
        }
    }
    

    "g" is the text in a group.

    I wonder, is there a way to reset the color to the default text instead of repainting it?

    Currently, it checks if foregroundColor of graph is not undefined - which is painted with "newPen" - and if it is true, he painted black. But I guess it is a clumsy workaround and there should be a good way to do this.

    Kind regards

    Kasyan

    Hi Kasyan

    Pre CC could set the color to null, CC, this causes an accident.

    PS there are other options (color theme), but not on ID so paint is the only option I know.

    The challenge is dealing with default colors that depend on the setting. To change the text in the foreground is always black background colors you can either take the approach here Re: Re: Re: Re: ScriptUI: element of change to the default color

    Or a longer but more effective approach would be to go pass 100 values possible topic and get the associated rgb values.

    Probably not interesting put in a lot of effort as the way things are going THAT SUI will not support editing text in a few years.

    Concerning

    Trevor

  • Export of the correct Hex colors via script

    Hi all

    I need to export the fillColor of a paragraph via script style.

    I can get the fillColor of the paragraph style property and can also convert CMYK Hex. However, I realize that color in InDesign values in some color space of the document uses.

    My question is, is there a native API to convert the values of color for a web safe color value? If this is not the case, how can I go on the correspondences between colors?

    In addition, I see that Adobe knows internally to convert it to a good hex color (attached screenshot - note the color property in the export marking side). If I can't use some native API, is there a way to access the text in this pane?

    Screen Shot 2014-12-15 at 7.25.20 PM.png

    Thank you all in advance!

    Win! It worked!

    Here is the complete solution-

    Assuming that the original color is stored in a variable named color :

    var color = passedInColor; //the original color that we wish to convert.
    
    // Create a temporary color instance that we'll use to extract updated colorValues.
    var scratchColor = workingDoc.colors.add({
                             model: color.model,
                             space: color.space,
                             colorValue: color.colorValue
                        });
    
    // Now, we force adobe's internal color conversion mechanism to trigger by changing the scratchColor's color space.
    scratchColor.space = ColorSpace.RGB;
    var updatedValues = scratchColor.colorValue; // Updated values now has the properly mapped and converted RGB values.
    // You may need to round off the R, G and B values in the updatedValues array.
    // And that's it!
    

    Why am I not surprised that she should be a hacky autour work? * sigh *. It was so so so frustrating to work on this platform! I hope adobe gets his act together!

  • Model by unwanted color change script

    I defined a model I intend using as a filling. After that I selected scripted brick and model of the pop box filling up I noticed that it is by changing the colors of my boss. I put the cursor of random color to 0 but the colors of my original pattern are different.

    I don't want my pattern color to change. Is this possible?

    I thought about it.

    If your color RGB mode the colors remain the same. Is it your CMYK color mode as it was for me, the colors change.

    You must change it back between RGB and CMYK

  • Menu color by Script

    Hi Experts,

    I'm trying to create a Menu ID that contains submenus, and I want to apply the color for this menu. It can be done manually by Edit-> Menus...-> by selecting the menu, next to this menu, we can change the color, is to enter into the menu. But I did not have to do with Automation by using google Javascript.I a lot to achieve. But I can not find, even in this forum too. That's why I ask this question to the expert ID. And I add the menu, have submenus (view > symbol,) I can able to add colors manually. Other menu items that does not submenus, I can't able to apply colors manually too... You can guide me expert!

    I tried the codes below. But I can not find the color property.

    var menuName = app.menuActions.itemByID (6146);

    var x = NomMenu;

    Alert (x.Properties);

    var y = x.properties;

    Alert (y.toSource ());

    Output:

    error.png

    Thank you and best regards,

    Velprakash.

    I don't think it's available via the script. Submit a feature request...

  • Color select Script needs refining

    Hello

    I've been running this simple script (created by an end PS scripter) in action:

    #target Photoshop

    main() {} function

    if(!documents.) Length) return;

    app.activeDocument.colorSamplers.removeAll ();

    var X = activeDocument.width.as('px')/2;

    var sample = activeDocument.colorSamplers.add ([new UnitValue (X, 'px'), new UnitValue (1, 'px')]);

    app.backgroundColor = sample.color;

    app.activeDocument.colorSamplers.removeAll ();

    }

    main();

    It selects the top center pixel color, sample, for the bottom point. Now I need to select a 5 x 5 moy. Second, is there a way to hide the INFORMATION pane, which opens by running the script? This appears not be called from an action, of course, and I'm not script.

    Thanks for any help.

    This should make an average...

    #target Photoshop
    function main(){
    if(!documents.length) return;
    var startRulerUnits = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;
    try{
    app.activeDocument.colorSamplers.removeAll();
    var X = activeDocument.width/2;
    var LB=[];
    LB[0] = X.value;
    LB[1] = 1;
    LB[2] = X.value +5;
    LB[3] = 6;
    var tmpColour = new SolidColor();
    var savedState = activeDocument.activeHistoryState;
    activeDocument.selection.select([[LB[0],LB[1]], [LB[2],LB[1]], [LB[2],LB[3]], [LB[0], LB[3]]], SelectionType.REPLACE, 0, false);
    activeDocument.activeLayer.applyAverage();
    var sample = activeDocument.colorSamplers.add( [ new UnitValue( X+1, 'px' ), new UnitValue( 2, 'px' ) ] );
    tmpColour=sample.color;
    activeDocument.activeHistoryState = savedState;
    app.backgroundColor=tmpColour;
    app.preferences.rulerUnits = startRulerUnits;
    }catch(e){alert(e + " - " + e.line);}
    }
    main();
    

    I was not able to stop the information panel so I add to my open panels is not intrusive.

  • Access to the project color management script

    I know that you can access some color management settings in a script (i.e. bitsPerChannel), but I don't know about the others. In particular, can you get/set the workspace through a script? Thank you.

    N ° no color management controls are available in a script. bitsPerChannel and linearBlending are parameters of project that are associated with the color, but none are specific to color management.

    If you want to access the color management settings through scripts, please file a feature request.

  • Color Picker script or algorithm levels help

    First question is: did anyone know of a good explanation of the algorithm of levels as in how each setting affects a pixel in an image. If I change the middle point levels, how a specific pixel change in relation to this? I've experimented for hours and cannot understand one common factor other that there seems to be a relationship of binary type. The reason why I ask this question, it's because I'm trying to generate scripts that will balance the colors.

    If this method is not practical, I can go to the old method of old-fashioned trial and error, but this way also presents an obstacle for me. I made a point of color picker and the script can get the values from there exactly as it is in the Info Panel. If I put an above levels adjustment layer and adjust it, I now see the initial color and the adjusted value of color in the Info Panel, but I can't figure out how to get the value adjusted with a script. It always returns the original value. Does anyone know how to get the adjusted value?

    I hope I explained this right.

    What version of Photoshop are you using and what layer is active when you ran the script? I guess the depth of space and little color might also have.

    With CS4, 8 bit RGB I get different values, unless the adjustment layer was not visible when the script starts. Looks like maybe your adjustment layer was turned off when you ran the script becuse you see 226 (rounded) in the alert

  • Color Sampler script part 2

    Ok. So I'm back at it. Here's what I have a problem to find now any help would be appreciated of course.

    When I use the colorSamplers script I am able to get information on a single point. However, when you set the sampling points there is the possibility to select the single point, 3 by 3 average, 5 by 5 average 11 of 11, etc., and the average number is shown in the Info Panel. But, the script always returns the information of single point and not the average. Is it possible to obtain this information using another script that through every point with the colorSamplers [0] .move () and make the calculation in the script in order to get the average? This is how I do it now, but for large surfaces, it can become slow.

    Any advice?

    No, I don't mind at all. You can replace your scriptlistner turn off with the method DOM comes to make the code a little tighter.

    activeDocument.selection.deselect ();

  • Flash swf componrnt color changing script flex button

    I have a swf created in flash that is used in flex. the button has an arrow that is originally black, now I need to dynamically change the color of the arrow. I know that flex slightly but do not know flash.
    I have the SWF source - fla - file too, where there is a button symbol - arrow - in the library, but I don't know how to access this symbol of flex and change its properties.
    Thanks in advance.

    I solved it by myself.

  • A script to divide each color into a separate layer?

    Hello, I was just wondering if anyone knows of a script that can automate the task of taking a single layer with a few different colors in this (rare, I mean between 2-10 colors here) and separate each color to put on its own layer.

    I did a quick search on google and came across this Split to layers. Scripts Photoshop .
    It's not what I want to do specifically of course but it seems to me that it should be possible to change this to select sort of color threshold instead of select continuous blocks in the alpha channel. I had a look in the script but I would more hazy about how to modify the code for what I need.

    Here, anyone have any ideas?

    Thank you

    Then finally opening in photoshop, separate into layers and applying latest details (shading, highlights, more colors etc.)

    Personally, I think you might be better of sticking with Illustrator, once you vectorized the image.

    In the absence of anti-aliasing (I had to clean up the image significantly, PNG should worked better) and with a limited number of colors, a script approach seems indeed possible.

    This Script is strictly for RGB images and tries to determine the colors, if you know you could throw a bunch of code and set rather manually from the theArray.

    divide the regions of color to an RGB image in layers;

    2016, use it at your own risk.

    #target photoshop

    If (app.documents.length > 0) {}

    If (app.activeDocument.mode = DocumentMode.RGB) {}

    var (HAE) 1 = Number (timeString ());

    myDocument var = app.activeDocument.duplicate ("theCopy", true);

    var theLayer = myDocument.activeLayer;

    var histogram = myDocument.histogram;

    var total = 0;

    for (var n = 0; n)< histo.length;="" n++)="">

    Total = total + histo [n];

    };

    collect histograms and not 0-values;

    var theHistos = new Array;

    for (var m = 0; m< 3;="" m++)="">

    var histogram = myDocument.channels [m] .histogram;

    var values = new Array;

    for (var n = 0; n)< histo.length;="" n++)="">

    If (histo [n]! = 0) {theValues.push (n)}

    };

    theHistos.push ([historical, values])

    };

    ////////////////////////////////////

    var theArray = new Array;

    create the masking layer to determine which combinations of values exist more or less;

    Solid var = solidColorLayer (55, 128, 200, 'aaa', charIDToTypeID ("Dfrn"));

    Try;

    for (var n = 0; n)< thehistos[0][1].length;="" n++)="">

    ////////////////////////////////////

    for (var o = 0; o)< thehistos[1][1].length;="" o++)="">

    ////////////////////////////////////

    for (variety p = 0; p)< thehistos[2][1].length;="" p++)="">

    ////////////////////////////////////

    try {}

    $.writeln(theHistos[0][1][n]+"___"+theHistos[1][1][o]+"___"+theHistos[2][1][p]);

    changeSolidColorLayer (theHistos [0] [1] [n], theHistos [1] [1] [o], theHistos [2] [1] [p]);

    var checkHisto = myDocument.histogram;

    If (checkHisto [0] > 0) {}

    theArray.push ([theHistos [0] [1] [n], theHistos [1] [1] [o], theHistos [2] [1] [p]])

    };

    }

    catch (e) {};

    ////////////////////////////////////

    };

    ////////////////////////////////////

    };

    ////////////////////////////////////

    };

    theSolid.remove ();

    try to cut layers;

    for (var a = 0;< thearray.length;="" a++)="">

    try {}

    selectColorRange (theArray [a] [0], [a] [1] theArray, theArray [a] [2], 0);

    cutToLayer ();

    myDocument.activeLayer = theLayer;

    }

    catch (e) {};

    };

    var Number = time2 (timeString ());

    Alert (((TIME2-time1)/1000) +"seconds\nstart" + (HAE) 1 + ' \nend '+ time2)

    }

    };

    Select color range.

    function selectColorRange (g, theB, theR, blur) {}

    // =======================================================

    var idClrR = charIDToTypeID ("Llrc");

    var desc4 = new ActionDescriptor();

    var idFzns = charIDToTypeID ("Fzns");

    Desc4.putInteger (idFzns, blur);

    var idMnm = charIDToTypeID ("Mnm");

    var desc5 = new ActionDescriptor();

    idR var = charIDToTypeID ('Rd');

    Desc5.putDouble (idR, theR);

    idG var = charIDToTypeID ("Grn");

    Desc5.putDouble (idG, g);

    the IDB var = charIDToTypeID ("Bl");

    Desc5.putDouble (IDB, theB);

    var idRGCl = charIDToTypeID ("RGBC");

    Desc4.putObject (idMnm, idRGCl, desc5);

    var idMxm = charIDToTypeID ('Mxm');

    var desc6 = new ActionDescriptor();

    idR var = charIDToTypeID ('Rd');

    desc6.putDouble (idR, theR);

    idG var = charIDToTypeID ("Grn");

    desc6.putDouble (idG, g);

    the IDB var = charIDToTypeID ("Bl");

    desc6.putDouble (IDB, theB);

    var idRGCl = charIDToTypeID ("RGBC");

    Desc4.putObject (idMxm, idRGCl, desc6);

    var idcolorModel = stringIDToTypeID ('colorModel');

    Desc4.putInteger (idcolorModel, 0);

    executeAction (idClrR, desc4, DialogModes.NO);

    };

    cut layer.

    function cutToLayer () {}

    try {}

    // =======================================================

    var idCtTL = charIDToTypeID ("CtTL");

    executeAction (idCtTL, undefined, DialogModes.NO);

    return activeDocument.activeLayer

    } catch (e) {return undefined}

    };

    create a solid color layer.

    function solidColorLayer (theR, g, theB, theName, theBlendMode) {}

    // =======================================================

    var idMk = charIDToTypeID ("Mk");

    var desc10 = new ActionDescriptor();

    var idnull = charIDToTypeID ("null");

    var ref1 = new ActionReference();

    var idcontentLayer = stringIDToTypeID ("contentLayer");

    Ref1.putClass (idcontentLayer);

    desc10.putReference (idnull, ref1);

    var idUsng = charIDToTypeID ("Usng");

    var desc11 = new ActionDescriptor();

    var idNm = charIDToTypeID ("Nm");

    desc11.putString (idNm, theName);

    TSM var = charIDToTypeID ("Md");

    var idBlnM = charIDToTypeID ("BlnM");

    var idMltp = theBlendMode;

    desc11.putEnumerated (TSM, idBlnM, idMltp);

    var idType is charIDToTypeID ('Type');.

    var desc12 = new ActionDescriptor();

    var idClr = charIDToTypeID ("Clr");

    var desc13 = new ActionDescriptor();

    idRd var = charIDToTypeID ('Rd');

    desc13.putDouble (idRd, theR);

    var idGrn = charIDToTypeID ("Grn");

    desc13.putDouble (idGrn, g);

    var idBl = charIDToTypeID ("Bl");

    desc13.putDouble (idBl, theB);

    var idRGBC = charIDToTypeID ("RGBC");

    desc12.putObject (idClr, idRGBC, desc13);

    var idsolidColorLayer = stringIDToTypeID ("solidColorLayer");

    desc11.putObject (idType, idsolidColorLayer, desc12);

    var idcontentLayer = stringIDToTypeID ("contentLayer");

    desc10.putObject (idUsng, idcontentLayer, desc11);

    executeAction (idMk, desc10, DialogModes.NO);

    return app.activeDocument.activeLayer

    };

    changeSolidColor.

    function changeSolidColorLayer (theR, g, theB) {}

    try {}

    // =======================================================

    var idsetd = charIDToTypeID ("setd");

    var desc17 = new ActionDescriptor();

    var idnull = charIDToTypeID ("null");

    ref2 var = new ActionReference();

    var idcontentLayer = stringIDToTypeID ("contentLayer");

    var idOrdn = charIDToTypeID ('Ordn');

    var idTrgt = charIDToTypeID ("Trgt");

    ref2.putEnumerated (idcontentLayer, idOrdn, idTrgt);

    desc17.putReference (idnull, ref2);

    idT var = charIDToTypeID ("T");

    var desc18 = new ActionDescriptor();

    var idClr = charIDToTypeID ("Clr");

    var desc19 = new ActionDescriptor();

    idRd var = charIDToTypeID ('Rd');

    desc19.putDouble (idRd, theR);

    var idGrn = charIDToTypeID ("Grn");

    desc19.putDouble (idGrn, g);

    var idBl = charIDToTypeID ("Bl");

    desc19.putDouble (idBl, theB);

    var idRGBC = charIDToTypeID ("RGBC");

    desc18.putObject (idClr, idRGBC, desc19);

    var idsolidColorLayer = stringIDToTypeID ("solidColorLayer");

    desc17.putObject (idT, idsolidColorLayer, desc18);

    executeAction (idsetd, desc17, DialogModes.NO);

    Returns true

    } catch (e) {return false;}

    };

    function to get the date.

    function timeString () {}

    var now = new Date();

    return Now.getTime)

    };

  • How to set my color?

    Hi experts,

    I have a script:

    app.findObjectPreferences = null;
    app.findObjectPreferences.fillColor = "MARKUP";
    app.changeObjectPreferences.fillColor = "Black";
    app.changeObject();
    app.findObjectPreferences = null;
    app.findObjectPreferences.strokeColor = "MARKUP";
    app.changeObjectPreferences.strokeColor = "Black";
    app.changeObject();
    

    to find and change the color of the object, but if the docs that has no name in the shade of color, the script will be executed in error, so how can I set if no such as the color, the script to continue? How can the script below work?

    var myDoc = app.activeDocument;
    myColor = myDoc.colors.name("MARKUP");
    if (!cmyColor) continue;
    
    app.findObjectPreferences = null;
    app.findObjectPreferences.fillColor = myColor;
    app.changeObjectPreferences.fillColor = "Black;
    app.changeObject();
    
    app.findObjectPreferences = null;
    app.findObjectPreferences.strokeColor = myColor;
    app.changeObjectPreferences.strokeColor = "Black";
    app.changeObject();
    

    Thank you

    Respect of

    John

    Here's an idea, which also includes the previous question "MARKUP, markup, MARK-UP, MARK_UP":

    app.doScript(main, ScriptLanguage.JAVASCRIPT , [], UndoModes.ENTIRE_SCRIPT, "Replace Colors");
    
    function main() {
    
    var curDoc = app.activeDocument;
    var allSwatches = curDoc.swatches;
    var allPItems = curDoc.allPageItems;
    
    var colorsToRemove = [];
    
    for (var i = 0; i < allSwatches.length; i++) {
      var curSwatch = allSwatches[i];
      var curSwatchName = curSwatch.name;
      var colorToFind = curSwatchName.search(/Mark[-_]?UP/i);
      if (colorToFind != -1) {
    
    colorsToRemove.push(curSwatch.name);
    
      }
    }
    alert("Found color names:\r" + colorsToRemove.join("\r"));
    
    for (i = 0; i < allPItems.length; i++) {
      var curItem = allPItems[i];
      var fColorName = curItem.fillColor.name;
      var sColorName = curItem.strokeColor.name;
      for (var j = 0; j < colorsToRemove.length; j++) {
    
    var curColorName = colorsToRemove[j];
    
    if (fColorName == curColorName) {
    
    curItem.fillColor = "Black";
    
    }
    
    if (sColorName == curColorName) {
    
    curItem.strokeColor = "Black";
    
      }
    }
    }
    

    BTW: syntax highlighting destroyed the code

    Kai

  • Execute and return a value (or object) from another script

    I wish I could have some of the functions of the little that I often use in my scripts, just like seporate scripts. so I can then update in one place and do not copy in every script, I want to use them in.

    I don't know if this is possible at all. But I'd love to be able to just call them and return of their share values somehow.

    for example

    Swatches of color key code, I need:

            var inCutColorCMYK = cmykColor(50, 0, 100, 0);
            var intCutSPOT = makeSwatch("CutIN", inCutColorCMYK);
    

    so I have these functions I have tweeked/found:

       function makeSwatch( swName, swCol) {  
        var doc = app.activeDocument;
        var sel = doc.selection;
        if (!inCollection(doc.swatches, swName)) {  
        var aSwatch = doc.spots.add();  
        aSwatch.name = swName;  
        aSwatch.color = swCol;  
        aSwatch.tint = 100;  
        aSwatch.colorType = ColorModel.SPOT;  
        var aSwatchSpot = new SpotColor();  
        aSwatchSpot.spot = aSwatch;  
        return aSwatchSpot;  
        }else{  
            return doc.swatches.getByName(swName);  
            }  
        };
    
    
    function cmykColor(c, m, y, k) {  
        var newCMYK = new CMYKColor();  
        newCMYK.cyan = c;  
        newCMYK.magenta = m;  
        newCMYK.yellow = y;  
        newCMYK.black = k;  
        return newCMYK;  
        };
    
    
    
    
    function inCollection(collection, nameString) {  
           var exists = false;  
       try{
        for (var i = 0; i < collection.length; i++) {  
            if (collection[i].name == nameString) {  
                exists = true;  
                }  
            }  
        }catch(e){//alert("Illustrator needs drop kicked!!\nPlease restart Illustrator :/\n\n"+e)
            }
            return exists;  
            
          };
    

    in any case! I keep finding my self using functions like that again and again new scripts and hope there is a way to do this!

    Any help is appreciated!

    -Boyd

    You have the file a.jsx, something like myLibrary.jsx, and in it, you can have all the functions for future use. In the file, it can look like this:

    ------------------------------------ Library file -----------------------------------

    #target illustrator

    function MyLibrary() {}

    this.cmykColor = function (c, m, y, k) {}

    var newCMYK = new CMYKColor();

    newCMYK.cyan = c;

    newCMYK.magenta = m;

    newCMYK.yellow = y;

    newCMYK.black = k;

    Return newCMYK;

    };

    function applyFillColorTo (item, color) {}

    item.fillColor = color;

    }

    function CataloguedPathItem (pathItem) {}

    var p = pathItem;

    p.applyFillColor = {function (color)}

    applyFillColorTo (this, color);

    };

    return p;

    }

    this.cataloguedPathItem = {function (pathItem)}

    var p = new CataloguedPathItem (pathItem);

    return p;

    }

    };

    ----------------------------------------------------------------------------------------

    And then you can understand and use this file in other scripts, like here:
    -------------------------------------- Script File ---------------------------------

    #target illustrator

    #include 'C:\\Users\\Me\\Desktop\\My Adobe Scripts\\Illustrator\\MyLibrary.jsx.

    function test() {}

    var MyLib = new MyLibrary(); the script library is used as an object - elements of its scope of application are available through point (.) as mylib.myFunction ();

    If (app.documents.length > 0) {}

    var doc = app.activeDocument;

    If (doc.selection.length > 0) {}

    var MonElement = mylib.cataloguedPathItem(doc.selection[0]);

    var mylib.cmykColor (0,100,50,0) = myColor;

    myItem.applyFillColor (myColor);

    }

    } else {}

    Alert ("there is no open document.");

    }

    }

    test();

    ----------------------------------------------------------------------------------------

    The colors test script just a pathItem, but it uses functions from the inside of the object of 'library' to power the process. Note that to use the library of color a path implied instantiate this path as a custom which is a 'applyFillColor' method that uses a function of the scope of the library (called "applyFillColorTo") for power. Then, we can not simply the function "applyFillColorTo" use within the scope of the Script file because it is protected by the MyLibrary object.

Maybe you are looking for