Apakah mungkin untuk menentukan lebar dalam piksel untuk banyak objek sekaligus di Illustrator CS5?


17

Illustrator memiliki dialog 'Transform Each', tetapi hanya memungkinkan Anda untuk menskala beberapa objek dengan menentukan persentase.

Apakah ada cara untuk menentukan ukuran dalam piksel?

Lebih khusus, bayangkan saya memiliki 10 persegi panjang di kanvas saya, dan saya ingin semuanya memiliki ketinggian tertentu. Urutan batang dan posisi pada kanvas penting, jadi saya tidak bisa melakukan trik 'menyelaraskan vertikal ke atas dan kemudian mengubah ukuran ketinggian grup' - mereka perlu diubah ukurannya di tempat.

Jawaban:


11

Ada skrip untuk itu oleh John Wundes yang luar biasa (tidak ada afiliasi).

Ini disebut Atur SEMUA hal , dijelaskan di sini , dan memungkinkan Anda mengatur lebar dan tinggi untuk objek yang dipilih.

masukkan deskripsi gambar di sini

Itu dapat mengatur sejumlah nilai lain untuk item yang dipilih, juga, jika Anda tahu nama untuk mereka (atau, jika Anda mencari nama mereka di Illustrator Scripting Guide atau di posting blog yang terhubung).

Berikut ini tautan unduhan langsung , dan jika karena alasan tertentu tautan itu terputus atau tidak tersedia, inilah kode (Okt 2012) saat ini yang disalin dan ditempel, termasuk catatan bermanfaat John di bagian atas dan pemberitahuan hak cipta asli yang ditambahkan di bagian akhir. Dikatakan CS-CS4 tapi saya sudah bekerja dengan baik di CS5 dan CS6. Semua kredit, hak dll untuk John Wundes.

/////////////////////////////////////////////////////////////////
//  Set All The Things v.1.2 -- CS,CS2,CS3,CS4
//>=--------------------------------------
// Wanna Batch Transform objects?  Illustrator has built in tools to resize each selected item, 
// but only by percentage, not by hard values. I made this script because I could find no
// native way to set the width of all selected objects to 100px at once.
//
// This script can accept multiple parameters at once.
// To change, for instance, both width and height at the same time, 
// at the 'attributes' prompt, enter <b>width,height</b>
// then at the 'values' prompt, enter a comma separated value list like <b>20,30</b>
//  If a single value is passed for 'values', that value will be applied to all chosen properties. 
//
// Common legal parameter names include, but are not limited to: <b>width,height,top,left</b>.
// Install and use <a href='http://wundes.com/JS4AI/#explore.js'>explore.js</a> on an object to see what other properties can be set.
//  
// Update: Based on feedback from user Jode, You are now given the option to transform objects from center. 
// You can now also use whatever standard units you like and the script will convert them into pixels.
//  e.g., you can enter "30mm" or "12in" and the script will know what you mean.
//  v1.2 adds decimal support and explicit 'px' and 'pt' units to the regex. (thanks to Cristofer Cruz for noticing the bug)
//>=--------------------------------------
// JS code (c) copyright: John Wundes ( john@wundes.com ) www.wundes.com
//copyright full text here:  http://www.wundes.com/js4ai/copyright.txt
////////////////////////////////////////////////////////////////// 
var centerObjects= false;
function main(){
    var item,center_point;
    var toPixels=function(v){

    var units={
                        'in':72,
                        'mm':2.8346455078125,
                           'px':1,
                           'pt':1,
            },re = /(\d*[.]*\d+)(mm|in|ft|cm|px|pt)/i,m,u,rep;
        //derivitave
        units['cm'] = units['mm']*10;
        units['ft'] = units['in']*12;

        while(m=v.match(re)){
            u = m[2].toLowerCase();
            if (units[u]){
                rep = (m[1]*units[u]);
                v = v.replace(re,rep);
            }
        }
        return v;
    }

    var trace = function (m){alert(m)};
    if(activeDocument == null){trace("No open document found. Please open a document.");return;}
    if(activeDocument.selection.length == 0){trace("Nothing selected. Please select one or more items.");return;}
    var i = prompt("What attribute(s) do you want to set?","width,height");
    if( i===null ){return false;}
    var v = prompt("What value(s) do you want to assign?","100,50");
    if (v === null ){return false;}
    centerObjects=confirm("Transform Objects around center?");
    v=toPixels(v);
    // here's where we walk through all objects.
    var assign = function (i,v){
        for (var x=0 ; x < activeDocument.selection.length ; x++){

                item = activeDocument.selection[x];
                //get top and left width and height values
                center_point = [item.top-(item.height/2),item.left+(item.width/2)];

            item[i] = eval(v);
            //redraw();
            if(centerObjects){
                //center_point = [item.top+(item.height/2),item.left+(item.width/2)];
                item.top = center_point[0] + (item.height/2);
                item.left = center_point[1] - (item.width/2);
            }
        };
    }
    if(  i.indexOf(',') !== -1){  i =  i.split(',');}
    //split if a list, but not if function is found.
    if( v.indexOf(',') !== -1){ v = v.split(',');}

    if(typeof i !== "string")
    {
        for ( var len=i.length,c=0;c<len;c++)
        {
            assign(i[c],typeof v !== 'string' ? v[c] : v);
        }
    } else
    {
        assign(i,v);
    }
    redraw();
    return true;

}
main();

/*-
 * Copyright (c) 2005 wundes.com
 * All rights reserved.
 *
 * This code is derived from software contributed to or originating on wundes.com
 *
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *        This product includes software developed by wundes.com
 *        and its contributors.
 * 4. Neither the name of wundes.com nor the names of its
 *    contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY WUNDES.COM AND CONTRIBUTORS
 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

2

Menurut Adobe Help , tidak ada.

Anda tidak dapat memasukkan lebar tertentu untuk menskalakan beberapa objek. Di Illustrator, Anda hanya dapat menskala objek dalam pengukuran persentase.


Saya menangis ... Kenapa Adobe ?! Saya memiliki banyak lingkaran dengan ukuran berbeda yang perlu memiliki ukuran yang sama. Bagaimana lagi yang bisa saya lakukan tanpa opsi seperti itu?
A. Vieira

0

Jika Anda semua objek sebenarnya gambar awalnya ditemukan di beberapa direktori, Anda dapat terlebih dahulu mengubah ukurannya dengan imagemagick:

mkdir -p temp_dir
mogrify -resize 80x -path temp_dir *.png

Ini mengubah ukuran semua file png di direktori saat ini untuk memiliki lebar 80px dan menuliskannya ke dalam temp_dirdirektori.

Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.