Hack for Ctrl+C and Ctrl+V

Hi everyone,

I want to hack a bit result of !_CopyToClipBoard (Ctrl+V) and !_Paste (Ctrl+C) commands. Rhino copies objects at the same location with this commands but I need to move new objects a bit in order to help user to show there is no overlapping with copied objects.

I have CopyFlag in my controller to understand objects is copying or not in the;

private void RhinoDoc_AddRhinoObject(object sender, RhinoObjectEventArgs e)
    if (e?.TheObject != null && IsPluginObject(e.TheObject) && CopyFlag)
    // Add the new object to the helper
    // Hook up the idle handler

What is the best practice to get Ctrl+C or Ctrl+V events.

RhinoApp.KeyboardEvent += RhinoApp_KeyboardEvent;

private void RhinoApp_KeyboardEvent(int key)
     throw new NotImplementedException();

I tried to use this one but it doesn’t make sense to me. Do you have any suggestion?

Hi @oguzhankoral,

An approach you might want to consider is this:

1.) Using a Command.BeginCommand handler, watch for the beginning of Paste.

2.) Record next object runtime serial number:

var sn_start = RhinoObject.NextRuntimeSerialNumber;

3.) Using a Command.EndCommand handler, watch for the ending of Paste.

4.) Record next object runtime serial number:

var sn_end= RhinoObject.NextRuntimeSerialNumber;

5.) If sn_end > sn_start, hook up a RhinoApp.Idle handler.

6.) When the RhinoApp.Idle handler called, unhook it, Then round up all the objects that were added to the document by the Paste command:

var objects = new List<RhinoObject>();
for (var sn = sn_start; sn < sn_end; sn++)
  var obj = doc.Objects.Find(sn);
  if (null != obj)

7.) Do something with objects.

My 2 cents…

– Dale

1 Like

Hi @dale,

I think it was more than 2 cent :slight_smile: It works, thank you.