active_entities are the entities in the current edit of the model, group or definition, so that's equivalent to
model.entities if it's in the model. It didn't mine into definitions...
That gets me thinking of another method - see below... simply filter the array of entities returned for text and change each bit of text to suit - works in the model, inside groups and components etc... useful for any methods where global change of some types of entities is needed - like layer and material manipulation when model is heavily grouped or componentized ?
- Code: Select all
=begin
(c) TIG 2009
'all_entities.rb' adds a new Method to Sketchup's Model Class -
"model.all_entities" - it returns an array of all entities in the model
i.e. model.entities.to_a + definintion.entities [groups and components]...
=end
class Sketchup::Model
def all_entities
model=Sketchup.active_model
all_entities=model.entities.to_a
model.definitions.each{|d|d.entities.each{|e|all_entities.push(e)}}
return all_entities
end#def
end#class
###