Clone geometry in C#

Dear forum,

What would be the best way to clone a geometry (specifically line) in c#? I have a rotated line in the code and want to have a deep copy of it.

I have tried “var newLine = new Line(oldLine.PointAt(0.0), oldLine.PointAt(1.0))”, but it actually did something strange - maybe it is a tolerance issue, because put very small deviation made it work, eg (var newLine = new Line(oldLine.PointAt(0.000001), oldLine.PointAt(0.9999999)).

So actually, my question can be two, how to clone geometry and why the new line of domain 0-1 does not reproduce the same line?

Any feedback will be much appreciated.


Line type is a struct, not a class derived from GeometryBase. You can clone structs only by assigning it to another variable:

var newLine = oldLine;

and in geometries, by calling DuplicateGeometry() or DuplicateCurve() in the case of the Curve, or DuplicateBrep() in the type Brep…

Check the tolerance you have in Rhino doc, the error/desviation should be under it.

1 Like


Thanks for your reply - very helpful.