Skip to main content
Shulipa Bernad
Inspiring
March 18, 2020
Question

Check grids in the document:

  • March 18, 2020
  • 1 reply
  • 1272 views

Hello everyone!
Friends I need to open a dialog window with a ckekbox, however, it is necessary to check if in the current document it has grids, if it is true, the chekbox has a true validation "cb1.value = true;". Serial possible? Thanks.

dlg = new Window("dialog"); 
cb1 = dlg.add("checkbox", undefined, undefined, {name: "cb1"}); 
cb1.text = "Checkbox"; 
cb1.value = false;
dlg.show();
This topic has been closed for replies.

1 reply

Legend
March 18, 2020

cb1.value = activeDocument.guides.length 

 

?

 

Shulipa Bernad
Inspiring
March 18, 2020

Hi DmitryEgorov , I need to check "grids" not guids

 
JJMack
Community Expert
Community Expert
March 18, 2020

You will most likely need to use Action Manger javascript coded to get some action reference to check the toggle state of menu View>Show>Grid shortcut Ctrl+' I don't know how to code that. Perhaps R-bin will help.

 

Once you know the toggle state you can toggle the state if you need to.

 

function ToggleGrid() {
    var dialogMode = DialogModes.NO;
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putEnumerated(app.charIDToTypeID('Mn  '), app.charIDToTypeID('MnIt'), app.charIDToTypeID('TgGr'));
    desc1.putReference(app.charIDToTypeID('null'), ref1);
    executeAction(app.charIDToTypeID('slct'), desc1, dialogMode);
};

 

 

 

JJMack