Skip to content

Converting to DXF ​

Use Dwg::toDxf($source)->convert() to export a DWG as ASCII DXF.

Requires LibreDWG dwg2dxf. See External tools.

Use the default target ​

php
use Mattmy\DwgConverter\Facades\Dwg;

$dxf = Dwg::toDxf(storage_path('app/private/floor-plan.dwg'))->convert();

$path = $dxf->storeAs('drawings', 'floor-plan.dxf', 's3');

Without toVersion(), the conversion uses LibreDWG's default target version.

Choose a target version ​

php
use Mattmy\DwgConverter\DxfVersion;

$dxf = Dwg::toDxf($request->file('drawing'))
    ->toVersion(DxfVersion::R2018)
    ->convert();

Supported cases are R12, R14, R2000, R2004, R2007, R2010, R2013, and R2018. toVersion() returns a new operation with that target. The original operation keeps its settings.

Output format and checks ​

The result reports extension dxf and MIME type image/vnd.dxf. The package checks for a non-empty ASCII DXF with the required section and end markers, but that check does not guarantee every DWG object was preserved or that every CAD application will display the file identically.

Last updated:

Released under the MIT License.