Somebody help me to make simple plugin for this code

With regard to “05a.rb” …

A. The namespace module ( module Examples ) is not YOUR module.

ALL of YOUR code, plugins and extensions MUST be inside YOUR toplevel namespace module.
It must be a unique name that separates ALL or YOUR codes and extensions from everyone ELSE’s extensions. Ie …

module ATI
  # ALL of YOUR extension submodules inside this toplevel module !

B. The submodule ( module Examples::HelloCube ) is NOT YOUR extension name, and has nothing to do with copying entities. IE, it should be …

module ATI
  module CopySelection
    # ALL of YOUR extension's code inside this submodule !

C. The menu item you create has menu caption text that is "Create Cube Example" that has nothing to do with copying entities.

D. The comments in YOUR code are not sufficient to tell us what YOU want your code to do.
(Many of the comments are left over from the “Hello Cube” example.)

Add more comments to your code explaining what it is supposed to do.

E. As I said above, you have code at the submodule level outside of any method.
This code will run only once, when the module is first loaded.

This code is from line 31…56 …

    #test using selection entities

    model = Sketchup.active_model # Open model
    ent = model.entities # All entities in model
    sel = model.selection # Current selection
    ss = model.active_entities
    entities = model.active_entities
    # define some delta transform

    model.start_operation "Erase Inside"
      ent_face = entities.grep(Sketchup::Face).find_all
      ent_edges = entities.grep(Sketchup::Edge).find_all
      ent_face.to_a.each { | entity| entity.erase! }
      ent_edges.to_a.each { | entity| entity.erase! }
      #  ent_group = entities.grep(Sketchup::Group).find_all
      # ent_group.to_a.each { | entity| entity.explode }

      vector = , 0.m, 0)
      tr = Geom::Transformation.translation(vector)

      result = self.copy_entities(tr, sel)

    model.close_active until model.entities == model.active_entities

E1. Also this code ERASES any edges and faces BEFORE they can be copied.

E2 This code does NOT need find_all after the grep.

E3. The #grep method returns an array, so you would not need to call #to_a on the result of a #grep call.

E4. The transform …

     vector = , 0.m, 0)
      tr = Geom::Transformation.translation(vector)

… is frivolous. It means do not move at all.

So …

F. Firstly, explain what your plugin is supposed to do, in a comment at the TOP of the CODE.


ADD: You still have not fixed the first post’s code block.