Function OnInit(initData)
initData.name = "Command_Test"
initData.min_version = "12"
InitData.group = "++ Test ++"
initData.default_enable = True
End Function
Function OnAddCommands(addCmdData)
Dim cmd: Set cmd = addCmdData.AddCommand()
cmd.name = "Test"
cmd.method = "OnTest"
End Function
The paths to files in libraries have an extra part, normally hidden from view, which identifies which of the library folders they are below. You need to feed that path in, or calculate it, in order to select a file in a library.
The paths look like this:
lib://Pictures/?7e6911a3/Subfolder/Etc/File.jpg
The number part will be different for different libraries and paths, but will be consistent, so you could just find that and use it.
Or you could use something like the below example, which takes the real full path to the file, then finds it in the list of files and gets the library library path from it, and then feeds that to the select command.
(If you uncomment the DOpus.Output line in the example, you'll see it outputs a path like the one above.)
VBScript:
[code]Function OnClick(ByRef clickData)
Dim cmd, setRealPaths, folderItem
Set cmd = clickData.func.command
cmd.deselect = false ' Prevent automatic deselection
cmd.ClearFiles
Set setRealPaths = DOpus.Create.StringSet
setRealPaths.insert "C:\Temp\temp\temp.txt"
' ...Insert any other paths you want to select here...
For Each folderItem in clickData.func.sourcetab.all
If (setRealPaths.exists(folderItem.RealPath)) Then
' DOpus.Output folderItem
cmd.AddFile folderItem
End If
Next
cmd.RunCommand "Select FROMSCRIPT DESELECTNOMATCH MAKEVISIBLE"
var setRealPaths = DOpus.Create.StringSetI();
setRealPaths.insert("C:\Temp\temp\temp.txt");
// ...Insert any other paths you want to select here...
for (var eSel = new Enumerator(clickData.func.sourcetab.all); !eSel.atEnd(); eSel.moveNext())
{
if (setRealPaths.exists(eSel.item().RealPath))
{
// DOpus.Output(eSel.item());
cmd.AddFile(eSel.item());
}
}
cmd.RunCommand("Select FROMSCRIPT DESELECTNOMATCH MAKEVISIBLE");