How can I know if a given fille .dwf or .dxf is 2D or 3D?

Hi,
How can I know if a given fille DWF or DXF is 2D or 3D?
Thanks,

@danies8,
Hello,

You can determine whether a DWF or DXF file contains 2‑D or 3‑D geometry by loading the file with Aspose.CAD and inspecting the entities that are present in the resulting CadImage. After calling Image.Load you get a CadImage object; its Entities collection holds all drawing objects. If the collection contains any 3‑D specific entity types (for example AcDb3dFace, AcDb3dPolyline, AcDbRegion with a Z‑coordinate, etc.), the file should be considered 3‑D. When only 2‑D entities such as lines, arcs, circles, polylines, text, etc., are present, the drawing is 2‑D.

So the typical steps are:

  1. Load the file: var image = Aspose.CAD.Image.Load("yourFile.dxf");
  2. Cast the image to CadImage and enumerate image.Entities.
  3. Check the type of each entity – if you encounter any of the 3‑D entity types, you can mark the file as 3‑D; otherwise it is 2‑D.

If you run into a specific file where the result is unclear, feel free to share a small sample (or the relevant part of the code you are using) and we can help you verify the detection logic.

1 Like

Thank you.
You can close this post.

@danies8,
Hello,
you may detect if DWF is 3D using this code sample:

using (DwfImage image = (DwfImage)Image.Load(filename))
{
     var is3D = image.Depth > 0;
}

but the common answer is similar to DXF/DWG here. The approach proposed by AI-bot above is valid in common as well. The post is closed.