1. is it possible to extract part of the text from the file path? 6-digit number
2. Button "ok" - do script / Button "Cancel" - do script too(
1. filePath.slice("ish") ?
Example path to part 6digit-number
\\FS\M\200508\ish\bbb\1card.tif to 200508
\\FS\M\200509\ish\a1.tif to 200509
\\FS\M\200601\ish\bl-prok\print\test.tif to 200601
2. Cancel not work at Cancel.
var dlg = new Window('dialog', 'Parametres:');
dlg.frameLocation = [200, 200];
...
dlg.msgPnl.msgHeight = dlg.msgPnl.add('group');
dlg.msgPnl.selectFolder = dlg.msgPnl.add('group');
with (dlg.msgPnl) { ..... }
var bolUserCancel = false;
dlg.buttons2 = dlg.add('group');
dlg.buttons2.btnClose = dlg.buttons2.add("button", undefined , "Ok" );
dlg.buttons2.btnClose.onClick = function() { this.parent.close(0); };
dlg.buttons2.btnCancel = dlg.buttons2.add("button", undefined , "Cancel" );
dlg.buttons2.btnCancel.onClick = function() { bolUserCancel = false; this.parent.close(0); };
dlg.show();
delete dlg;
and my script:
Code: Select all
var strtRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.MM;
var docRef = app.activeDocument;
// filePath = docRef.path; //
var fileName = docRef.name.slice(".")
var dlg = new Window('dialog', 'Parametres:');
dlg.frameLocation = [200, 200];
dlg.msgPnl = dlg.add('panel', undefined, 'Parametres');
dlg.msgPnl.alignChildren = "right";
dlg.msgPnl.Z = dlg.msgPnl.add('group');
dlg.msgPnl.P = dlg.msgPnl.add('group');
dlg.msgPnl.F = dlg.msgPnl.add('group');
dlg.msgPnl.msgHeight = dlg.msgPnl.add('group');
dlg.msgPnl.selectFolder = dlg.msgPnl.add('group');
with (dlg.msgPnl) {
Z.st = Z.add('statictext', undefined, 'Number:');
// Z.et = Z.add('edittext', undefined, '200508');
Z.et = Z.add('edittext', undefined, filePath); // filePath - Full
Z.et.preferredSize = [160,20];
P.st = P.add('statictext', undefined, ' Position:');
P.et = P.add('edittext', undefined, '01');
P.et.preferredSize = [160,20];
F.st = F.add('statictext', undefined, ' File Name:');
F.et = F.add('edittext', undefined, fileName);
F.et.preferredSize = [160,20];
};
var bolUserCancel = false;
dlg.buttons2 = dlg.add('group');
dlg.buttons2.btnClose = dlg.buttons2.add("button", undefined , "Ok" );
dlg.buttons2.btnClose.onClick = function() { this.parent.close(0); };
dlg.buttons2.btnCancel = dlg.buttons2.add("button", undefined , "Cancel" );
dlg.buttons2.btnCancel.onClick = function() { bolUserCancel = false; this.parent.close(0); };
dlg.show();
var Z = parseFloat (dlg.msgPnl.Z.et.text);
var P = parseFloat (dlg.msgPnl.P.et.text);
var F = parseFloat (dlg.msgPnl.F.et.text);
delete dlg;
var W = Math.round(docRef.width);
var H = Math.round(docRef.height);
function SaveAsTIFF( saveAsName ) {
var tso = new TiffSaveOptions();
tso.embedColorProfile = false;
tso.imageCompression = TIFFEncoding.NONE;
tso.byteOrder = ByteOrder.IBM;
docRef.saveAs( File( saveAsName ), tso );
}
docRef.flatten()
SaveAsTIFF ("//FS//M//" + dlg.msgPnl.Z.et.text + "//"+ dlg.msgPnl.P.et.text + "_" + W +"x" + H + "mm_" + dlg.msgPnl.F.et.text );
app.preferences.rulerUnits = strtRulerUnits;