The application has two files open" Source_l.ai" and "Dest_l.ai". I want to change the active document, and the active layer, of the active document through the UI "palette", the code of which is given below.
Two Checkboxes, "CheckSourse" and "CheckDest" are responsible for changing the active document of the application, whose functionality I'm trying to configure ....
Does anyone know how to write the correct code for such a switch?
-----------------------------------------------------------------------------------------------------------------------
#target Illustrator;
#targetengine main;
app.documents.getByName("Source_l.ai").activate();
app.activeDocument.activeLayer = app.activeDocument.layers[0];
app.redraw();
function WinObject() {
var windowResource = "palette { text: 'Devide PathItems', panelSNumObjects: Panel { orientation:'row', spacing:0, margins:10, text: 'Goal', Group1: Group { orientation:'row', spacing:16, margins:5, CheckSourse: Checkbox { alignment:'center', text:'S.', value:true}, st: StaticText { text:'0', characters:3 }, }, Group2: Group { orientation:'row', spacing:16, margins:5, CheckDest: Checkbox { alignment:'center', text:'D.', value:false }, st: StaticText { text:'0', characters:3 }, }, }, panelDevide: Panel { orientation:'row', spacing:10, margins:10,text: 'Devide', et: EditText { text:'0', characters:2, alignment:'center' }, CheckSel: Checkbox {alignment:'center', text:'Sel.', value:true ,},CheckAuto: Checkbox {alignment:'center', text:'Auto.', value:false},buttonDev: Button { text:'D', alignment:['center', 'center']},}, buttonUpdate: Button { text:'Update', alignment:['center', 'center']}, buttonExport: Button { text:'Export', alignment:['center', 'center']}, ButtonClose: Button { text:'Close', alignment:['center', 'center']}}";
var win = new Window(windowResource);
win.ButtonClose.onClick = function() { win.close() };
win.panelSNumObjects.Group1.CheckSourse.onClick = function () {
win.panelSNumObjects.Group1.CheckSourse.value = true;
win.panelSNumObjects.Group2.CheckDest.value = false;
setDocument('Source_l.ai', 0);
};
win.panelSNumObjects.Group2.CheckDest.onClick = function () {
win.panelSNumObjects.Group1.CheckSourse.value = false;
win.panelSNumObjects.Group2.CheckDest.value = true;
setDocument('Dest_l.ai', 1);
};
function setDocument(documentName, layerIndex) {
app.documents.getByName(documentName).activate();
app.activeDocument.activeLayer = app.activeDocument.layers[layerIndex];
app.redraw();
}
win.show();
};
var message = WinObject.toString();
message += "\nnew WinObject();"
var bt = new BridgeTalk();
bt.target = "illustrator";
bt.body = message;
bt.send();
---------------------------------------------------------------------------------------------------