[JS][CS3] Create new swatch

Hi all,
I'm writing a script that reads an xml file and then converts the contents to InDesign Objects.
Most of this I can do, but I'm having problems with the colors and swatches in InDesign.
Simple said, what I'm trying to do is the following:
1. Create a rectangle on my document
2. Create a new Color Swatch with CMYK values
3. Use the swatch for the rectangle's fillColor or strokeColor
Using Javascript I can add new colors tot my document: myDoc.colors.add()
But I can't use this color for the fillColor or strokeColor properties, it says they it needs to be a swatch, and not a color.
Unfortunately, the method myDoc.swatches.add() doesn't exist, and I can't set a colorValue property to a swatch.
Does anybody know how to do this? I'm guessing there's a simple solution for this, but I'm just not seeing it.
Thanks in advance,
Dany

Hi Kasyan,
Thanks very much for your reply.
I breaked my head trying to find what was the difference between your code and mine, but now I see:
Instead of using myDoc.colors, I used app.colors, which returns an error if you try to use that color for a rectangle, textframe, etc.
Thanks !
Dany

Similar Messages

  • "Create New Swatch" not working in Indesign CS5

    Suddenly, I am no longer able to create a process swatch by clicking on "new Swatch" on the swatch menu swatch. When I click this
    window comes up and the PMS list is over the procees color boxes and i cant input anything. To work around I have been creating the Process colors and them dragging them to the swatch palatte, but this is annoying. Any Idea how to fix this problem?

    Trash your prefs. See Replace Your Preferences

  • Create new swatch using Guassian Blur

    Hello
    I am trying to create a new swatch pattern that repeats consistently (see diagram below)
    I create a assemble four (6pt by 6pt squares) together and then colour them in approproiately. I guassian blur at 1.5pt each square. I add a base colour background in a square of 12pt by 12pt and then put a 12pt by 12pt invisible bounding box behind all this. I then drag to the swatch panel to create my new swatch.
    Problem is that when I try to colour in a larger square with this patter I get harsh lines ... see the example. Would love thoughts on how to get around this
    Thanks
    John

    Nah, don't create the seams at the edges of the squares but more in a flower shape with one of the squares in the middle and the others surrounding it as ahlf squares.
    Mylenium

  • No "create new swatch" command

    I just noticed that there are no icon buttons at the bottom
    of the swatches panel to create or delete a new swatch like there
    is in AI and PS; is this an oversight?

    Paevo Kelley wrote:
    > I just noticed that there are no icon buttons at the
    bottom of the
    > swatches panel to create or delete a new swatch like
    there is in AI
    > and PS; is this an oversight?
    Click in the swatches panel. The cursor will change into a
    paint bucket,
    and the color of any object you have selected will be added
    to the panel.
    Stop expecting things in Fireworks to work the same way they
    do in
    Photoshop. :-)
    Linda Rathgeber - Adobe Community Expert
    http://www.adobe.com/communities/experts/members/8.html

  • JS[CS3] Create Pattern/Swatch

    I am new to JS
    in AI. I know pretty well JS in ID but the object is totally different.
    So I am creating a layer, naming it, Creating a box, Importing an EPS as a groupItem.
    NOW the tricky part. The imported EPS is my Stamp so I need to create a pattern from it.
    Then apply that pattern to my box. That is where I loose myself. I don't comprehend the relationship between stwatch, pattern & Patterncolor. But I did understand that a swatch COLOR can be of type PatternColor and there you can access its properties like angle, scale, etc... But a PatternColor is a Pattern itself?!? I also understand I can access my pattern using the swatches because a pattern is actually a swatch color.
    Any pointer on how to create a pattern from my groupItem? Pattern.add method has no argument, right?
    So I can't do
    var myDoc = app.activeDocument;
    var myStamp = myDoc.groupItems.createFromFile(myFile);
    var myPattern = myDoc.patterns.add(myStamp);              <---- Error
    myPattern.name = "XXX";
    var mySwatch = myDoc.swatches.getByName("XXX");
    mySwatch.color.rotation = 45;
    mySwatch.color.scaleFactor= [50, 50];
    var myRCT = myDoc.pathItems.rectangle(myDoc.pageOrigin[1], myDoc.pageOrigin[0], myDoc.width, -myDoc.height);                              
    myRCT.fillColor = mySwatch.color;     <---- DOES not apply it maybe because a pattern?
    Any help is appreciated

    Yes that is what I get as well. There as to be a way to assign, just like the GUI does.
    Compared to InDesign, AI scripting sucks. It is really poorly implemented. Even the help is sketchy at best.
    I'll keep trucking along and post my findings.
    Cheers, Alex.

  • Can't create new sites in Dreamweaver CS3.  Help!

    I am trying to create a new site in Dreamweaver CS3 but keep
    getting the following error:
    "The action cannot be completed because the other program is
    busy.
    Choose 'Switch to' to activate the program and correct the
    problem"
    I have tried every documented solution on the adobe website
    and other discussion forums and still cannot get past the problem.
    I have restarted the IIS server on my local PC as documented
    on the following adobe technote:
    http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_16485&sliceId=2
    Other things I have done:
    1. I have followed all the advice in the links at the bottom
    of the above page.
    2. I have created a new user, logged into that and tried
    creating a site with a "virgin" environment
    and I still have the problem.
    3. I have gone into the registry and renamed the site
    configuration info in case something was corrupted.
    This removed all my site configurations. No help!
    4. I have turned of my firewall and restarted the IIS
    server.
    5. I have searched the web for anything even remotely
    similar to this error and tried every tip out there.
    I called Adobe and they referred me back to the technote
    above, which I had already tried.
    One last bit of info. I can't create new sites, but I can
    edit web pages in my existing sites. However, I cannot change the
    configuration of the website in the Manage Sites area (i.e. I can't
    push the Edit button).
    Has anyone had this problem? Any help would be appreciated. I
    have hit a brick wall on this one and am trying to meet a deadline
    on a new website I need to create.
    If I can't find a solution quick, I will be an
    ex-Dreamweaver user. That saddens me because I really like
    Dreamweaver, but I have to perform on my job.

    And are you running Skype?
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "Murray *ACE*" <[email protected]> wrote
    in message
    news:ga4hba$bnv$[email protected]..
    > What is your firewall?
    >
    > --
    > Murray --- ICQ 71997575
    > Adobe Community Expert
    > (If you *MUST* email me, don't LAUGH when you do so!)
    > ==================
    >
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    >
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    > ==================
    >
    >
    > "Steven A" <[email protected]> wrote in
    message
    > news:ga4ejo$8nb$[email protected]..
    >>I have rebooted many times. Actually, I am the only
    user that ever logs
    >>in.
    >> This is happening on my laptop. I just created
    another user to see if it
    >> was a
    >> corruption issue with sites tied to my regular
    login.
    >>
    >>
    >>
    >

  • Dreamweaver CS3 - Cannot create root and image folder in Site Management. (Create New Site)

    Good day everyone,
    I am not able to create folders for a new site in Dreamweaver CS3.
    This is the problem:
    I open Dreamweaver
    I go to site and click on create new site
    In the new site panel I name the site eg: Test Site
    Then I click on the browse folder to attached a root folder and image folder for the site
    This is where the problem starts, when I browse to the folders, Dreamweaver does not keep the location/path.
    Like this: My folder is created in the following directory.
    C:\xampp\htdocs\my_site_folder
    So when I browse to this folder and click save
    the path does not stay in Dreamweaver, all the stays is this.
    C:\xampp\htdocs\
    The site name does not remain.
    I cannot get Dreamweaver to hold the path.
    Same for the image folder.
    I noticed this started to happened after I updated Vista to Service pack 2.
    I have never seen this happen before.
    Anyone have any ideas?
    Thanks.
    Patrick

    You'll see the anser to this here:
    http://forums.adobe.com/thread/478132?tstart=60
    E. Michael Brandt
    www.divahtml.com
    www.divahtml.com/products/scripts_dreamweaver_extensions.php
    Standards-compliant scripts and Dreamweaver Extensions
    www.valleywebdesigns.com/vwd_Vdw.asp
    JustSo PictureWindow
    JustSo PhotoAlbum, et alia

  • How to create new docs with custom swatch palette?

    Looking to create new documents with a corporate color palette already available instead of having to load the .ase files. Fat chance?

    Thanks Bob - I was trying that on a test MAC and it just was not sticking. A shutdown instead or a restart seemed to put things back in order and now all is good.

  • [JS, CS3] Creating a new boolean object. Is it possible?

    Hello,
    I am wondering if I can create a new boolean object in InDesign that I can use in a script I am working on. What I am doing is selecting some text and then manipulating other aspects of the selection's paragraph. I want to be able to determine if certain characters are selected, so the new boolean object would be, let's say "selected." If a character within the paragraph is selected, it's value would be "true," while other characters in the paragraph that are not selected would remain "false." Is this possible? I am also thinking that I could use an already existing boolean value, such as strikeThrough and then turn it off at the end of the script. But this is not elegant if the text were to REALLY need strikeThrough (not very likely, but just sayin'). Thanks for any advice.
    Regards,
    Len Swierski

    Len,
    Your current approach is the only feasible one. You can't create new properties for Indesign's objects. In some cases it's easy: text frames, for instance, can have their label set to a certain value, as can several other objects (cells, the application, etc.).
    But characters don't have the label property, so you have to use an existing property, as you did with overstrike. If you don't like using that particular one, have a look through the OMV under "Character" and see if there's a property that suits your needs better than overstrike.
    What you can use use this: in a script you can assign a character (text, word, etc.) an underline colour without setting underline. In the interface you'd have to enable underline, then set a colour, then disable underline. In a script enabling and disabling underline isn't necessary: just set myCharacter.underlineColor to some value ('Black' for "yes", 'White' for "no" or something like that).
    So though you can't add new properties to characters, they have so many already that you're sure to find one you can exploit.
    Peter

  • Select path with same swatch and apply a new swatch

    I am trying to write a script that will select a line based on a swatch name, apply a new swatch, set the stroke, dash and miter of the line...and then create a new layer, change then name of the layer, and then move the selected items to the newly created layer.
    All I could seem to accomplish was renaming a swatch.
    var swatchName = app.activeDocument.swatches;
    if (swatchName.length > 0) {
        for (i=0; i < swatchName.length; i++){  
            changeName(swatchName[i]);
    function changeName(swatchObject){
                     if (swatchObject.name == "PANTONE Orange 021 C"){                     
                        swatchObject.name = "021 (Orange)";
                    if (swatchObject.name == "PANTONE Red 032 C"){                     
                        swatchObject.name = "032 (Red)";
    So the goal of what I would like it to do is look for all paths with the stroke color set to "PANTONE Orange 021 C" then have it change the swatch name to "021 (Orange)". After that apply the stroke, dash and miter. Create a new layer named "021 (Orange)". Then send all of the selected lines to that layer.
    PLEASE HELP AS I HAVE 200+ files to do this task to. Using a windows machine with CS3. Trying to write in javascript.

    This would be the way to rename 2 existing swatches… The GUI pallet can be a little sticky in updating but it works…
    #target illustrator
    var docRef = app.activeDocument;
    var a = docRef.swatches.getByName('PANTONE Orange 021 C');
    a.name = '021 (Orange)';
    var b = docRef.swatches.getByName('PANTONE Red 032 C');
    b.name = '032 (Red)';
    redraw();
    My mistake… Looks like this Jive stuff gave you an unwanted bump from nowhere? Didn't look at the date…

  • Creating Custom Swatches

    Is there a way in Illustrator CS3 or CS4 to add individual swatches or a group of swatches that have specific names for my workflow into the swatches panel? I have found that I can do this with a new document with the "New Document Profile" and also I can load a custom swatch library in Illustrator.
    I would like a few certain swatches to always show up in the swatches panel, or to quickly load them, without browsing thru several windows.
    Do I need a script to do this?
    Maari

    You do not need a script but yu do this I copied it from my post on another thread.
    The way yo do this is go to the Users/Username/Library/Application
    Support/Adobe/US_en/Adobe Illustrator CS 4/New Document Presets/Print
    if that is the preset you use to create new files or any of the others
    or do this to all of preset files.
    You open the file in AI and you take your the colors you want as
    swatches and load them in the swatches panel and delete all the others
    and save the file or save as and over write the file. Yu n then import
    those swatches into the other presets and you save those as well to
    the same location overwriting the originals.
    Now when you open a new document for print or any other preset you
    have only the colors you want.
    http://forums.adobe.com/thread/446074?tstart=0

  • Script to select same stroke color and apply a new swatch...

    I am trying to write a script that will select a line based on a swatch name, apply a new swatch, set the stroke, dash and miter of the line...and then create a new layer, change then name of the layer, and then move the selected items to the newly created layer.
    All I could seem to accomplish was renaming a swatch.
    var swatchName = app.activeDocument.swatches;
    if (swatchName.length > 0) {
        for (i=0; i < swatchName.length; i++){  
            changeName(swatchName[i]);
    function changeName(swatchObject){
                     if (swatchObject.name == "PANTONE Orange 021 C"){                     
                        swatchObject.name = "021 (Orange)";
                    if (swatchObject.name == "PANTONE Red 032 C"){                     
                        swatchObject.name = "032 (Red)";
    So the goal of what I would like it to do is look for all paths with the stroke color set to "PANTONE Orange 021 C" then have it change the swatch name to "021 (Orange)". After that apply the stroke, dash and miter. Create a new layer named "021 (Orange)". Then send all of the selected lines to that layer.
    PLEASE HELP AS I HAVE 200+ files to do this task to. Using a windows machine with CS3. Trying to write in javascript.

    This would be the way to rename 2 existing swatches… The GUI pallet can be a little sticky in updating but it works…
    #target illustrator
    var docRef = app.activeDocument;
    var a = docRef.swatches.getByName('PANTONE Orange 021 C');
    a.name = '021 (Orange)';
    var b = docRef.swatches.getByName('PANTONE Red 032 C');
    b.name = '032 (Red)';
    redraw();
    My mistake… Looks like this Jive stuff gave you an unwanted bump from nowhere? Didn't look at the date…

  • How to create a swatch library from multiple png files?

    Illustrator CC
    I am having a difficult time trying to create a new swatch libray of patterns from multiple png files. The way I am doing this is very slow and repetitive and seems silly for a tool as advanced as the latest CC suite including illustrator.
    What it seems I must do is open all the png files in Illustrator, creating multiple workspaces, drag one png file into the swatch window, then save that window as a library, close the existing window to reveal the next png file, open the user library I just created, drag the next image into the currently active swatch window, then drag the previous swatch/s from the user library into the current active swatch window, resave and replace the user defined swatch library (now with two images in there)fromthe updated current active swatch panel/window, close the existing workspace to reveal the next image file, and then repeat the process again, slowly building the user defined swatch library up by adding one image at a time and then adding back into the Swatch panel the previously built up library of swatches again one at at time.  (you can select all from the existing  user defined library and drag over into swatch panel, but this creates at least one  duplicate on each cycle for as soon as you click on the first swatch in the library, it adds itto the current swatch panel and then when you select all swatches to drag across it includes the first swatch and copies it again)
    This is a very slow process to build up a swatch library. For some reason you cannot drag swatches directly into  the user defined library you have created, only into the active swatch window for each workspace. I searched the web and forums  for answers but could find none. There must be an easier way,  just can't find it.
    Ideally, the best option would be a swatch window  option that allows the import directly from a list of selected files in the finder.
    Any ideas out there?

    Monika,
    Thank you for responding, however I am not exactly clear on what you mean by "libraries are plain AI files". For example, I cannot find a file with the same name as my user defined library name that I have created. I can find the preinstalled swatches listed under Adobe Application Support... Library... Swatches, but a user defined folder is not present and the library sets that I have already created are not visible. I have tried searcing my Mac for a (name).ase file and still no luck (at least for the name I was looking for). I can open the user defined library from the Swatch library icon on the bottom left of the Swatch panel, but when I open this I cannot drag and drop add new swatches directly to this library. As stated above, I have to add each pattern, one at at time to the normal swatch panel, then add back the previous ones I have saved from the user defined library to the swatch panel and then save threm all as an updated user defined library. Thus by repeating this process, it builds up the user defined library one at a time.
    I am using Illustrator CC if this makes a difference.

  • How do I select a set of swatches (ideally at once) from a long list to create a swatch library?

    I just started using PS (CS6) and I added 10 new custom swatches that I want to save in a new swatch library. However, I still have the PS default library of swatches listed (that contains scores of colors). Can I select multiple swatches at once to save them for the swatch library? Or do I need to delete ALL the default swatches first manually, then save the remaining colors in the new swatch library? If so, it makes it a daunting task...

    I watched a tutorial on the Preset Manager and was able to finally select multiple swatches to create a swatch library by using the [Shift] key while selecting.
    One of the problems was that the swatches were displaying as small thumbnails and it was difficult for me to see each swatch selected (plus, the outline of the selections were blue, and many of the colors I selected were blue).
    What also through me off was that when you display swatches in a pane (say, when working on an image), one of the dropdown options is "Save Swatches", which I thought allowed you to save swatches in a library (not just an individual swatch).
    Without the tutorial, I don't think I would have been able to figure out the right steps! Thanks for the tips, guys.

  • How can you create a swatch from a jpeg in Illustrator CS4?

    I am trying to create a jpeg image into a swatch in Illustrator CS4. In previous versions you could simply drag the image into the swatches toolbar and it would convert it automatically. Now when I do that nothing happens. When I click on new swatch it creates a colour swatch instead of the actual image itself.

    When you say you would drag the image itself into the Swatch Palette and it would show the image itself? How would then use this swatch? Can you give an example of what you would apply a jpeg to as a swatch? The only palette that I can think of off the top of my head that you can drag a jpeg into and have the icon appear as the jpeg is the Symbols Palette. Is is possible that you were using the Symbols Palette in the past and not the Swatch Palette?

Maybe you are looking for