# Delete Multiple Components from the list at one time?

**URL:** <https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749>\
**Category:** Pro\
**Tags:** sketchup\
**Created:** [September 12, 2024, 11:57pm UTC](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749 "2024-09-12T23:57:44Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![ArchyVR](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/archyvr/32/182009_2.png) [@ArchyVR](https://forums.sketchup.com/u/ArchyVR)\
**Post date:** [September 26, 2024, 11:09pm UTC](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749/9 "2024-09-26T23:09:59Z")

</div>

Thank you, @rtches and @TIG!

In the end the combination of your code managed to purge all unused components in one go without crashing.

```auto
model = Sketchup.active_model
model.start_operation('compos_togo', true) # for possible undo
defns = model.definitions
togos = []
defns.each{|e| togos << e if (e.name =~ /^*/ && e.count_used_instances == 0)}
# there are many pattern matching possibilities...
togos.each{|e| defns.remove(e) }
model.commit_operation # allowing an undo

```

Not sure why the native purge feature crashes on this model, but I am grateful for your ruby script knowledge and will keep this code handy the next time I run into this glitch. I was finally able to clear out old components bringing my model from 93MB to 76MB. 🙂

Note after the Ruby Script Purge Components, the native Window → Model Info → Statistics → Purge Unused works without crashing!

Thanks again!  
Chris

---

_[View the full topic](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749)._
