Clone

Namespace: Digi21.DigiNG.Entities
Assembly: Digi21.DigiNG

Returns a copy of the entity. The copy does not belong to any drawing file and can therefore be modified.

public Entity Clone()

Each derived class declares with new a Clone() returning the read/write type: ReadOnlyLine.Clone returns Line, ReadOnlyPolygon.Clone returns Polygon, ReadOnlyComplex.Clone returns Complex, ReadOnlyPoint.Clone returns Point, and ReadOnlyText.Clone returns Text. The method executed depends on the variable's type: Entity.Clone() calls the derived class's Clone() and also copies code attributes (see the table). ICloneable.Clone() calls Entity.Clone().

Return value

A new entity of the read/write type, with Owner set to null and ReadOnly set to false.

Data Copy
Coordinates, polygon holes and complex entities Copied.
Color, Weight, FillColor and Deleted Copied.
Codes Names, tables, identifiers and visibility are copied.
Each code's Code.Attributes With Entity.Clone(): a new Dictionary<string, object> containing a copy of each code's attributes. With the derived class's Clone(): a read-only dictionary containing attributes stored in the native entity (those of an entity read from a file); attributes assigned to codes in .NET are not copied.
Attributes Read-only dictionary containing attributes stored in the native entity (those of an entity read from a file). Attributes assigned in .NET are not copied. To change them, assign another dictionary.
UserData and Hidden Not copied.

Example

// línea is a ReadOnlyLine read from a file: the copy is a Line.
var copia = línea.Clone();
copia.Points.Add(new Point3D(0, 0, 0));