# Properly Erase Pattern Via Scripting?

**URL:** <https://forum.renoise.com/t/properly-erase-pattern-via-scripting/29999>\
**Category:** Renoise Tool Development\
**Created:** [September 29, 2010, 8:39am UTC](https://forum.renoise.com/t/properly-erase-pattern-via-scripting/29999 "2010-09-29T08:39:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bystrano](https://forum.renoise.com/letter_avatar/bystrano/32/6_449c533f586939b6e5f246632a46421f.png) [@bystrano](https://forum.renoise.com/u/bystrano)\
**Post date:** [September 29, 2010, 8:39am UTC](https://forum.renoise.com/t/properly-erase-pattern-via-scripting/29999/1 "2010-09-29T08:39:20Z")

</div>

I can’t get to erase patterns properly. Here’s my problem :

Starting with an empty song, I clone the first pattern (no 0) using renoise.song().sequencer:clone\_range. I get a new pattern (no 1). I remove it from the sequence, using renoise.song().sequencer:delete\_at, then clear it with renoise.song().patterns[]:clear. When I clone the no 0 pattern again, the new cloned pattern is no 2. But I expect it to be no 1, since I erased no 1 in every possible way.

I know we have the same problem when doing this without scripting, but at least we have the “Sort and Delete Unused Patterns” function. AFAIK, you don’t have access to this function from the API, and it would be more useful for scripting if you could delete patterns one by one.

Is there any workaround for this? Is it a planned feature?

---

<div class="post-metadata">

**Author:** ![taktik](https://forum.renoise.com/user_avatar/forum.renoise.com/taktik/32/3823_2.png) [@taktik](https://forum.renoise.com/u/taktik)\
**Post date:** [October 4, 2010, 11:22am UTC](https://forum.renoise.com/t/properly-erase-pattern-via-scripting/29999/2 "2010-10-04T11:22:38Z")

</div>

Will automatically remove such empty patterns in “renoise.song().sequencer.delete\_sequence\_at(sequence\_pos)” in the next beta.
