Delete a list of components by their definitions.
-
**Thank you driven, your solution works well but encounters the same problem as that of TIG enhanced by Dan.
The materials applied to the "subcomponents" are not seen by the 2 methods.
To be more precise, here is an example in image:
The goal is that the texture "CUBE" is not deleted because it is used by "Nested component".
Perhaps the solution would be to ask both methods to explore all the subcomponents in SketchUp and collect the materials so as not to delete them?
How to write this in ruby?
I could find a solution by modifying the components of Click-Cuisine 2, but the ideal would be to solve the problem with the code.
If you want to try, here is the SKP file of the example:
Thank you**
-
you must have changed something because it does work for me...
did you read the code?
it collects all nested materials from 'everything' before removing any materials...
click image to see gif:
attach your test code...
john
-
**Yes I read your code driven and am surprised that it does not work for me.
You are right in my last SKP example, your method works.
Make a test with this example:
You will see that the texture of "TOTO" will be deleted.**
-
**I can not understand why the texture applied to "TOTO" is purged.
If I go through "purge_unused" the texture "TOTO" is not deleted.
So I'll get around the problem with another method.
To delete a list of materials, I can write this:
mat_names = ['TOTO','LOLA','CUBE'] materials = Sketchup.active_model.materials mat_names.each{|mnj| materials.remove(mnj)}
Can we do the same with "purge_unused", so that the unused materials of the list are deleted?
Thank you for your help.**
Advertisement