Hi,
I have mixed sample of .dwg + .dxf extensions.
I downloaded this zip file:
map_of_alaska.zip (3.5 MB)
It has two inner folders:
image.png (5.2 KB)
In one folder there is -__MACOSX-.dwg extension.
image.png (8.7 KB)
In other folder there are both -.dwg + .dxf extensions
image.png (12.9 KB)
So how I refer to it as: .dwg or .dxf in the code ?
Thanks,
@danies8,
Hello,
Aspose.CAD can work with both DWG and DXF files directly. You just need to point the API to the actual file you want to process – the library detects the format from the file extension (or its content) and loads it accordingly. So if you want to handle the DWG version, use the path to the *.dwg file; if you need the DXF version, use the path to the *.dxf file. Each file is treated independently, there isn’t a combined “DWG/DXF” reference.
In practice you would extract the zip first, then call the loading method with the full file name, e.g. …/folder/yourfile.dwg or …/folder/yourfile.dxf. The same code works for both formats, so you don’t need separate handling logic.
If you need to work with both files in the same workflow, simply load each one in turn using its own path. Should you encounter any unexpected behavior with a particular file, feel free to share that file (or a minimal sample) and we can investigate further.
Hi,
Can you please verify the AI ?
Can I load both extensions DWG and DXF or only one?
Can you please explain this issue of mix extensions in details :
When it used both extensions?
What are the possibilities with your API ?
@danies8,
CadImage is used to work with DWG/DXF:
string[] fileNames = new string[] { "Map_of_Alaska.dwg", "Map_of_Alaska.dxf" };
foreach (string fileName in fileNames)
{
using (CadImage cadImage = (CadImage)Aspose.CAD.Image.Load(fileName))
{
cadImage.Save(fileName + ".stp", new StpOptions());
}
}
Instead of
using (CadImage cadImage = (CadImage)Aspose.CAD.Image.Load(fileName))
you may use Image, it is suitable for both formats as well:
using (Aspose.CAD.Image cadImage = Aspose.CAD.Image.Load(fileName))
Files inside __MACOSX folder are not valid DWG/DXF files, these are resources with metadata for Mac computers related to the files.
I always verify all AI answers by default 
1.Why there are in on zip file two extensions: DWG/DXF?
Can you explain in real word why ? they can be many DWG/DXF in one sample?
2.This code from other post, we close about.
using (Image cadImage = Aspose.CAD.Image.Load(fileName))
{
var rasterizationOptions = new Aspose.CAD.ImageOptions.CadRasterizationOptions()
{
DrawType = Aspose.CAD.FileFormats.Cad.CadDrawTypeMode.UseObjectColor
};
StpOptions stpOptions = new StpOptions();
stpOptions.VectorRasterizationOptions = rasterizationOptions;
cadImage.Save(outPath, stpOptions);
}
@danies8,
got it, the task is closed.