This code is not exhaustively tested, but it should give you enough ideas:
model = Sketchup.active_model model.start_operation('Unglue', true) insts = model.selection.grep(Sketchup;;ComponentInstance) insts.each{|inst| inst.glued_to= nil } model.commit_operationOne step undo-able...
It un-glues all selected component-instances.