# 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:** 11\
**Page:** 1

<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 12, 2024, 11:57pm UTC](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749/1 "2024-09-12T23:57:44Z")

</div>

Besides Purging, is there a way to delete multiple components at a time from the component list?

The issue I’m having is that when I purge all, SU crashes.

I suspect I have one bad component in the mix. In the past I’ve taken the time to one by one right click on the component and delete until I find the one that crashes SU.

But is seems silly that although I can select multiple components at once, I am not able to right click and select delete. If I could, this would allow me to find the bad component faster by first trying to delete top half of the list, if it crashes, I know the one I’m looking for is somewhere there. from there I can reopen and try alphabetical groups “a” thru “d”, “e” thru “k” … until I get a crash again, and so on… With this method after about 5 to 10 attempts I should be able to narrow down and identify the bad apple. Without that ability, I’m forced to delete one by one… and in large models a few hundred components, this can take way too long.

---

<div class="post-metadata">

**Author:** ![DaveR](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/daver/32/7601_2.png) [@DaveR](https://forums.sketchup.com/u/DaveR)\
**Post date:** [September 13, 2024, 1:26am UTC](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749/2 "2024-09-13T01:26:27Z")

</div>

Have you tried purging only components?

---

<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 13, 2024, 4:30pm UTC](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749/3 "2024-09-13T16:30:48Z")

</div>

Hey Dave,

I tried purging just the components and I still get a crash.

I can purge everything else with no problems.

It seems I have one bad component in my model, I’ll eventually find it, but it would be nice to be able to delete 5, 10, 20… components at a time so it would be faster in finding the corrupt component. This seems like a relatively easy option to add in a future update. 🤞

---

<div class="post-metadata">

**Author:** ![TIG](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/tig/32/198_2.png) [@TIG](https://forums.sketchup.com/u/TIG)\
**Post date:** [September 13, 2024, 5:13pm UTC](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749/4 "2024-09-13T17:13:53Z")

</div>

It’s a relatively simple Ruby script…  
But first you need to set up a ‘pattern’ to match in the components’ names…  
So let’s say the ‘bad’ component definitions start with the text ‘Aardvark’…  
Here’s some [untested] sample code…

```ruby
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 =~ /^Aardvark/ }
# there are many pattern matching possibilities...
togos.each{|e| defns.remove(e) }
model.commit_operation # allowing an undo

```

---

<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 15, 2024, 5:29am UTC](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749/5 "2024-09-15T05:29:21Z")

</div>

Thanks TIG!

I’ll definitely give that a try. Can you do wild cards similar to windows command prompt?

Example, " a\* " for any entity starting with the letter " a " or " \*box \* " for any entity that has the word " box " within it?

---

<div class="post-metadata">

**Author:** ![rtches](https://sea2.discourse-cdn.com/sketchup/user_avatar/forums.sketchup.com/rtches/32/131827_2.png) [@rtches](https://forums.sketchup.com/u/rtches)\
**Post date:** [September 15, 2024, 5:58am UTC](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749/6 "2024-09-15T05:58:34Z")

</div>

> [@ArchyVR](#):
>
> " a\* " for any entity starting with the letter " a " or " _box_ " for any entity that has the word " box " within it?

Use regex…  
For starting with a  
\ba\w\*\b  
For word “box”  
\w_box\w_

---

<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, 6:36pm UTC](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749/7 "2024-09-26T18:36:14Z")

</div>

Thanks guys for the help.

The Script works great in deleting batches of components.

Turns out I still have difficulty finding the bad apple though. My theory for deleting letter groups at a time until I find a letter group that crashes, sort of worked, but then when I reopened and tried to delete the letter group one by one, no crash was produced.

In thinking of another approach, I noticed this script deletes components regardless if they are being used in the scene or not. Is there a way to modify this script to only delete components that are not used? So in the end I can purge letter groups and see if that helps me find the corrupt component.

Thanks again! 🙏

---

<div class="post-metadata">

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

</div>

Try to modify this line. (not tested as I’m not at the computer)

```rb
defns.each{|e| togos << e if (e.name =~ /^Aardvark/ && e.count_used_instances == 0)}

```

---

<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

---

<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:** [October 18, 2024, 9:39pm UTC](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749/10 "2024-10-18T21:39:52Z")

</div>

Just wanted to send a thank you again! I had another project that would crash the Native Purge all, but this script worked like a charm and cleared out whatever was causing the crash. 😀

---

<div class="post-metadata">

**Author:** ![JackyM](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@JackyM](https://forums.sketchup.com/u/JackyM)\
**Post date:** [August 29, 2025, 3:58pm UTC](https://forums.sketchup.com/t/delete-multiple-components-from-the-list-at-one-time/289749/11 "2025-08-29T15:58:41Z")

</div>

Closed on August 29, 2025, 3:58pm UTC


