Rhinocommon: Create a copy of a circle

what is the best method for creating a copy of a circle in rhinocommon? This structure hasn’t Duplicate() method as is available for another data type, like nurbsCurve.

I’m trying to transform (translate) a copy of one circle. I can figure out ways to do it, for example, instaciating a new circle with the same parameters and then translating this one, but this doesn’t “feel” ok to me.

Just guessing what is the best (shortest to type) method,


maybe I’m just feeling particularly lazy today…

If you’re implementing this in Python, you can always import the copy module (i.e. copy.copy() and copy.deepcopy()). But I also prefer to use Duplicate() in RhinoCommon (when available), or the style where the constructor takes the same type as its input to duplicate (like with Point3D for instance). It’s indeed a bit odd that Circle provides neither of these options.

1 Like

Circle is a struct, not a class. Structs copy-on-assignment.

Circle c1 = new Circle(Point3d.Origin, 2.0);
Circle c2 = c1; // tadaa, copied!
c2.Translate(new Vector3d(1,0,0)); 
1 Like

I’ve always wondered if this is by design, but IronPython does not appear to do this:

191017_CopyStructOnAssignment_IronPython_00.gh (4.0 KB)

I’ve always wondered if this is by design

Yes that is part of the C# language standard. AFAIK Python does not make a distinction between classes and structs, so in Python this would indeed not work.

Ah yes, sorry. I meant if it is by design that the IronPython developers did not implement the C# behaviour (IronPython being written in C# and all). But yes, I suppose that wouldn’t be very Pythonic of them :snake:

Visual Studio 2019 finally introduced a differentiation in color between a struct and a class. Although structs have multiple useful features, its also kind of unlucky implemented in C# . Before this color distinction in the IDE, you always had to double check a 3rd party object if its a class or not, because otherwise you could not guarantee if you pass a reference pointer or a copy when you apply the equals operator…