Hi all,
I am writing an application that searches a vault and then converts certain files into STEP . There is already a defined task for this STEP conversion. When I try to start the task automatically with the RunTask method, I always get the error message “The supplied object id is not valid”.
I’ve copied the procedure from the pdm api example " Get and Run a Task Add-in Example (C#)".
PDM-Version is 2023
_filesToStep is a List
private static void RunTask()
{
EdmSelItem2[] selection = new EdmSelItem2[ _filesToStep.Count ];
for( int i = 0; i < _filesToStep.Count; i++ )
{
IEdmFile17 file =(IEdmFile17) _vault.GetFileFromPath( _filesToStep[i].Path, out IEdmFolder5 folder );
selection[ i ].mlID = file.ID;
selection[ i ].mlParentID = folder.ID;
selection[ i ].mlVersion = file.CurrentVersion;
selection[ i ].meType = EdmObjectType.EdmObject_File;
}
try
{
IEdmTaskMgr taskMgr = (IEdmTaskMgr)_vault.CreateUtility( EdmUtility.EdmUtil_TaskMgr );
Array tasks = taskMgr.GetTasks();
string cleanedInput = _taskName.Trim().Trim( '"' );
EdmTaskInfo stepTask = tasks.OfType<EdmTaskInfo>().FirstOrDefault(
task => string.Equals( task.mbsTaskName, cleanedInput, StringComparison.OrdinalIgnoreCase ) );
taskMgr.RunTask( stepTask, selection, 0 );
}
catch( Exception ex )
{
_logger.Error("The Task cannot be executed. --> " + ex.Message );
}
}
Does anyone has an idea?