Skip to main content
Participating Frequently
August 14, 2024
Answered

Automation Blocks - Can you remove clips from sequence based on clip attributes?

  • August 14, 2024
  • 2 replies
  • 1130 views

I am trying to set up an automation that removes clips from a sequence only, not the entire project, based on whether or not it's selected. Files attached for how I have it set up.

I started out using the clip.remove execute code as defined in the block reference, but that ended up only deleting every other clip in track 1. I then used chat GPT to modify the execute code.  So far I have it working but once it has successfully removed the clips, I get an error "execution result:could not find item 1 in track Video 7 (the track contains no items at all) (line 6)". This is because my clip.remove block is still going even after removing the selected clips. I am not sure how to revise the execution code so that it stops after successful removal. 


Files attached for how I currently have it set up. If anyone has a better solution to removing clips based on attributes that would be awesome. Ideally it would remove the clips if they are enabled (weird I know), but the way I currently have it set up it's based on whether or not the clip is selected.

Many many thanks to anyone who can help me understand this a little better, and happy to provide additional details/clarification.

 

PS sorry for duplicate post, I initally posted to the wrong topics. 

This topic has been closed for replies.
Correct answer Mathias Moehl

I think the issue is that you nested your execute code block into a "for each selected clip" block AND the execute itself again loops over all selected clips. Hence, you don't want to execute the "execute code" once for each selected clip, but you just want to execute it one time.

Does it work, if you simply remove the "for each selected clip" block?

 

Alternative solution:

You said that initially, it just deleted every other clip. The problem here is, that when Automation Blocks loops over all clips, it uses their index in the track like:

- run loop for first clip of track 1

- run loop for second clip of track 1

- run loop for third clip of track 1

 

Now if in the first step "run loop for first clip of track 1" you actually delete this clip, then the clip that was formerly the second is now the first. Hence, the loop continues with the third clip (which is now effectively the second one).

The easiest way to work around this is to put all clips you want to delete into a list, and then remove the elements in the list in reversed order. Because, if you remove the last element first, the index of all other items does not change.

2 replies

Participating Frequently
August 16, 2024

Thank you so much for your quick response, side note this plugin is incredible and is everything I have been needing in my life!

 

Taking it out of the For Each Clip block works! But since its now also out of the For Each Item block, it only runs on the active sequence. I need to run this on multiple sequences located in a single bin (does not work when 
i set a target bin and deselect "only selected items")

The alternative solution is what I think would work best, but I was getting confused on how to set up the list/reverse the index etc. 

Mathias Moehl
Community Expert
August 16, 2024

Your custom code hard-coded to use the active sequence.

This change should do the trick:

 

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects
Participating Frequently
August 16, 2024

you absolute king!!!! I could cry this worked thank you so much!!!!

Mathias Moehl
Mathias MoehlCorrect answer
Community Expert
August 15, 2024

I think the issue is that you nested your execute code block into a "for each selected clip" block AND the execute itself again loops over all selected clips. Hence, you don't want to execute the "execute code" once for each selected clip, but you just want to execute it one time.

Does it work, if you simply remove the "for each selected clip" block?

 

Alternative solution:

You said that initially, it just deleted every other clip. The problem here is, that when Automation Blocks loops over all clips, it uses their index in the track like:

- run loop for first clip of track 1

- run loop for second clip of track 1

- run loop for third clip of track 1

 

Now if in the first step "run loop for first clip of track 1" you actually delete this clip, then the clip that was formerly the second is now the first. Hence, the loop continues with the third clip (which is now effectively the second one).

The easiest way to work around this is to put all clips you want to delete into a list, and then remove the elements in the list in reversed order. Because, if you remove the last element first, the index of all other items does not change.

Mathias Möhl - Developer of tools like BeatEdit and Automation Blocks for Premiere Pro and After Effects