How to delete a model imported from *.dae file by ruby.
-
I have many *.dae files (about 10 thousand) that must be purged in SketchUp. So I write a plugin to deal with the *.dae files. How to delete a imported model in ruby?
Here is my ruby scripts, but the code doesn't have any effects.
model = Sketchup.active_model
entities = model.active_entities
entities.each { |singleEntity|
entities.erase_entities singleEntity
} -
what are you actually doing?
open new drawing...
import dae, purge, export purged dae...2.times{Sketchup.send_action('editUndo;')}
start again...
maybe you don't even need the 2.times.... -
@driven said:
what are you actually doing?
open new drawing...
import dae, purge, export purged dae...2.times{Sketchup.send_action('editUndo;')}
start again...
maybe you don't even need the 2.times....yes, I just need to keep repeating the process: import a dae , purge, export purged dae, and deal with the next dae.
thank you very much...
-
Start off by clearing everything, by using:
model = Sketchup.active_model model.entities.clear!
then purge the model using:
model.definitions.purge_unused model.active_layer=model.layers[0]; model.layers.purge_unused model.materials.current=nil; model.materials.purge_unused model.styles.purge_unused ds = model.attribute_dictionaries; ds.to_a.each{|d| ds.delete(d) } if ds
Now you have an empty SKP.Try doing the import AND export within a
model.start_operation(...)
block, BUT do not 'commit
' it, rather you need to 'abort
' it after each one.
That way the import happens, the export happens but the changes to the model are undone by each 'abort
'. The exported file is NOT undone by the 'abort
' !
Advertisement