Every QCAD Professional installation includes some command line tools which allow batch conversion of CAD drawing files.
Contents
Platform Notes
Windows
Under Windows, these utilities are included as batch files (.bat) in the installation directory of QCAD.
macOS
Under macOS, you can find the utilities as shell scripts inside the application bundle under:
QCAD-Pro.app/Contents/Resources
Linux
Under Linux systems, the utilities are also included as shell scripts in the installation directory of QCAD.
dwg2bmp
(also dwg2png, dwg2jpeg, dwg2tiff, dxf2png, dxf2jpeg, dxf2tiff, ...)
dwg2bmp converts a DXF or DWG file into a bitmap file. Supported output formats are: BMP, ICO, JPEG, PNG, PPM, TIFF, XBM, XPM.
The maximum number of bytes for the raw image data is 2'147'483'647 bytes. With four bytes per pixel (ARGB), the maximum size for the output file is 536'870'911 pixels, or for example 23'170x23'170 pixels.
Usage: dwg2bmp [OPTIONS]... <drawing file>
Converts a DWG / DXF file to a Bitmap file.
-a, -antialiasing Enable antialiasing
-b, -background=C Set the background color as color name
e.g. 'white' or '#ccdd00'.
-block=BLOCK_NAME Name of block to output (defaults to *Model_Space)
-f, -force Overwrite existing output file
-h, -help Display this help
-l, -list List supported formats
-m, -margin=M Set auto zoom margin to M (in pixels)
-o, -outfile=FILE Set output file to FILE
Default is same path and base name as input file
-q, -quality=Q Set the image quality / compression
(0=best compression..100=best quality)
-r, -resolution=R Set rendering resolution to R
(in pixels/drawing unit)
This overrides the width/height parameters.
-x, -width=W Set bitmap width to W (in pixels)
-y, -height=H Set bitmap height to H (in pixels)
-p, -origin Draw zero point (origin)
dwg2svg
(also dxf2svg)
dwg2svg converts a DXF or DWG file into an SVG (Scalable Vector Graphics) file. The output file can be optimized to look exactly the same as the drawing file (default) or to transfer as much of the geometry across as possible (switch -g).
Usage: dwg2svg [OPTION]... <drawing file>
Converts a DWG / DXF file to a SVG file.
-a, -adjust Adjust page size to include thickest lineweight
-b, -bottom=MB Set page margin at bottom to MB
-block=BLOCK_NAME Name of block to output (defaults to *Model_Space)
-c, -circle=CR Export points as circles with radius CR
-e, -equalmargins=M Set all page margins to M
-l, -r, -t and -b are ignored
-f, -force Overwrite existing output file
-g, -preservegeometry Preserve as much of the original geometry as possible
Default is identical rendering
-h, -help Display this help
-i, -inkscape Generate additional information for Inkscape
-l, -left=ML Set page margin at left to ML
-o, -outfile=FILE Set output file to FILE
Default is same path and base name as input file
-p, -open Open the converted file after conversion
-r, -right=MR Set page margin at right to MR
-s, -scale=SF Set scale factor to SF
-t, -top=MT Set page margin at top to MT
-x, -cross=CS Export points as crosses with size CS
Points: If neither -c nor -x is given, points are not exported.
SVG Units: SVG only supports the following units: mm, cm, in.
- Unsupported Metric drawing units are converted to Millimeters.
- Unsupported Imperial drawing units are converted to Inches.
Use -s to scale and avoid large values.
Margins: Margin values have to be specified in the (converted) SVG unit.
Examples:
Adjust page, set all margins to 1.5, export points as circles with radius 0.5:
dwg2svg -a -e 1.5 -c 0.5 file.dwg
Set scale factor to '1:200':
dwg2svg -s 1:200 file.dwg
dwg2pdf
(also dxf2pdf)
dwg2pdf converts a DXF or DWG file into a PDF file. The drawing file is expected to contain information about the paper size, orientation and drawing scale and offset.
Usage: ./dwg2pdf.sh [OPTIONS]... <drawing file>
Converts a DWG / DXF file to a PDF file.
-a, -auto-fit Auto fit and center drawing to paper -block=BLOCK_NAME Name of block (or layout) to output (defaults to '*Model_Space') -c, -center Auto center drawing on paper -d, -recompute-dim Recompute dimension blocks if empty (dimensions rendered with best compatibility) -e, -papers List all supported paper size names -point-size=SIZE Set size of points in mm -f, -force Overwrite existing output file -fs, -font-substitution FONT1 FONT2 Substitute FONT1 with FONT2 -h, -help Display this help -k, -grayscale Grayscale -l, -landscape Landscape (default is portrait) -layer=LAYER_NAMES Comma-separated list of layer(s) to export List may include regular expressions -list-printers List all available printers -m, -margin=M Set paper margins to M -n, -monochrome Monochrome (black / white) -o, -outfile=FILE Set output file to FILE default is same path and base name as input file -offset=X,Y Set offset to X,Y in drawing units ('3,4', '7/2,1/4', '0.5,-1.5', ...) -p, -paper=WxH Set paper size to W x H in mm or to named paper size ('A4', 'Letter', ...) -printer=PRINTER Print directly to PRINTER or default printer if no printer given -s, -scale=SCALE Set drawing scale to given scale ('1', '2', '0.5', '1:1', '1:5', '5:1', ...) -w, -minlineweight=LW Set minimum line weight to LW drawing units
dwg2maptiles
(also dxf2maptiles)
dwg2maptiles fully automatically creates sets of tiles for use in online maps. The generated directory / file structure follows the well established standard of (z/x/y.png). The number of zoom levels (z) is adjustable. Such map tiles can be used to create interactive maps for the web, for example using leaflet.js. Click here for an example of such a map created with dwg2maptiles and leaflet.js.
Usage: ./dwg2maptiles [OPTIONS]... Converts a drawing file (DWG, DXF, ...) to a set of bitmap files (PNG, JPEG, ...) for use with online maps, e.g. leaflet.js. -a, -antialiasing Enable antialiasing -b, -background=C Set the background color as color name e.g. 'white' or '#ccdd00'. -c, -colorcorrection Enable color correction to prevent white on white or black on black painting -f, -force Overwrite existing output file -h, -help Display this help -k, -grayscale Grayscale -l, -list List supported formats -n, -monochrome Monochrome (black / white) -o, -outdir=DIR Set output dir to DIR default is same path and base name as input file -q, -quality=Q Set the image quality / compression (0=best compression..100=best quality) -r, -resolution=R Set rendering resolution to R (in pixels/drawing unit) This overrides the width/height parameters. -t, -format File format (png, jpeg, gif) -x, -width=W Set bitmap width to W (in pixels) -y, -height=H Set bitmap height to H (in pixels) -p, -origin Draw zero point (origin) -z, -zoomlevels Number of zoom levels
dwghatch
(also dxfhatch)
dwghatch creates a solid fill hatch entity using all closed paths in the given drawing file as boundary. Boundary loops contained in other boundary loops are considered to be islands.
Usage: ./dwghatch [OPTIONS]... <data file>
Fill all fillable (closed) boundaries of the given drawing
file (DXF, DWG) with a solid fill hatch.
-f, -force Overwrite existing output file
-h, -help Display this help
-o FILE, -output=FILE Set CAD output file to FILE
merge
merge is a powerful tool to merge multiple drawing files (DXF,DWG,...) into one. Each drawing can be individually positioned, rotated, scaled and flipped horizontally or vertically. One of the parameters when calling merge is an XML file which defined what drawings are inserted and where, at what angle, etc. The insert tag may be repeated to insert the same drawing multiple times with different parameters.
Usage: ./merge [OPTIONS]... <XML config file>
Merges multiple drawing files (DWG, DXF, ...) into one.
-f, -force Overwrite existing output file
-h, -help Display this help
-t TYPE, -type=TYPE Set file type to TYPE
(e.g. R12...R27 or 2000...2013)
-o FILE, -outfile=FILE Set output file to FILE
default is same path and base name as input file
XML format:
<?xml version="1.0" encoding="UTF-8"?>
<merge xmlns="http://qcad.org/merge/elements/1.0/" unit="Millimeter">
<insert x="15" y="0" angle="-30" flipx="false" flipy="false" />
<item src="/file2.dxf">
</merge>