This Ruby script allows you to redraw all dynamic components in SketchUp. Pasting the code into the Ruby Console will add options to the right-click context menu to redraw either just the selected dynamic components or all sibling dynamic components of the selected components. The script loops through the selected components, finds any that are dynamic using the 'dynamic_attributes' dictionary, and redraws them using the dynamic component observer class.
This Ruby script allows you to redraw all dynamic components in SketchUp. Pasting the code into the Ruby Console will add options to the right-click context menu to redraw either just the selected dynamic components or all sibling dynamic components of the selected components. The script loops through the selected components, finds any that are dynamic using the 'dynamic_attributes' dictionary, and redraws them using the dynamic component observer class.
This Ruby script allows you to redraw all dynamic components in SketchUp. Pasting the code into the Ruby Console will add options to the right-click context menu to redraw either just the selected dynamic components or all sibling dynamic components of the selected components. The script loops through the selected components, finds any that are dynamic using the 'dynamic_attributes' dictionary, and redraws them using the dynamic component observer class.
* https://forums.sketchup.com/t/redraw-all-dynamic-components/77512/14 * Redraw all dynamic components * Open the Ruby Console (Window) and paste
# 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 *--------------------------------------------------------------------------------- * works like regen all in autocad Sketchup.active_model.selection.grep(Sketchup::ComponentInstance).each do |s| $dc_observers.get_latest_class.redraw_with_undo(s) end *---------------------------------------------------------------------------------