I have created a code to incrementally increase specific parameters in a model, then save an image file of each. It worked perfectly once I created the code, however, I attempted to run the code the day after, and it ceased to save the image files. It is throwing no errors and is otherwise functioning perfectly. I hope someone on here is able to see something that I cannot.
Here's the code:
function run(context) {
"use strict";
if (adsk.debug === true) {
/*jslint debug: true*/
debugger;
/*jslint debug: false*/
}
var ui;
try {
var app = adsk.core.Application.get();
ui = app.userInterface;
var des = adsk.fusion.Design.cast(app.activeProduct);
var resultFolder = 'C:/Temp/';
var param1 = des.allParameters.itemByName("Length");
var param2 = des.allParameters.itemByName("Depth");
var param3 = des.allParameters.itemByName("Height");
for (var i = 66.0; i < 78.0; i++)
{
param1.expression = i + " in";
for (var j = 21; j < 34.0; j++){
param2.expression = j + " in";
for (var k = 25; k < 25.0; k++){
param3.expression = k + " in";
var filename = resultFolder + param1.expression + "x" + param2.expression + "x" + param3.expression + ".jpg";
app.activeViewport.saveAsImageFile(filename, 0, 0);
}
}
}
ui.messageBox('Finished.');
}
catch (e) {
if (ui) {
ui.messageBox('Failed : ' + (e.description ? e.description : e));
}
}
adsk.terminate();
}
function pad(num, size)
{
var s = num + "";
while (s.length < size)
{
s = "0" + s;
}
return s;
}
Hi,
There is a mistake in your code "for (var k = 25; k < 25.0; k++)" that causes the saveAsImageFile method is never called. Change the code to "for (var k = 25; k < 26; k++)", it will work.
Jack