
spicyDoge
Explorer
spicyDoge
Explorer
Activity
‎Sep 21, 2022
09:53 AM
System: Windows 10, ID version 17.4, Extendscript CC I updated Indesign and it will no longer use Extendscript CC to edit a script, what should I do? System specs are above.
... View more
‎May 07, 2019
07:13 AM
I'm marking this comment as correct as it solved the issue i was having—looping forward instead in reverse—but Marc's approach and explanation is equally as valid and possibly the best way to handle it. It's a little bit out of my 'comfort' zone at the moment, but it makes perfect sense when analyzed. If you arrived here at a later date, be sure to read Marc's reply Re: How to insert text at specific position? to get a handle on whats happening if your insertions points start bouncing backwards.
... View more
‎May 07, 2019
05:52 AM
Thank you for this explanation, This makes perfect sense. As I was vehemently pacing outside last night, racking my brain as to what could be causing this, I realized that somehow the addition of the thinspace character to the total char. count had to be causing the movement of the thinspace itself. It had not dawned on me until uwe's answer that a reverse loop could remedy this. I was going so far as to subract the loop counter from the insertion point which was working 1% better but not correct at all—i had the right idea, just not the correct execution. The reverse loop actually solved the issue for me. However, i like the absolute simplicity of your approach and will give that a go the next time I write a loop. I've always been hesitant to use the old while loop as i sometimes create an infinite loop, but its high-time i bit the bullet and learned how to handle that. You used array.pop, and iirc, it pops off the end of the array which is a reverse loop in itself. Brilliant approach sir.
... View more
‎May 07, 2019
05:03 AM
Thanks Marc, what you said makes sense and is a new way for me to look at what I'm doing. By looking at it, I understand your approach. Would using while instead of the for loop have the same problem as I've indicated above in my post I made a few minutes ago? Does using while negate the need to loop in reverse?
... View more
‎May 07, 2019
04:56 AM
REVERSE... ok something about looping in reverse makes sense. I'm about this close to needing a new keyboard over getting this to work—its so frustrating. The lack of online information available on insertionPoints doesn't help either. Basically, everything works perfect until i add in the insertion point, then things go crazy. The following 2 lines of code work great, the tab is selected 100% of the time. //locate second tab var secondTab=myLine.indexOf('\t', firstTab+1); //select tab myParagraphs .characters[secondTab].select(); Here's where the wackiness begins. From what I've read, an InsertionPoint is the space between characters. so I've used the Data Browser to surmise that, with a tab selected, I have an InsertionPoints.length of 2, one before the tab, one after the tab I assume. So, naturally I would want the first index—[0]. So i fire this line off and things go haywire. app.selection[0].insertionPoints[0].contents = SpecialCharacters.THIN_SPACE; So instead of: (^ = thinspace) A B^ C D A B^ C D It starts going in reverse as indicated below. The first iteration works as intended, then the thinspace starts moving backwards one character . Needless to say this caused me a literal headache. I'll adjust the for loop to run backwards and give it a go. But I'd love to know why in the world is this happening?
... View more
‎May 06, 2019
01:36 PM
Thank you so much for your response. So basically use the tab position to set the insertion point location, correct? I'm not the most familiar with insertionPoints, so im not sure how to assign a value to the insertionPoint[0].
... View more
‎May 06, 2019
09:43 AM
In a nutshell, i know exactly where my tab is by using indexOf to get the position of the tab I want. The problem is I simply cannot find a way to replace the text at that point. Id like to replace "/t" (tab) with "~<\t" (thin space + tab). Ive tried slicing and joining but it removes all my anchored images. Ive tried selecting the tab location then using app.selection[0].changeGrep to replace the text but it only works on the first occurance. I'm stumped, what am I missing here? var myFrames = app.activeDocument.textFrames; //loop through frames for (i=0; i < myFrames.length; i++) { // get all paragraphs var myParagraphs = myFrames.paragraphs.everyItem().getElements(); //loop through paragraphs for (n=0; n < myParagraphs.length; n++) { //get contents of paragraph var myLine = myParagraphs .contents; //find first tab var tablocation=myLine.indexOf('\t'); //find next tab var tablocation=myLine.indexOf('\t', tablocation+1); //select this second tab myParagraphs .characters.itemByRange(tablocation,tablocation).select(SelectionOptions.REPLACE_WITH); // if tablocation is -1 skip it if (tablocation > 1 ) { app.findGrepPreferences = app.changeGrepPreferences = null; app.findGrepPreferences.findWhat = "\\t"; app.changeGrepPreferences.changeTo= "~<\\t"; app.selection[0].changeGrep(); } } }
... View more
‎May 02, 2019
01:09 PM
Ive been at this for days and I've had no luck with this. I'm trying to highlight text that contains an anchored image within it and if the image I'm looking for exists I'd like to replace it. The problem i think I'm having is with the formats—the extensions are different. The existing image is a raster .tif and the one I'd like to swap it with is an .ai vector file. The code below will get me the filenames for both images. The issue is that the file is not getting replaced. Does anyone know what I may be doing wrong? Like i said I've been at this for a few days and maybe I'm overthinking this so far I've gotten myself lost. What's the best way to handle replacing the one image with another? The script is just using the first index of the image I want to replace for now, Ill adjust it later to include more. The .ai needs to be selected as different users will have the replacement file in different locations. // grab the path from the image contained within the selection var my_Tif_Image = app.selection[0].allGraphics[0].properties.itemLink.filePath; //create file object to get its path var new_Ai_Image = File.openDialog ('select image'); //set path A to path B my_Tif_Image = new_Ai_Image; Thanks in advance for your time.
... View more
‎Apr 30, 2019
05:07 AM
thanks one million times for this reply, it was exactly what i couldn't figure out regarding how to skip the first occurrence of the anchor. i appreciate this immensely. I've changed my code to reflect your suggestions and it works as desired for now. var anchoredItems = app.documents[0].stories.everyItem().pageItems.everyItem().getElements(); for( var n=0; n<anchoredItems.length; n++ ) { // If anchored object is first in a text line, do nothing: if( anchoredItems .parent == anchoredItems .parent.lines[0].characters[0] ){ continue }; //get contents of paragraph - cant use just lines because the text is multiline var thistext = anchoredItems .parent.paragraphs.item(0).contents; //grab my index location for insertion var tablocation=thistext.indexOf('\t'); //set up insertion var myIP=anchoredItems .parent.paragraphs.item(0).insertionPoints.item(tablocation+1) ; //move anchor anchoredItems .anchoredObjectSettings.insertAnchoredObject(myIP, AnchorPosition.INLINE_POSITION); }; However i now have another question, which is: is there a better way to move the anchors? You mentioned the move() method but the anchors I deal with are all in-line; move() requires 2 coordinate inputs if I remember correctly. You mentioned the anchor resides as a child of the (Â¥) character in the line? I believe I've moved it previously but once it moves, say via grep, the anchored object, in my case a rectangle object, fails to retain the image placed inside. Whats the best way to handle moving where the anchored object is inserted at while still retaining the contents inside? The way I have it above seems to work fine, but I've been doing this long enough to know there's got to be a better way. As always, thanks in advance for your time, it is greatly appreciated.
... View more
‎Apr 29, 2019
07:48 PM
I have a script (bottom) that I created to move the anchored object insertion points to after the first tab. It works as intended. Here are example lines before and after running the script—(~a1,2,3) would be the anchored objects, (\\t) is a tab. Before: (~a1) foo (\\t) bar (~a2) fizzbuzz (~a3). After: foo (\\t) (~a1) (~a2) (~a3) bar fizzbuzz. However, occasionally there are anchored objects at the beginning of lines that i would like to omit from being moved. Here is the desired format, having moved only the anchors after the first anchored object occurrence. Desired: (~a1) foo (\\t) (~a2) (~a3) bar fizzbuzz. My question is how to isolate only the text and children thereof after the first occurrence of an anchored object? So in other words how can I skip the first anchored object and still move the rest? Thanks in advance for your time. var myanchors = app.documents[0].stories.everyItem().pageItems.everyItem().getElements(); for ( x=0; x<myanchors.length;x++) { var thistext = myanchors .parent.paragraphs.item(0).contents; var tablocation=thistext.indexOf('\t'); var myIP=myanchors .parent.paragraphs.item(0).insertionPoints.item(tablocation+1) ; myanchors .anchoredObjectSettings.insertAnchoredObject(myIP, AnchorPosition.INLINE_POSITION); }
... View more
‎Mar 19, 2019
06:01 AM
I went ahead and created an object, list = {"alpha":"numeral",....); I used the function below to get the value from prop, where the property is the A format and the value is the B format. So getting var list = {object} function getAlphaNumeric(num) { if ( list.hasOwnProperty(num)) { return list[num]; } } that improved the script performance tremendously. issue is going in the opposite way to pull the property from the value. using a for loop and comparing list.valueOf(property) to myValue and returning property takes a pretty long time as well. So the most optimal approach seems to have 2 objects, one "format A:format B" and another "format B:format A" then using the function above to get the xref number. If theres yet a faster way please enlighten me, if this is pretty much as good as it gets i thank you for your help.
... View more
‎Mar 19, 2019
03:01 AM
Thank you for your informative reply. I can merge the two arrays into a key => val format. I was reluctant to take that approach initially as I'm coming from php and there appears to be no such thing as an associative array in JavaScript which is what I need. Is there a better way to handle this than for (key in array)?
... View more
‎Mar 18, 2019
07:03 AM
I have a long list of parts. Each part has 2 different number formats—one numeric, one alphanumeric. Format A (12-234567) is the same part as Format B (ABCD-EFGH-IJKL). I have 2 arrays in a 1:1 correlation with each other, meaning arrayNumeric[1000] and arrayAlphaMumeric[1000] are the same part. The script works as intended but both arrays have a length of about 70k. My issue is there is a 2-5 second lag as the script searches through the arrays. I have the "same" script written in php and apache computes it instantly, so I'm confused as to what the performance issue is. I see there is no IndexOf unless you add it as a prototype, and the code i see to add indexOf is the same as what I wrote. I cannot seem to find a faster way to search through the large arrays. Here's the function I made to search them. function getXref(num) { for ( i = 0 ; i < arrayNumeric.length; i++) { if ( arrayNumeric == num ) { return arrayAlphaMumeric; } } } There seems to be a performance issue regardless of debug level, whether extendscript toolkit is closed or open, or if i write to console or not. So my question is basically what's the best way to handle finding values in large arrays?
... View more
‎Feb 23, 2019
12:41 AM
try myStaticText.removeAll(); then put the static text back in and set the width differently to this new statictext.
... View more
‎Feb 20, 2019
01:43 AM
Hey All, I have experience with Javascript for web development and have some questions about InDesign automation. It's a bit tough to get started with a simple script and started reading the scripting guide and have some questions. InDesign scripts are written, then loaded into InDesign to be executed from the application. You can't run the commands from a command line or other program, right? CORRECT I do a lot of typesetting, using different master pages for different designs. Clients sends us excel files with the fields and records and it would be great to automate this repetitive process. THIS IS POSSIBLE Data merge is useful to some degree but not with multiple master pages. THIS IS POSSIBLE With InDesign scripting, is it possible to read an excel/csv file, select a master page for a given record and then merge the data into the master page? THIS IS POSSIBLE Some master pages have multiple text boxes, can these be targeted from within the scripts? THIS IS POSSIBLE It's a bit tough to get started writing a simple script and looking for something practical and useful for what I do. Any suggestions or resources for this type of use case? with the extendscript toolkit youll find sample scripts to get you started. there's also a reference pdf included. looking at google resources are scarce (goolge: extendscript tutorial pdf) but available. there's a few useful PDF's out there, this forum and stackoverflow, other than that i suppose cash or a solid background in programming could get you somewhere as well. Thanks! YEP
... View more
‎Feb 20, 2019
01:33 AM
1 Upvote
I'd take a stab at helping if i even remotely understood what you were asking, sorry.
... View more
‎Feb 18, 2019
04:48 AM
Corners are rounded by default and unusable at a small dimension in ID 14. Is there a way to get square buttons in the properties somewhere (which i havent seen yet) or is a workaround the only way to solve this? I was considering using panels with event handlers as an option.
... View more
‎Feb 17, 2019
07:04 PM
Try this. https://www.rorohiko.com/wordpress/indesign-downloads/textstitch/ I also write scripts.
... View more
‎Feb 17, 2019
07:00 PM
|| = OR youre essentially saying LET VAR X = THIS OR THAT and that just cant happen.
... View more
‎Feb 14, 2019
02:34 PM
1 Upvote
remove app.pdfExportPreferences.pageRange = PageRange.ALL_PAGES app.pdfExportPreferences.viewPDF = true add var mySettings = app.pdfExportPreferences; with (mySettings) { pageRange = PageRange.ALL_PAGES; viewPDF = true useSecurity = true; viewPDF = true; disallowPrinting = false; disallowCopying = true; disallowChanging = true; changeSecurityPassword = "XXXXXX"; }
... View more
‎Feb 14, 2019
10:29 AM
FWIW my response was exactly to what you asked with the given preset—and a one liner to boot. Any preset listed in your export menu will work in the bold space below. d.exportFile(ExportFormat.pdfType, File(pdfFullName), false, app.pdfExportPresets.item("smallest size_spreads"));
... View more
‎Feb 14, 2019
01:13 AM
1 Upvote
i relay https queries through localhost.
... View more
‎Feb 14, 2019
01:09 AM
1 Upvote
short answer NO. there is only http support as you've found out with the socket class. long answer MAYBE, there are extensions or workarounds you can use. There's an HTTPS extension available, check google. Here's what I did. I use localhost and curl the https site that i want then i query localhost from indesign and get my https page in http. kind of a long way around things, but it works.
... View more
‎Feb 13, 2019
02:31 PM
1 Upvote
Give this a rip d.exportFile(ExportFormat.pdfType, File(pdfFullName), false, app.pdfExportPresets.item("smallest size_spreads"));
... View more
‎Feb 13, 2019
01:50 PM
Here's a quick and easy way to remove style overrides in a document at once. This may not work in all cases but as a general rule it works great in a pinch! Works for all styles! Leave the Find/Change fields blank and add the style you want to remove overrides from into the Find Format options. Enter the same style into the Change Format options. (note, if its not clearing overrides completely try adding character style [None] into the Change Format options) Change at will.
... View more
‎Feb 13, 2019
01:03 PM
I'm taking a wild stab on this..... find .*?: *([^\v]+)\v*.*?: *([^\v]) replace [$]\rFOO\rBAR\r$2\rbiz\rbaz
... View more
‎Feb 11, 2019
11:14 PM
idk where your chapter is, but just grab the object/file & swap the file name. you can use book.fullName and set it to the myChapter.fullName and see if that works
... View more
‎Feb 11, 2019
10:54 PM
Going out on a limb here but it sounds like a windows issue, more specifically win10/8? Just find out where you can add ID as a trusted source, change/check file associations or check the firewall settings. I still run win7 so i cant be of any more assistance, but i can tall ya it's not an ID issue. GL
... View more
‎Feb 11, 2019
09:22 AM
1 Upvote
if youre wanting to consolidate those empty lines, then do the following doc.findGrepPreferences.findWhat = "[\v]+"; doc.findGrepPreferences.changeTo = "\r"; doc.findGrep(); then you can string.slice it using \r, or \r\r if you want to skip the prev step
... View more
‎Feb 11, 2019
04:27 AM
2 Upvotes
Ok i understand now that the row numbers are part of the file. In that case, do something like use grep to them out of the line find:^.*,(.*,.*\r)$ or maybe use firstIndexOf(',') to start the slice after the first comma.
... View more