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.
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.
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…
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
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.
In the end the combination of your code managed to purge all unused components in one go without crashing.
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!