Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

97
Vistas
Need an Illustrator JavaScript script to toggle three settings at once and keep them synchronized

I often work with icons and need to quickly check how they look with pixel preview. When I'm building them I have the grid enabled, and artboards visible.

I really want a script that will do the following in one click:

  1. Hide Artboards

  2. Hide all guides

  3. Hide the grid

  4. Toggle Pixel Preview to ON.

And then another script that will exactly reverse the above toggles.

Unfortunately I can't find a way to query the state of the application to determine if artboard borders are already hidden, or if the grid is already hidden, etc.

This is the simple script right now:

//@target illustrator
preferences.setBooleanPreference("ShowExternalJSXWarning", false); // Fix drag and drop a .jsx file

function main() {
   var SCRIPT = {
      name: "Toggle Preview Mode",
      version: "v.0.1"
   };

   if (!documents.length) {
      alert("Error\nOpen a document and try again");
      return;
   }
   app.executeMenuCommand("showgrid");
   app.executeMenuCommand("showguide");
   app.executeMenuCommand("raster");
   app.executeMenuCommand("artboard");
}

try {
   main();
} catch (e) {}

But the problem is if the grid is already hidden, the script will toggle it back on when I want to hide it. Likewise with guides / pixel preview / artboard visibility. Is there a way to query the state of each property?

Basically I want to do this: (excuse the psuedo code)

if(guidesAreHidden=true){ //do nothing }
if(gridIsHidden=true){ //do nothing }
if(pixelPreviewIsOn=true){ //do nothing }
if(artboardsAreHidden=true){//do nothing }

Or a more complex example (Only the grid is hidden):

if(guidesAreHidden=false) { app.executeMenuCommand("showguide"); }
if(gridIsHidden=true){ //do nothing }
if(pixelPreviewIsOn=false){ app.executeMenuCommand("raster"); }
if(artboardsAreHidden=false){ app.executeMenuCommand("artboard"); }

Essentially I need a way to retrieve whether guides/grid/pixel preview/artboard visibility is currently enabled or disabled so I can set the appropriate state of the application.

Any help greatly appreciated.

about 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda