netDxf icon indicating copy to clipboard operation
netDxf copied to clipboard

DXF file modification/editing.

Open rspardeshi opened this issue 2 years ago • 5 comments

Hi Haplokuon,

Is it possible to update, edit, or alter the DXF file data using netDxf ? I want to select a particular Polyline and wish to delete that polyline from the selected DXF file.

thanks, Rahul Pardeshi.

rspardeshi avatar Aug 22 '22 10:08 rspardeshi

Yes, the the purpose of this library is being able to create, modify, and read DXF files. You just need to load your file, remove the entity, and save it again.

haplokuon avatar Aug 22 '22 19:08 haplokuon

Hi Haplokuon,

thanks, I am studying netDXF library and successfully created one tool using it. Now I want to select a particular Polyline and wish to delete that polyline from the selected DXF file. Could you please provide me any example or reference matching my task?

rspardeshi avatar Aug 25 '22 06:08 rspardeshi

I cannot tell you how to find a particular entity in the drawing you must know how to find it. You will have to decide if it has a particular color, if it is inside a unique layer, if it is by its geometry,...; although the most efficient way is by its handle.

DxfObject o = doc.GetObjectByHandle("");
doc.Entities.Remove(o as EntityObject);

haplokuon avatar Aug 26 '22 15:08 haplokuon

thanks for the advice... it's constructive for my development.

rspardeshi avatar Aug 29 '22 04:08 rspardeshi

List<Polylines2D> allOuterContourEnts = DxfDoc.Entities.Polylines2D.Where(e => e.Layer.Name.Equals("0")).ToList(); DxfDoc.Entities.Remove(allOuterContourEnts);

my88480 avatar Apr 20 '23 10:04 my88480