Automatic measures only 1 color ink (modification of the script)

Hi all

I need to modify this script as well as bring the measure already in are... PANTONE Pantone 485 (solid coated),

I need to change this string, but do not know how...

Thank you very much

line color measurement

var color = new RGBColor;                                              How to change it, to the ink pantone...?

255 = Color.Green;

0 = Color.Blue;

/*
* Description: An Adobe Illustrator script that automates measurements of objects. This is an early version that has not been sufficiently tested. Use at your own risks.
* Usage: Select 1 to 2 page items in Adobe Illustrator, then run this script by selecting File > Script > Other Scripts > (choose file)
* License: GNU General Public License Version 3. (http://www.gnu.org/licenses/gpl-3.0-standalone.html)
*
* Copyright (c) 2009. William Ngan.
* http://www.metaphorical.net
*/


// Create an empty dialog window near the upper left of the screen 
var dlg = new Window('dialog', 'Spec');
dlg.frameLocation = [100,100];
dlg.size = [250,250];


dlg.intro = dlg.add('statictext', [20,20,150,40] );
dlg.intro.text = 'First select 1 or 2 items';


dlg.where = dlg.add('dropdownlist', [20,40,150,60] );
dlg.where.selection = dlg.where.add('item', 'top');
dlg.where.add('item', 'bottom');
dlg.where.add('item', 'left');
dlg.where.add('item', 'right');


dlg.btn = dlg.add('button', [20,70,150,90], 'Specify', 'spec');






// document
var doc = activeDocument;


// spec layer
try {
          var speclayer =doc.layers['spec'];
} catch(err) {
          var speclayer = doc.layers.add();
          speclayer.name = 'spec';
}


// measurement line color
var color = new RGBColor;
color.green = 255;
color.blue = 0;


// gap between measurement lines and object
var gap = 2;


// size of measurement lines.
var size = 10;


// number of decimal places
var decimals = 0;


// pixels per inch
var dpi = 72;


/**
          Start the spec
*/
function startSpec() {
  
          if (doc.selection.length==1) {
                    specSingle( doc.selection[0].geometricBounds, dlg.where.selection.text );
          } else if (doc.selection.length==2) {
                    specDouble( doc.selection[0], doc.selection[1], dlg.where.selection.text );
          } else {
                              alert('please select 1 or 2 items');
          }


          dlg.close ();
}








/**
          Spec the gap between 2 elements
*/
function specDouble( item1, item2, where ) {
  
          var bound = new Array(0,0,0,0);


          var a =  item1.geometricBounds;
          var b =  item2.geometricBounds;
  
          if (where=='top' || where=='bottom') {
  
                    if (b[0]>a[0]) { // item 2 on right,
  
                              if (b[0]>a[2]) { // no overlap
                                        bound[0] =a[2];
                                        bound[2] = b[0];
                              } else { // overlap
                                        bound[0] =b[0];
                                        bound[2] = a[2];
                              }
                    } else if (a[0]>=b[0]){ // item 1 on right
  
                              if (a[0]>b[2]) { // no overlap
                                        bound[0] =b[2];
                                        bound[2] = a[0];
                              } else { // overlap
                                        bound[0] =a[0];
                                        bound[2] = b[2];
                              }
                    }


                    bound[1] = Math.max (a[1], b[1]);
                    bound[3] = Math.min (a[3], b[3]);
  
          } else {
  
                    if (b[3]>a[3]) { // item 2 on top
                              if (b[3]>a[1]) { // no overlap
                                        bound[3] =a[1];
                                        bound[1] = b[3];
                              } else { // overlap
                                        bound[3] =b[3];
                                        bound[1] = a[1];
                              }
                    } else if (a[3]>=b[3]){ // item 1 on top
  
                              if (a[3]>b[1]) { // no overlap
                                        bound[3] =b[1];
                                        bound[1] = a[3];
                              } else { // overlap
                                        bound[3] =a[3];
                                        bound[1] = b[1];
                              }
                    }
  
                    bound[0] = Math.min(a[0], b[0]);
                    bound[2] = Math.max (a[2], b[2]);
          }
          specSingle(bound, where );
}




/**
          spec a single object
          @param bound item.geometricBound
          @param where 'top', 'bottom', 'left,' 'right'
*/
function specSingle( bound, where ) {


  
          // width and height
          var w = bound[2]-bound[0];
          var h = bound[1]-bound[3];


          // a & b are the horizontal or vertical positions that change
          // c is the horizontal or vertical position that doesn't change
          var a = bound[0];
          var b = bound[2];
          var c = bound[1];
  
          // xy='x' (horizontal measurement), xy='y' (vertical measurement)
          var xy = 'x';
  
          // a direction flag for placing the measurement lines.
          var dir = 1;
  
          switch( where ) {
  
                    case 'top':
                              a = bound[0];
                              b = bound[2];
                              c = bound[1];
                              xy = 'x';
                              dir = 1;
                              break;
  
                    case 'bottom':
                              a = bound[0];
                              b = bound[2];
                              c = bound[3];
                              xy = 'x';
                              dir = -1;
                              break;
  
                    case 'left':
                              a = bound[1];
                              b = bound[3];
                              c = bound[0];
                              xy = 'y';
                              dir = -1;
                              break;
  
                    case 'right':
                              a = bound[1];
                              b = bound[3];
                              c = bound[2];
                              xy = 'y';
                              dir = 1;
                              break;
  
          }


          // create the measurement lines
          var lines = new Array(); 
  
          // horizontal measurement
          if (xy=='x') {
  
                    // 2 vertical lines
                    lines[0]= new Array( new Array(a, c+(gap)*dir) );
                    lines[0].push ( new Array(a, c+(gap+size)*dir) );
                    lines[1]= new Array( new Array(b, c+(gap)*dir) );
                    lines[1].push( new Array(b, c+(gap+size)*dir) );
  
                    // 1 horizontal line
                    lines[2]= new Array( new Array(a, c+(gap+size/2)*dir ) );
                    lines[2].push( new Array(b, c+(gap+size/2)*dir ) );
  
                    // create text label
                    if (where=='top') {
                              var t = specLabel( w, (a+b)/2, lines[0][1][1] );
                              t.top += t.height;
                    } else {
                              var t = specLabel( w, (a+b)/2, lines[0][0][1] );
                              t.top -= t.height;
                    }
                    t.left -= t.width/2;
  
          // vertical measurement
          } else {
  
                    // 2 horizontal lines
                    lines[0]= new Array( new Array( c+(gap)*dir, a) );
                    lines[0].push ( new Array( c+(gap+size)*dir, a) );
                    lines[1]= new Array( new Array( c+(gap)*dir, b) );
                    lines[1].push( new Array( c+(gap+size)*dir, b) );
  
                    //1 vertical line
                    lines[2]= new Array( new Array(c+(gap+size/2)*dir, a) );
                    lines[2].push( new Array(c+(gap+size/2)*dir, b) );
  
                    // create text label
                    if (where=='left') {
                              var t = specLabel( h, lines[0][1][0], (a+b)/2 );
                              t.left -= t.width;
                    } else {
                              var t = specLabel( h, lines[0][0][0], (a+b)/2 );
                              t.left += size;
                    }
                    t.top += t.height/2;
          }
  
          // draw the lines
          var specgroup = new Array(t);
  
          for (var i=0; i<lines.length; i++) {
                    var p = doc.pathItems.add();
                    p.setEntirePath ( lines[i] );
                    setLineStyle( p, color );
                    specgroup.push( p );
          }


          group(speclayer, specgroup );


}




/**
          Create a text label that specify the dimension
*/
function specLabel( val, x, y) {
  
                    var t = doc.textFrames.add();
                    t.textRange.characterAttributes.size = 8;
                    t.textRange.characterAttributes.alignment = StyleRunAlignmentType.center;


                    var v = val;
                    switch (doc.rulerUnits) {
                              case RulerUnits.Inches: 
                                        v = val/dpi;
                                        v = v.toFixed (decimals);
                                        break;
  
                              case RulerUnits.Centimeters:
                                        v = val/(dpi/2.54);
                                        v = v.toFixed (decimals);
                                        break;
  
                              case RulerUnits.Millimeters:
                                        v = val/(dpi/25.4);
                                        v = v.toFixed (decimals);
                                        break;
  
                              case RulerUnits.Picas:
                                        v = val/(dpi/6);
                                        var vd = v - Math.floor (v);
                                        vd = 12*vd;
                                        v =  Math.floor(v)+'p'+vd.toFixed (decimals);
                                        break;
  
                              default:
                                        v = v.toFixed (decimals);
                    }
  
                    t.contents = v;
                    t.top = y;
                    t.left = x;
  
                    return t;
  
}


function setLineStyle(path, color) {
                    path.filled = false;
                    path.stroked = true;
                    path.strokeColor = color;
                    path.strokeWidth = 0.5;
  
                    return path;
}




/**
* Group items in a layer
*/
function group( layer, items, isDuplicate) {
  
          // create new group
          var gg = layer.groupItems.add();


          // add to group
          // reverse count, because items length is reduced as items are moved to new group
          for(var i=items.length-1; i>=0; i--) {
  
                    if (items[i]!=gg) { // don't group the group itself
                              if (isDuplicate) {
                                        newItem = items[i].duplicate (gg, ElementPlacement.PLACEATBEGINNING);
                              } else {
                                        items[i].move( gg, ElementPlacement.PLACEATBEGINNING );
                              }
                    }
          }
  
          return gg;
}








// ----------------------------------------------------------------------------------------------------------------------------------------


dlg.btn.addEventListener ('click', startSpec );
dlg.show();

As a first step, you must necessarily swatches Pantone in your document.

Then it's easy:

Change this:

// measurement line color
var color = new RGBColor;
color.green = 255;
color.blue = 0;

to do this:

// measurement with Pantone line color
var color = doc.swatches.getByName('Pantone 485 C').color

That's all.

Tags: Illustrator

Similar Questions

  • Is there a way to change the color layer tag via the Script?

    I tried to use the listener from Script to find the event to change the color of the layer tag, but there is no order saved on my desktop. I've scoured the forums and the depths of huge... ooogle and nothing is helping.

    I checked the API for an Art Layer and found no option to assign a color label.

    I want to change the color tag of the:

    Capture.JPG

    The purple color of the tag:

    Capture2.JPG

    Could someone please help point me in the right Direction?

    Just solved my own question:

    Photoshop has been weird so I had to change the color 2 times for the event must be recognized... idk why but it worked: here is the code:

    desc66.putReference (idnull, ref55);

    idT var = charIDToTypeID ("T");

    var desc67 = new ActionDescriptor();

    var idClr = charIDToTypeID ("Clr");

    var idClr = charIDToTypeID ("Clr");

    var idVlt = charIDToTypeID ("Vlt");

    desc67.putEnumerated (idClr, idClr, idVlt);

    var idLyr = charIDToTypeID ("Lyr");

    desc66.putObject (idT, idLyr, desc67);

    executeAction (idsetd, desc66, DialogModes.NO);

  • Modification of the Script label

    Hello

    I've been watching the script of the label provided with InDesign CS3 and I made a few small changes, but I am confused on how I can remove the drop down menus to apply a Swatch and Style apply, I want that just use 1 swatch and 1 model I made?

    can someone help me with that please?

    Concerning

    Seth

    JavaScript is not a standard feature, so you'll have to make your own:

    function padToFour(number) {
      if (number<=9999) { number = ("000"+number).slice(-4); }
      return number;
    }
    

    (sidenote, I wonder who wrote the original scripts for adobe examples)

  • OfficeJet Pro 8600 always in color ink

    I have 4 computers, printing on this printer and I put printing preferences on all levels of grey: black ink only, yet I am still uses ink of color for a reason any.  All faxes and copies that are made on the machine are in BLACK.  Please help me understand this.  Y at - it a setting I'm missing?

    There are a few things to check.  Some ink will be used to keep the "plumbing" and clear print heads.  If you never run cleaning cycles (in the front panel or computer palette) ink will use black and all colors.  If the printer is off of an external switch that will serve the most ink - the printer must always be connected to a live outlet.  Finally, when you automatically print duplex some color ink will be used on the first page to set the ink more quickly so that the ink will not smear when the page is pulled back into the printer.

    The document described here how the ink is used.  In the terminology of this document the 8600 Officejet Pro is an IIC printer.

  • Is it possible to embed a color profile when using the assets to generate?

    I'm looking for a command to integrate the profile of my production of images with generator anywhere and I'm not having any luck. Anyone know if this is possible? So far, my only work-around is to assign the script profile, but what to do with thousands of png is taken way too long. Please tell me there is a simple bit of syntax, that I can add to my folder names.

    Thank you!

    I don't think that the format file used by the generator code can currently include a color profile.

  • Photosmart 7520: Preference avancΘs, change the default settings, print using ONLY black ink (not color ink)

    Where can I find this that all information in the preferences > advanced, what they mean, how and why.

    How to permanentely to change the default printer settings.

    How to use out of the black cartridge for everything I print (I do not want to use ANY) color ink.

    Hi TJBar,

    This link should give you the information you need to explain the menu print, print menus. In order to print in black only, you can select "print in black and white." Note, however, that color will be used during maintenance of your printer. This is necessary to prevent the healthy color ink for when you do not need to use it.

    Please let me know if it helps.

    Thank you very much

    Michaele

  • HP 4500 All In One Envy... Print from the cartridge color only when black ink is low...

    Is it possible to print with the cartridge color only if the black cartridge is low or outside? I have the HP Envy 4500 e All in One... What can I do?

    Hello

    You can use the color ink only by removing the small black cartridge.

    You can find the next steps in his guide of the user as a reference:

    Use single-cartridge
    Use single-cartridge use the HP ENVY 4500 series with only one cartridge. The
    mode Single-cartridge begins when an ink cartridge is removed from the distribution of ink cartridges.

    on the printer screen.

    Shlomi

  • HP Laser Jet Pro CM1415 can only you by default for all print in black to save color ink?

    My impression is text I want to print using black ink only.  I tried using shades of gray, but ran out of all my color cartridges and still have 70% of black left!  Is there a way to get the printer to use only black ink, unless I said to use the color (for photos) so that my color ink will last longer?

    If you use the "Print in grayscale" checkbox in the properties of the printer, which will force the printer to use only the black toner.  You can check by looking at the page printed under magnification.

    Of course if your photos are full page that will use much more ink than, say, 5 x 7.  If you are printing photos on glossy paper rather than the typical plain paper, which will tend to use a little more toner.  Keep in mind that yields of the cartridge is based on the coverage is low (such as text), and the photos have a much higher than the text coverage.  I'm curious about how many photos and what size, don't you think that you have printed this year?

  • Only 1 HP Officejet Pro 8000 color ink prints

    I changed all three color ink cartridges, but only one color, prints magenta (and black). I cleaned the heads, but again only black and magenta show.

    Hello RobertHuntley.

    The last option would be to contact Customer Service to see if there is something else that the printhead causing the problem. I've included a link to the contact information for your printer.

    I wish you the best. Sorry I couldn't do more to help.

    -Chauntain

  • HP Vivera Photosmart 3210: EXPIRY of the INK. can buy black ink only and print n &amp; B with the range of printers hp Vivera 3210?

    all ink has expired. can I buy only black ink and print n & b with hp Vivera printer, photosmart 3210 all-in-one

    and black and white printing only with color expired ink in there?

    Hi @peanut7949,

    I believe, with this model, you can continue printing with inks has expired. That being said, if you replace only the black ink and continue to print with others (expired), it should be fine.

    Here's what I could find on the subject:

    Each ink cartridge has an expiration date to protect the printing system and ensure a good quality ink. The cartridge expiration date appears on line 53 of the free test report.

  • OfficeJet Pro 6830: color ink is not printing

    We just received our 6830 Officejet Pro a few months ago and feel sometimes but not often. Yesterday when I tried to print, printed only black things on the page. None of the colorful text printed at all - not even in a different color or a shade - so it appears none of the color ink cartridges has been used. The printer indicates that all four cartridges are about 50% full.

    Things that I've checked or tried:

    The computer has the choice of the color selected.

    Color copy gives the same result - no color.

    I checked the vents and they don't seem to be blocked. I stuffed them with a needle just to be safe.

    I hit the bottom of the cartridges where the ink comes out and ink on my fingers. They are not dry.

    I'd clean the print heads.

    I tried putting the printer off, and then restarting the computer.

    The "test page" and the "print quality diagnostics page" do not print with any color either.

    The printer indicates that it not there no new updates.

    Color printing perfectly fine a few weeks ago, no sign cartridges drying up. It is under warranty, but it's our third of these printers and really, I prefer not to be yet another replacement if it is possible to solve this problem! (The first two were a high pitched noise all the time while it is plugged). Thanks in advance for advice.

    After the execution of the cycle 'cleaning print head' repeatedly, the color ink is now working!

  • Office Jet 6600: How to print black with color ink run out?

    How can I print black with color ink are empty? (I have gone to properties... black and white only... and allow black ink only a few times, but I get the options for onlinr purchases, cancel printing or help.)

    When I click on it help States I can print with the depleted cartridges, but it doesn't tell me how. Can someone please?

    Hello

    For your printer, it is only possible to print only in black when the other cartridges are exhausted.

    If you want to know more about it please check the document below

    http://support.HP.com/us-en/product/HP-OfficeJet-6600-e-all-in-one-printer---H711a/H711g/4322968/model/4323587/document/c04331666

    Thank you

    I am an employee of HP, these messages are consistent with my knowledge and HP is not responsible.
    By clicking on the star of congratulations in the post helped you to say thanks.
    Please indicate the position that solved your problem as accepted Solution

    I work for HP

  • Select start measurment only if the temperature is less than 26 ° C for 10 seconds

    Hello

    I have a program for a measure of viscosity/temperature use DasyLab 12

    I burn my brain to try to activate the measurment only if the temperature is less than 26 ° C for 10 seconds.

    Click on 'Start', then control the temperature, if the temperature stay below 26 ° C, for 10 sec then allow to click the button "start measurment.

    If this isn't the case, restart the control.

    Thanks in advance!

    Ivan

    Simply enter the channel number. If this string has a name, DASYLab will automatically replace the figure.

  • Color ink cartridge exhausted more quickly

    Hello

    I recently bought 2515 HP color inkjet printers. The color cartridge is depleted fast [60 printed pages] even under fast draft with impressions of color cover 25%. While HP promises 160 pages per color cartridge when purchasing this product. In fact, this model is known ink printer advantage!.

    Can someone help me?

    Hello
    That is expected for a 25% coverage of color print, HP promises about 200 printing pages with a tricolor 650 ink cartridge color based on ISO 24711, which is equivalent to an average of 5% coverage per page, taking into account the high ink coverage you described quite should be terminated after fewer pages.

    You can learn more about how ink usage is measured in the following article:

    http://h10060.www1.HP.com/pageyield/en-150/articles/inkjetPageYields.html?cCode=IL

    Kind regards

    Shlomi

  • Tek MSO4104 - Programatically display automatic measurements

    I am trying to program my MSO4104 Tek to display programmatically automatic measures, such as the peak-to-peak amplitude, etc.. I can do on the front panel of the range, and I can read back the values I want via VISA, however, I can't find the command to add measures to the screen on the field programmatically.

    Let me rephrase... I think that the only way that would work to simulate the front and button keys running using the VISA controls: "FPanel: Press ' and 'FPanel:Turn'... but it's medium heavy... it seems that it MUST be a single command to add an automatic measurement of the Pk2Pk to the screen!


Maybe you are looking for

  • iPhoto import JPG (unrecognized format)

    I got a new imac and try to import some picture to my external drive imac. Process as below: 1. move the photo Mac locate drive 2. slide the photo album Everything works well except those files with "JPG", appearing as "Format not recognized", please

  • Photo editing tools

    It will be possible to 'Edit' the editing tools?  Change their order and eliminate some of them which I don't use?

  • Bluetooth not working not not after upgrade to El Capitan Yosemite

    Simple really. I upgraded to El Capitan Yosemite yesterday. Before the upgrade all the bluetooth was working fine. Now, it is not the case. No devices appear in the devices window. Thanks for any help Robert "it works"? MBP15 mid 2012

  • I forgot the responses of the security issue

    I forgot my security question answers and is not an emergency email. What should I do?

  • HP Mediasmart SmartMenu stop working ERROR

    Hello please help me fix my computer problem at about the mediasmart smartmenu stop working IM using the HP Pavilion p6140d, windos vista 32 bit desktop PC and the error is HP MediaSmart SmartMenu stop working, please help me solve this problem