Change Group axis

I want to chagne group axis like pic (left -> right)

and I used this method(in following code) but didn’t work

Can you help me for it?

 edge = group2.entities.add_line(start_point, end_point)
        xaxis = end_point.vector_to(start_point)
        zaxis = end_point.vector_to(start_point) * yaxis
        yaxis = end_point.vector_to(start_point) * zaxis
        transform = Geom::Transformation.axes(start_point, xaxis, yaxis, zaxis)
        my_group = group2.definition
        my_group.instances.each{ | instance | instance.transform!(transform)}
        my_group.entities.transform_entities(transform.inverse, my_group.entities.to_a)

↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓full code↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

require 'sketchup.rb'


module Chromite

    def self.makebox
      model = Sketchup.active_model
      entities = model.active_entities
      selection = model.selection
      faces = selection.grep(Sketchup::Face)
      faces.each{|face|
        group = entities.add_group(face)
        group2 = group.copy
        group.explode
        entities2 = group2.entities
        before = entities2.grep(Sketchup::Face)
        before[0].material = [50, 255, 255]
        before[0].pushpull( 10.mm )
        new_faces = entities2.grep(Sketchup::Face) - before
        upper_face = new_faces.find {|f| f.normal == before[0].normal.reverse }
        unless upper_face.nil?
          start_point = upper_face.bounds.center
          offset_vector = upper_face.normal
          offset_vector.length = 90.mm
          end_point = start_point.offset(offset_vector)
        end
        edge = group2.entities.add_line(start_point, end_point)
        xaxis = end_point.vector_to(start_point)
        zaxis = end_point.vector_to(start_point) * yaxis
        yaxis = end_point.vector_to(start_point) * zaxis
        transform = Geom::Transformation.axes(start_point, xaxis, yaxis, zaxis)
        my_group = group2.definition
        my_group.instances.each{ | instance | instance.transform!(transform)}
        my_group.entities.transform_entities(transform.inverse, my_group.entities.to_a)
        layer = Sketchup.active_model.layers.add("win")
        my_group.layer = layer
        entities2.each{|e| e.layer = layer }

        if !model.active_path.nil?
          instance = model.active_path.last
          definition = instance.definition
          my_group_copy = my_group.parent.parent.parent.entities.add_instance(my_group.definition,my_group.transformation)
          my_group.erase!
        end

        }


    end

    if( not file_loaded?("kce_makewin2.rb") )
        UI.menu("Plugins").add_item("Start makewin Tool2") { self.makebox }
        dir = Sketchup.find_support_file("Plugins")
        cmd = UI::Command.new("Start makewin Tool2") { self.makebox }
        cmd.large_icon = cmd.small_icon = dir+"/kce_makewin2.png"
        cmd.status_bar_text = cmd.tooltip = "Tool2 for making kce daylight analysis window"
        tb = UI::Toolbar.new("Poké Ball™")
        tb.add_item cmd
        tb.show if tb.get_last_state == -1
    end

    file_loaded("kce_makewin2.rb")

end # of chromite class

to move group axes in ruby, first, you move the group to a new point, you go to group edit mode, and move all entities in the group to its original place. When you move and rotate a group its Axes also move and rotate, when you move and rotate back entities of a group its axes not move and rotate. Don’t try to move axes directly.