createSetNameAction not working yet?

Hi there,

I´m trying to rename a VideoClipTrackItem via createSetNameAction but it seems like this just doesn´t work (yet?).

I tried to move the clip with createMoveAction which worked fine. But for some reason, createSetNameAction does nothing and I am also not getting the “setStartAction created” log → seems like it gets stuck when creating the renameAction already.

async function writeMetadataToClipname() {
  const metadata = await getMetadata();
  const string = JSON.stringify(metadata);

  const project = await ppro.Project.getActiveProject();
  const seq = await project.getActiveSequence();
  const selection = await seq.getSelection();
  const selectedItems = await selection.getTrackItems();

  for (var i = 0; i < selectedItems.length; i++) {
    const item = selectedItems[i];
    if (Object.prototype.toString.call(item) !== '[object VideoClipTrackItem]') {
      continue;
    }
    const getName = await item.getName();
    const originalName = getName.split("//MD:")[0];
    const newName = originalName + "//MD:" + string;
    const renameAction = await item.createSetNameAction(newName);
    console.log("setStartAction created");
    await executeAction(project, renameAction);
  }
}

Cheers!

Jannis

Hi Jannis,

The function is working correctly for me, in the premiere_api sample (and current PPro beta build).

Does that implementation, work for you?

Hi,
Thanks - I just changed the function to create the action inside project.lockedAccess() and now it seems to work:

async function writeMetadataToClipname() {
  const metadata = await getMetadata();
  const string = JSON.stringify(metadata);

  const project = await ppro.Project.getActiveProject();
  const seq = await project.getActiveSequence();
  const selection = await seq.getSelection();
  const selectedItems = await selection.getTrackItems();

  for (var i = 0; i < selectedItems.length; i++) {
    const item = selectedItems[i];
    if (Object.prototype.toString.call(item) !== '[object VideoClipTrackItem]') {
      continue;
    }
    const getName = await item.getName();
    const originalName = getName.split("//MD:")[0];
    const newName = originalName + "//MD:" + string;
    console.log("newName: " + newName);
    
    let success = false;
    try {
      project.lockedAccess(() => {
        const renameAction = selectedItems[i].createSetNameAction(newName);
        success = project.executeTransaction((compoundAction) => {
          compoundAction.addAction(renameAction);
        }, "rename trackItem");
      });
    } catch (error) {
      console.log("Error renaming trackItem:", error);
    }
  }
}

Why do I have to rename a VideoClipTrackItem like this but renaming its ProjectItem worked fine the way I did it before?