Forum Replies Created
-
AuthorPosts
-
Loic Aigon
MemberA script could certainly achieve this. However it would require to either know the exact adress (so the script can look for it) or that the adress matches a certain regular pattern (so the script can find occurences via GREP).
March 22, 2018 at 11:26 am in reply to: JS to delete old style and replacing it wih new one. #102587Loic Aigon
MemberHi,
While I certainly agree to the concept of being generous (as I try to always be), I am not disturbed by the idea of offering paid-for services to certain conditions. The reason is that sometimes people, naively or worse willingly will ask for huge piece of scripts that will ease their work. I do a difference between one asking for advice in his own development effort (this one should be encouraged and helped by community) and the one just saying, I need this please (and now).
At this stage, it should be everyone conscience to either deliver for free (I do it more than often) or say you know what, the script i could write and that you are not trying to develop on your own could save you a lot of efforts and money, so that would be fair to get some money out of it (I help you, it helps me).
The only thing that annoy me is when those offers of services are strongly and publicly repeated all over the place. When I do on a few occasions, I do send private message and I don’t judge the emitter. I just offer, you take it or leave it, no problem.
And eventually, we, developers, have regular clients who can pay a lot for scripts and I don’t think they would enjoy seeing the same code delivered for free. So clearly when I provide some code, it’s either because emitter tried something first, or the expectation is low, or that I am in a really good mood (i.e. all stars aligned).Loic Aigon
MemberLoic Aigon
MemberAP STyle ?
Loic Aigon
MemberIndeed, the forum engine did replace some characters thus corrupting the script.
To answer your questions :
1 – What does box.panel2.group.resizeObj.enabled = false; actually do/mean?
The underlaying idea is to make the action button non clickable if the user hasn’t entered any valid number. That’s a convenient way of preventing bugs and force user to check twice what he is typing in. The button will become clickable if the user enters a valid number.2 – what does the 1 in the box.close(1); / box.show()==1 ) actually do/mean?
This is a return code that helps you knowing which button did the user actually click. In your case you have only one button, but you could have two or three and it’s convenient to ensure user did click on “run” button.3 – where you reference the co-ordinates at the end. listed below. Do you need to list the coordinate spaces first or would it also work just reference anchorpoint, If so is there a benefit to doing this?
No you need to set the coordinate space first because it will let the script knows in which system has the geometry to be executed. Actually this is well documented:
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#PageItem.html#d1e207514__d1e210583Note that the script isn’t bullet proof in the sense that objects could be locked or on a locked layer…
Loic Aigon
MemberMy pleasure,
Feel free to get in touch at ozalto (dot) com. Maybe your “complex” folder organization has not to be and there are some further consulting I could offer ;)
Loic Aigon
MemberI see.
Try this :
//MAIN ROUTINE /* Change path in aFolder so it matches your own folder path Change canSelectMultiple if needed to true to allow multiple file selection Change exts to include more file types as ex: ["indt","indd",idml"] Then run… */ var main = function() { //==============VARS==============// var aFolder = Folder ( '/change/path/to/point/your/folder/path' ), m = $.os[0]=="M", exts = ["indt"], mf = function(f){return (f instanceof Folder)||RegExp("\.("+exts.join("|")+")$" ).test(f.name);}, wf = "Indesign Templates:*.indt", filter = m? mf : wf, canSelectMultiple = false, indtFile; //requesting file selection indtFile = aFolder.openDlg('Please pick a file', filter, canSelectMultiple); //Exit if no selection if ( !indtFile ) return; //Opening selection app.open ( indtFile ); } //Run script main();Loic Aigon
MemberI realized I removed the control on the applied Object style but you will easily set that back.
Loic Aigon
MemberA possible improvement:
var pageWidth = app.activeDocument.documentPreferences.properties.pageWidth;
var widthRounded = Math.round(pageWidth);
var pageHeight = app.activeDocument.documentPreferences.properties.pageHeight;
var heightRounded = Math.round(pageHeight);var box = new Window('dialog', "Resize Document");
box.panel = box.add('panel', undefined, "Enter Percentage to resize");
var resizePer = box.panel.add('edittext', undefined, "");
/*
resizePer.onChanging = function(){
if ( !/\d+/.test ( resizePer ) ) {
return;
}
$.writeln( ">"+resizePer.text );
}*/resizePer.addEventListener ("keydown", function (k) {
if (
!/\d/.test( k.keyName )
|| resizePer.text.length==3
|| (resizePer.text.length==0 && k.keyName=="0" )) {
k.preventDefault();
k.stopPropagation();
box.panel2.group.resizeObj.enabled = false;
}
});resizePer.addEventListener ("keyup", function (k) {
box.panel2.group.resizeObj.enabled = resizePer.text.length>0;
});resizePer.value = true;
resizePer.characters = 14;
resizePer.active = "true";box.panel2 = box.add('panel', undefined, "Current FIle Dimensions");
box.panel2.group = box.panel2.add('group', undefined, );
box.panel2.group.orientation='column';box.panel2.group.text1 = box.panel2.group.add('statictext', undefined, "Page Width:"+widthRounded+"mm");
box.panel2.group.text1 = box.panel2.group.add('statictext', undefined, "Page Height:"+heightRounded+"mm");
box.panel2.group.resizeObj = box.panel2.group.add('button',undefined, "Proceed");
box.panel2.group.resizeObj.onClick = function(){
box.close(1);
}
box.panel2.group.resizeObj.enabled = false;if ( box.show()==1 ) {
var doc = app.activeDocument;
var myObjectStyle = doc.objectStyles.itemByName("RoundalFrame");
var myScaleFactor = Number ( resizePer.text )/100;
var doc = app.activeDocument;
const CS = CoordinateSpaces.INNER_COORDINATES;
const AP = AnchorPoint.CENTER_ANCHOR;
const RM = ResizeMethods.MULTIPLYING_CURRENT_DIMENSIONS_BY;doc.pageItems.everyItem().resize ( CS, AP, RM, [myScaleFactor, myScaleFactor] );
}
Loic Aigon
MemberresizePer isn’t a number when you want to use it. It’s a reference to a scriptUI component.
At the very least resizePer.text would return the contents of the input. But to proper use it I would force convert it to a number: Number(resizePer.text);
Eventually you should add a control over typing in to ensure, nothing but numbers can be typed in.Loic Aigon
MemberI am probably missing something, how the script you seem to describe would differ from the regular open file command ?
Loic Aigon
MemberI second David and as a more personal opinion, I tend to use external logging myself (writing to a log file). $.writeln instructions may be really performance consuming especially in large loops.
Loic Aigon
MemberHi Vasha,
EasyCatalog is a good option to me. Can ingest Excel files as inputs or even link to your database. Much more flexible than datamerge especially for huge catalogs projects.
Feel free to get in touch with us at ozalto.com for more details.
Loic
-
AuthorPosts
