Try this...
module TIG
module DefinitionReplacer
def self.run()
model=Sketchup.active_model
defns=model.definitions
model.start_operation("DefinitionReplacer", true)
counter=0
defns.to_a.each{|defn|
name=defn.name
next if name=~/[#]/
defns.to_a.each{|d|
n=d.name
next unless n=~/[#]/
next unless d.instances[0]
next unless n.split("#")[0]==name
defn.name=name+rand.to_s
d.name=name
ins=d.instances
defn.instances.each{|i|
i.definition=d
}
ins.each{|i|
i.erase!
}
counter+=1
}
defns.remove(defn)
}
model.commit_operation
puts "Processed #{counter} definitions"
end#def
end #module
end #module
TIG;;DefinitionReplacer.run()
#to use, it assumes you have a number of component definitions [Com1, Com2, etc],
#and you have already imported a similar set of edited ones into the model [Com1#1, Com2#1 etc].
#to run it, paste all of this into the Ruby Console, it should auto-run.
#all instances of the original Com1 become Com1#1, renamed as Com1,
#any instances of the previous Com1#1 are erased and its definition removed.
#it's one step undo-able