Remove Component Definitions?
-
Is there no way to remove a specific component definitions from a model via Ruby?
(Or a Material or Layer for that sake.)I don't want to use Purge as it takes all unused items. But I would like to be able to remove definitions which my script created.
-
@thomthom said:
Is there no way to remove a specific component definitions from a model via Ruby?
(Or a Material or Layer for that sake.)I don't want to use Purge as it takes all unused items. But I would like to be able to remove definitions which my script created.
I often want to do that too - however, it seems that it's all or nothing when purging using Ruby... You can purge individual components, layers, materials and styles with SketchUp itself... BUT not via Ruby ! You have "model.definitions.purge_unused" BUT not the equivalent "definition.erase!" [as you can supposedly do for 'any' drawing element] - although it is a listed method "erase!" fails for a definition as it can't find its parent ??? : we need something like "instance.erase!"...
You can delete all of a definitions entities in Ruby using "definition.entities.each{|e|e.erase! if e.valid?}" - repeated several times to catch everything with a "while definition.entities.length>0" type of thing... If you then try to place an instance of that component manually it's removed from the browser list [a component must have some entities] BUT it doesn't work within Ruby...
Anyone feel up to inventing it ?
. -
I've noticed that V-Ray for Sketchup does some quirky workaround to delete materials from the model. It takes all unused materials, except the one you want to delete, creates an empty group for each material and assign the material. Afterwards it purges the materials and then deletes the temporary groups.
I really wish there wasn't the need for these 'hacks'. Has the issue been presented to the SU dev team? Is it some deliberate design decision for this? I just seems so odd that'd be overlooked. -
@thomthom said:
I've noticed that V-Ray for Sketchup does some quirky workaround to delete materials from the model. It takes all unused materials, except the one you want to delete, creates an empty group for each material and assign the material. Afterwards it purges the materials and then deletes the temporary groups.
I really wish there wasn't the need for these 'hacks'. Has the issue been presented to the SU dev team? Is it some deliberate design decision for this? I just seems so odd that'd be overlooked.You have the solution...
The new script is here http://www.sketchucation.com/forums/scf/viewtopic.php?p=144378#p144378 ... -
I wonder why clearing the definitions entities and placing the component from the browser works, but not when placing from ruby...
Advertisement