Click or drag to resize

RhinoObjectDuplicateGeometry Method

Constructs a deep (full) copy of the geometry.

Namespace:  Rhino.DocObjects
Assembly:  RhinoCommon (in RhinoCommon.dll)
Syntax
public GeometryBase DuplicateGeometry()

Return Value

Type: GeometryBase
A copy of the internal geometry.
Examples
using System;
using Rhino;
using Rhino.Commands;
using Rhino.DocObjects;
using Rhino.Input;

namespace examples_cs
{
  public class DuplicateObjectCommand : Command
  {
    public override string EnglishName { get { return "csDuplicateObject"; } }

    protected override Result RunCommand(RhinoDoc doc, RunMode mode)
    {
      ObjRef obj_ref;
      var rc = RhinoGet.GetOneObject("Select object to duplicate", false, ObjectType.AnyObject, out obj_ref);
      if (rc != Result.Success)
        return rc;
      var rhino_object = obj_ref.Object();

      var geometry_base = rhino_object.DuplicateGeometry();
      if (geometry_base != null)
        if (doc.Objects.Add(geometry_base) != Guid.Empty)
          doc.Views.Redraw();

      return Result.Success;
    }
  }
}
from System import *
from Rhino import *
from Rhino.Commands import *
from Rhino.DocObjects import *
from Rhino.Input import *
from scriptcontext import doc

def RunCommand():

  rc, obj_ref = RhinoGet.GetOneObject("Select object to duplicate", False, ObjectType.AnyObject)
  if rc <> Result.Success:
    return rc
  rhino_object = obj_ref.Object()

  geometry_base = rhino_object.DuplicateGeometry()
  if geometry_base <> None:
    if doc.Objects.Add(geometry_base) <> Guid.Empty:
      doc.Views.Redraw()

  return Result.Success

if __name__ == "__main__":
  RunCommand()
Version Information

Rhino for Mac

Supported in: 5.4

Rhino for Windows

Supported in: 6.0
See Also