This project has moved. For the latest updates, please go here.

DXF Files

Feb 19, 2015 at 11:30 AM
Hi All,

I want to take a single DXF file and pull out the images into separate DXF files.
I have already created a method that will add an image to a blank DXF file.
The problem is I can't get the images from the original file.
Feb 19, 2015 at 11:10 PM
If all you want to do is to create different dxf files with every individual image entity contained in another dxf, this is all you have to do:
// the original file that contains all your images
DxfDocument allImages = DxfDocument.Load("AllImages.dxf");
int counter = 1;
foreach (Image image in allImages.Images)
    // create the dxf that will hold every individual image
    DxfDocument doc = new DxfDocument();
    // it is VERY IMPORTANT to make copies of any entity or table object that you want to move between documents,
    // object handles and owner references cannot be shared between dxfs.
    Image copy = (Image) image.Clone();
    // add the copy to the new dxf, the AddEntity method will take care of everything else, its image definition, its layer, linetype, application registries,...
    // give a name to the new dxf
    string fileName = string.Format("Image{0}.dxf", counter++);
    // save the file
The Images property of a DxfDocument will return a ReadOnlyCollection<Image> object that contains the complete list of Image entities contained in a dxf across all layouts. The bitmap file details (file name, size, and resolution) are stored in the Definition property (an ImageDef object) of the Image entity. You can access the complete list of image definitions through the ImageDefinitions property of a DxfDocument. Also remember that multiple images can share the same definition.