Here is a revised edition that will work on multiple selection …
# Redraw all selected (and siblings)
UI.add_context_menu_handler do |context_menu|
ss = Sketchup.active_model.selection
if defined?($dc_observers) && !ss.empty?
insts = ss.grep(Sketchup::ComponentInstance)
if !insts.empty?
dynatts = 'dynamic_attributes'
insts.select! {|i| i.definition.attribute_dictionary(dynatts) }
if !insts.empty?
cdefs = insts.map(&:definition).uniq
dco = $dc_observers.get_latest_class
context_menu.add_item("Redraw ALL sibling DCs") {
cdefs.each {|cdef|
puts "\nRedrawing Instances of: \"#{cdef.name}\"..."
cdef.instances.each {|i|
puts "Redrawing ... #{i.inspect}"
dco.redraw_with_undo(i)
}
}
}
context_menu.add_item("Redraw ONLY selected DCs") {
puts
insts.each {|i|
puts "Redrawing Instance of: \"#{i.definition.name}\"... #{i.inspect}"
dco.redraw_with_undo(i)
}
}
end # if DC instances were selected
end # if component instances were selected
end # if DC loaded and something is selected
end # context menu handler block