Welcome, Guest. Please Login
Rorohiko Workflow Resources
  Welcome the Message Board of Rorohiko Workflow Resources. To register, please e-mail [email protected] - automatic registration has been turned off because of relentless spambots and spammers. This Message Board is not actively monitored. If you have an urgent question, please e-mail [email protected]. If you post it here, it will probably be many weeks before we notice.
  HomeHelpSearchLogin  
 
Page Index Toggle Pages: 1
Send Topic Print
links(II).update doesn't appear to work from SPLN (Read 9942 times)
Conrad
YaBB Newbies
*
Offline


I Love YaBB 2!

Posts: 6
links(II).update doesn't appear to work from SPLN
05/20/11 at 22:37:47
 
I have an SPLN file that calls a vbs file using the following command:
app.doScript(File("/C/Program Files (x86)/Adobe/Adobe InDesign CS5/Scripts/Scripts Panel/tested/export.vbs"), ScriptLanguage.visualBasic);

This works and calls my export.vbs file.

Within that file I'm collating the linked assets of a document into the same folder as the InDesign file. I then want to relink and update each item in the links collection with the new location before exporting to a PDF.

I'm using the following code:

For II = myDocument.Links.Count To 1 Step -1
     if fso.fileExists(myDocument.links(II).filepath) then
           sFilePath = myDocument.links(II).filepath
           iLastSlash = instrrev(sFilePath, "\")
           sFileName = right(sFilePath, len(sFilepath) - ilastSlash)
           fso.CopyFile myDocument.links(II).filepath, replicatedIDFolder
           fso.CopyFile myDocument.links(II).filepath, inDesignPath
     else
           msgBox("Asset doesn't exist: " & inDesignPath & sFileName)
     end if
     myDocument.links(II).relink fso.getfile(inDesignPath + sFileName)
     myDocument.links(II).update()
Next

When I call the VBS file directly the process works: the files are copied and relinked and the links are updated.
When I call the file from within the SPLN the files are copied and relinked but the links are left in an un-updated state (modified).

Can anyone see anything that I'm doing wrong or is there an issue with the plug-in?

Thanks in advance

Conrad
Back to top
 
 
IP Logged
 
Kris Coppieters
YaBB Administrator
*****
Offline



Posts: 181
New Zealand
Gender: male
Re: links(II).update doesn't appear to work from SPLN
Reply #1 - 05/20/11 at 23:09:26
 
Hi Conrad,

Not sure what could be the cause - but there are slight differences between a script executed as a .SPLN and as a normal script - so it is possible something in the encompassing environment is different. Personally, I'd not put much effort in trying to figure that out - even if you get it working, I think it's still a 'brittle' setup. I'd convert the VBS code to ExtendScript, which would probably fix the problem.

A wild guess: possibly it's something to do with the 'current directory'? I'd add some explicit current directories to the VBS. Not sure if it's a factor, not sure what you should set it to - I'd try setting it to the document's parent directory.

Try inspecting the current directory that's in force in the VBS script in both cases (executed as a standalone vs from inside the spln).
Back to top
 

Kris
WWW  
IP Logged
 
Conrad
YaBB Newbies
*
Offline


I Love YaBB 2!

Posts: 6
Re: links(II).update doesn't appear to work from SPLN
Reply #2 - 05/20/11 at 23:21:19
 
My problem and reluctance to do this is that we (as a team of developers) are much more comfortable in VBScript that ExtendScript (or regular JavaScript even) and we've got close to 500 lines of code to rewrite, including database connections and filesystem checks.

I guess I could break my script up and do all the pre-re-link stuff first, then have the extendscript do the update and then call a second VBS file to do everything else I need.

I assume that the extendscript will wait for a nested VBS file to finish before moving on to the next step?

I appreciate that the way we're approaching this isn't recommended and that I'm operating at the edges of the plug-ins supported scope, thanks for helping.
Back to top
 
 
IP Logged
 
Conrad
YaBB Newbies
*
Offline


I Love YaBB 2!

Posts: 6
Re: links(II).update doesn't appear to work from SPLN
Reply #3 - 05/21/11 at 03:37:15
 
Ok, looks like this is a bug.

Even calling the update function using extendscript within the scripted plug-in doesn't work.

I'm currently doing the following:

Code:
app.doScript(File("/C/Program Files (x86)/Adobe/Adobe InDesign CS5/Scripts/Scripts Panel/tested/export 1.vbs"), ScriptLanguage.visualBasic);

alert("!!");
var vLinks = myDocument.links;
alert(vLinks.length);
for(i=vLinks.length-1; i >= 0; i--){
    alert(i);
    vLinks[i].update();
}
alert("??");
        
//app.doScript(File("/C/Program Files (x86)/Adobe/Adobe InDesign CS5/Scripts/Scripts Panel/tested/testing.js"), ScriptLanguage.javascript);
//app.doScript(File("/C/Program Files (x86)/Adobe/Adobe InDesign CS5/Scripts/Scripts Panel/tested/export 2.vbs"), ScriptLanguage.visualBasic);

 



So I've split my code, VBS does the first pass and all my prep work, the JS does the updating of the links and then my other VB file goes off and does everything else I need it to.

My loop iterates through the links collection but doesn't actually execute the update (or at least the update doesn't do anything).
When I execute this same code directly from within the scripts palette it works.

I've also tried calling the file as a nested js file but that gave the same behaviour.
I'm pretty sure now it's not VBS related. If you can give me some examples of how I'd set the current directory that would be really useful.

Is there anything else I can try?

Thanks
Back to top
 
 
IP Logged
 
Page Index Toggle Pages: 1
Send Topic Print