I am still going a little nutty trying to understand OBJECTS within DOPUS, especially the clickData, cmdData, and the newest one I found in my research, the scriptCmdData.
So first, I am generally a little confused about how to best setup my addin script. I had it working pretty well, but then I keep having issues with the cmd.addFiles() (throwing automation error).
So first basic setup question
This is the init section of my add-in:
function OnAddCommands(addCmdData) {
var cmd1 = addCmdData.AddCommand();
cmd1.name = "Z_collectNoCPFiles";
cmd1.method = "Z_collectNoCPFiles";
cmd1.desc = "Z_collectNoCPFiles";
cmd1.label = "Z_collectNoCPFiles";
var cmd2 = addCmdData.AddCommand();
cmd2.name = "Z_normalizeSeriesSuffix";
cmd2.method = "Z_normalizeSeriesSuffix";
cmd2.desc = "normalize random Series Suffix";
cmd2.label = "Z_normalizeSeriesSuffix";
var cmd3 = addCmdData.AddCommand();
cmd3.name = "Z_collectSeriesFiles";
cmd3.method = "Z_collectSeriesFiles";
cmd3.desc = "Z_collectSeriesFiles";
cmd3.label = "Z_collectSeriesFiles";
}
***I know this can be done with FIND and FILTERS in DOPUS, but I do lots of other processing to each file.
Here is one of the basic function/command definitions:
function Z_collectNoCPFiles(scriptCmdData) {
var cmd = scriptCmdData.func.command;
var srcColl = "MYCOLL";
var destColl = "noCP";
var srcEnum = DOpus.FSUtil.ReadDir('coll://' + srcColl, true);
var chunkSizeMax = 5;
while (!srcEnum.complete) {
var collItem = srcEnum.Next();
if (collItem.is_dir) continue;
var filesToCopy = [];
var allConditions = !collItem.is_dir && validCount < addToCollLimit
if (allConditions) {
filesToCopy.push(collItem.realpath);
if (filesToCopy.length <= chunkSizeMax) {
cmd.AddFiles(filesToCopy);
} else {
cmd.RunCommand('Copy TO coll://' + destColl + ' WHENEXISTS=skip');
DOpus.Output(filesToCopy.join('\n'));
filesToCopy = [];
}
}
}
QUESTIONS
-
Is the
OnAddCommands(scriptCmdData)
section correct way to add commands so they appear in the BUTTON SCRIPT commands list? -
Is
scriptCmdData
the correct param to use i.e.OnAddCommands(scriptCmdData)
? Furthermore, is an obj paramater that is inherited from ___??? -
Is
var cmd = scriptCmdData.func.command;
the proper way to add the command that is later used forcmd.addFIles()
(trick question - I know it is NOT because I keep getting error) -
I think I have more questions - but cant think of them right now.
Thanks all for help