Open ponahoum opened 3 years ago
Ok I actually found out reading the tests that to make it work you need to add file.Header.Version = DxfAcadVersion.R14
:
var file = new DxfFile();
file.Header.Version = DxfAcadVersion.R14; // DxfImage is only supported on >= R14
Although the attributes are now in the DXF, i can't manage to make autocad open the DXF with the image as an external reference. The dependency doesn't seem to be considered even though it is included in the DXF file. Any idea on how to achieve this ? Here's my generation code:
//Setup the file
var file = new DxfFile();
file.Header.Version = DxfAcadVersion.R14; // DxfImage is only supported on >= R14
//Adding a line to test
DxfLine aLine = new DxfLine();
aLine.P1 = new DxfPoint(0, 0, 0);
aLine.P2 = new DxfPoint(0, 1, 0);
file.Entities.Add(aLine);
//Setting up the image
var image = new DxfImage("TestImage.png", DxfPoint.Origin, 1920, 1080, new DxfVector(19.2, 10.8, 0.0));
image.IsVisible = true;
image.ShowImage = true;
file.Entities.Add(image);
//Write the file
using (FileStream filestream = new FileStream(outputPath, FileMode.Create))
file.Save(filestream);
IMAGE
entities are problematic because AutoCAD is really picky about what the file looks like, and I haven't yet been able to determine exactly what that is. Using your example code an image displays correctly both in the ODA Viewer app as well as LibreCAD, but not AutoCAD 2016 (I don't have any other programs to test with.) I even did a Save As from LibreCAD and AutoCAD still couldn't open it; it seems that IMAGE
is a problem for everybody.
I tried with AutoCAD 2020 and it ignores the reference as well. Although I tried with AutoCAD 2020 and netDxf / ezDxf and it works well.
Hi,
I am trying to use the DxfImage entity to insert an image dependency into my DXF but I cannot make it work. The DXF output seems not to contain the image attributes that I put. Does anyone have a working example?
Thanks !