Copy link to clipboard
Copied
Hello,
I have a graph that is dynamic. I already have a variable set up and also a dataset. This file is saved.
Basically, I am trying to write some code that will open the document, import the variable file (with the new data from the xml file) and then update the graph.
Using the code below, the file opens and also the import of the variables is succesful. However, the graph is not updating automatically. I need to actually select the value from the dropdown in the variables window. Can anyone please tell me what I am doing wrong.
// Open the file and import the datasets and variables from xml file
var docRef = open(new File(aiChartFilePath));
alert("Importing the datasets.");
docRef.importVariables(new File(xmlFilePath));
var ds1 = docRef.dataSets.getByName("Chart1Variable");
alert(ds1); //this gives the "DataSet Chart1Variable"
docRef.activeDataset = ds1;
ds1.display();
redraw();
rs = "OK";
Thanks in advance for your help.
This should be it ... my original code was a lil bit messy cause was written in a hurry ![]()
#target indesign
function main() {
if (app.documents.length == 0) {
alert("Please have an 'Indesign' document before running this script.");
return;
}
var docRef = app.documents[0];
$.sleep( 3000 ); // Just my novice delay method
updateGraph();
$.sleep( 3000 ); // Ditto here
//updateGraph();// done this twice because there seems to be a bug where the dataset is not getting updated first time around
$.sleep( 3000 );
//} /
Copy link to clipboard
Copied
Hi Sonic,
THANKS!!! Finally it worked. I had to increase the sleep time but once I did that everything works.
Copy link to clipboard
Copied
Hello,
would you mind providing as attachment the .ai file and the xml file? I'll look into it a lil bit later as i dun have time right now. Problem lies probably somewhere in the variable binding ...
cheers;
Copy link to clipboard
Copied
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more