xref: /freebsd/contrib/file/magic/Magdir/cad (revision 898496ee09ed2b7d25f6807edc4515628196ec0a)
1
2#------------------------------------------------------------------------------
3# $File: cad,v 1.31 2022/12/09 15:36:23 christos Exp $
4# autocad:  file(1) magic for cad files
5#
6
7# Microstation DGN/CIT Files (www.bentley.com)
8# Last updated July 29, 2005 by Lester Hightower
9# DGN is the default file extension of Microstation/Intergraph CAD files.
10# CIT is the proprietary raster format (similar to TIFF) used to attach
11# raster underlays to Microstation DGN (vector) drawings.
12#
13# http://www.wotsit.org/search.asp
14# https://filext.com/detaillist.php?extdetail=DGN
15# https://filext.com/detaillist.php?extdetail=CIT
16#
17# https://www.bentley.com/products/default.cfm?objectid=97F351F5-9C35-4E5E-89C2
18# 3F86C928&method=display&p_objectid=97F351F5-9C35-4E5E-89C280A93F86C928
19# https://www.bentley.com/products/default.cfm?objectid=A5C2FD43-3AC9-4C71-B682
20# 721C479F&method=display&p_objectid=A5C2FD43-3AC9-4C71-B682C7BE721C479F
21#
22# URL:		https://en.wikipedia.org/wiki/MicroStation
23# reference:	http://dgnlib.maptools.org/dgn.html
24#		http://dgnlib.maptools.org/dl/ref18.pdf
25# Update:	Joerg Jenderek
26# Note: verfied by command like `dgndump seed2d_b.dgn`
27# test for level 8 and type 5 or 9
280	beshort&0x3F73	0x0801
29# level of element like 8
30#>0	ubyte&0x3F	x			\b, level %u
31#>0	ubyte		&0x80			\b, complex
32#>0	ubyte		&0x40			\b, reserved
33# type of element 9~TCB 8~Digitizer setup 5~Group Data Elements
34#>1	ubyte&0x7F	x			\b, type %u
35# words to follow in element: 17H~CEL library 2FEh~DGN 9FEh,DFEh~CIT
36#>2	uleshort	x			\b, words %#4.4x to follow
37# test for 3 reserved 0 bytes in CIT or "conversion" in ViewInfo structure (DGN CEL)
38#>508	ubelong		x			\b, RESERVED %8.8x
39>508	ubelong&0xFFffFF00	=0
40# test for level 8 and type 9 for INGR raster image
41>>0	beshort		0x0809
42# test for length of 1st element is multiple of blocks a 512 bytes
43>>>2	ubyte		0xfe
44>>>>0 	use		ingr-image
45# test for DGN or CEL by jump words (uleshort) forward to next element
46>(2.s*2)	ulong		x
47# 2nd element type: 8~Digitizer~DesiGNfile 1~library cell header other~CIT
48#>>&1		ubyte&0x7F	x		\b, 2nd type %u
49# DGN
50>>&1		ubyte&0x7F	8
51>>>2		uleshort	=0x02FE		Bentley/Intergraph Microstation CAD drawing
52!:mime		application/x-bentley-dgn
53!:ext		dgn
54# The 0x40 bit of this byte is 1 if the file is 3D, otherwise 0
55>>>>1214	ubyte  		&0x40		3D
56>>>>1214	ubyte  		^0x40		2D
57# 2 chars for name of subunits like ft FT in IN mu m mm '\0 '\040
58>>>>1120	string		x		\b, units %-.2s
59# 2 chars for name of master unit like IN in ML SU tn th TH HU mm "\0 "\040 \0\0
60>>>>1122	string		>\0		%-.2s
61#>>>>1120	ubelong		x		\b, units %#8.8x
62# element range low,high x y z like xlow=0 08010000h 01080000h
63#>>>>4		ubelong	  	!0		\b, xlow %8.8x
64#>>>>8		ubelong	  	!0		\b, ylow %8.8x
65#>>>>12		ubelong	  	!0		\b, zlow %8.8x
66#>>>>16		ubelong	  	!0		\b, xhigh %8.8x
67#>>>>20		ubelong	  	!0		\b, yhigh %8.8x
68#>>>>24		ubelong	  	!0		\b, zhigh %8.8x
69# graphic group number; all other elements in that group have same non-0 number
70#>>>>28		leshort		x		\b, grphgrp %#4.4x
71# words to optional attribute linkage
72#>>>>30		ubyte		x		\b, attindx \%o
73#>>>>31		ubyte		x		\b\%o
74# >>30	string	\026\105			DGNFile
75# >>30	string	\034\105			DGNFile
76# >>30	string	\073\107			DGNFile
77# >>30	string	\073\110			DGNFile
78# >>30	string	\106\107			DGNFile
79# >>30	string	\110\103			DGNFile
80# >>30	string	\120\104			DGNFile
81# >>30	string	\172\104			DGNFile
82# >>30	string	\172\105			DGNFile
83# >>30	string	\172\106			DGNFile
84# >>30	string	\234\106			DGNFile
85# >>30	string	\273\105			DGNFile
86# >>30	string	\306\106			DGNFile
87# >>30	string	\310\104			DGNFile
88# >>30	string	\341\104			DGNFile
89# >>30	string	\372\103			DGNFile
90# >>30	string	\372\104			DGNFile
91# >>30	string	\372\106			DGNFile
92# >>30	string	\376\103			DGNFile
93# elements properties indicator
94#>>>>32		uleshort	!0		\b, properties %#4.4x
95# class 0~Primary
96#>>>>>32		uleshort&0x000F	!0		\b, class %#4.4x
97# Symbology
98#>>>>>34		uleshort	x		\b, Symbology %#4.4x
99# test for 2nd element type 1~library cell header
100>>&1		ubyte&0x7F	1
101# test for 1st element with level 8 and type 5 for cell library
102>>>0		beshort		0x0805		Bentley/Intergraph Microstation CAD cell library
103!:mime		application/x-bentley-cel
104!:ext		cel
105#
106# URL:		http://fileformats.archiveteam.org/wiki/Intergraph_Raster
107# reference:	https://web.archive.org/web/20140903185431/
108#		http://oreilly.com/www/centers/gff/formats/ingr/index.htm
109# note:		verfied by command like `nconvert -fullinfo LONGLAT.CIT`
110# display information for intergraph raster bitmap
1110	name	ingr-image
112# in 5.37 "Microstation CITFile" "Bentley/Intergraph MicroStation CIT raster CAD"
113# DataTypeCode indicates format, depth of the pixel data and used compression
114>4	uleshort	x			Intergraph raster image
115>>4	uleshort	0x0009			\b, Run-Length Encoded 1-bit
116!:mime	image/x-intergraph-rle
117!:ext	rel
118>>4	uleshort	0x0018			\b, CCITT Group 4 1-bit
119!:mime	image/x-intergraph-cit
120!:ext	cit
121>>4	uleshort	27			\b, Adaptive RLE RGB
122!:mime	image/x-intergraph-rgb
123!:ext	rgb
124>>4	default		x
125>>>4	uleshort	x			\b, Type %u
126!:mime	image/x-intergraph
127# TODO:
128#>4	uleshort	0			\b, no data
129# ...
130#>4	uleshort	0x0045			\b, Continuous Tone CMKY (Uncompressed)
131# ApplicationType: 0~generic raster image 3~drawing, scanning
132# 8~I/IMAGE and MicroStation Imager 9~ModelView
133>6	uleshort	!0			\b, ApplicationType %u
134#>6	uleshort	x			\b, ApplicationType %u
135# XViewOrigin; Raster grid data X origin
136#>8	ulequad		!0			\b, XViewOrigin %llx
137# PixelsPerLine is the number of pixels in a scan line of bitmapp
138>184	ulelong		x			\b, %u x
139# NumberOfLines is height of the raster data in scanlines
140>188	ulelong		x			%u
141# DeviceResolution; resolution of scanning device
142# positive indicates number of micros between lines; negative indicates DPI
143#>192	leshort		x			\b, DeviceResolution %d
144# ScanlineOrient indicates the origin and the orientation of the scan lines
145#>194	ubyte		x			\b, ScanlineOrient %x
146>194	ubyte		x			\b, orientation
147>194	ubyte		&0x01			right
148>194	ubyte		^0x01			left
149>194	ubyte		&0x02			down
150>194	ubyte		^0x02			top
151>194	ubyte		&0x04			horizontal
152>194	ubyte		^0x04			vertical
153# ScannableFlag; Scanline indexing method used
154#>195	ubyte		!0			\b, ScannableFlag %#x
155# RotationAngle; Rotation angle of raster data
156#>196	ubequad		!0			\b, RotationAngle %#llx
157# SkewAngle; Skew angle of raster data
158#>204	ubequad		!0			\b, SkewAngle %llx
159# DataTypeModifier; Additional raster data format info
160#>212	uleshort	!0			\b, DataTypeModifier %#4.4x
161# DesignFile[66]; Name of the design file
162>214	string		>\0			\b, DesignFile %-.66s
163# DatabaseFile[66]; Name of the database file
164>280	string		>\0			\b, DatabaseFile %-.66s
165# ParentGridFile[66]; Name of parent grid file
166>346	string		>\0			\b, ParentGridFile %-.66s
167# FileDescription[80]; Text description of file and contents
168>412	string		>\0			\b, FileDescription %-.80s
169# MinValue
170#>492	ubequad		!0			\b, MinValue %#llx
171# MaxValue
172#>500	ubequad		!0			\b, MaxValue %#llx
173# Reserved[3]; Unused (always 0)
174#>508	ubelong&0xFFffFF00	x		\b, RESERVED %8.8x
175# GridFileVersion; Grid File Version like 2 3
176#>511	ubyte		x			\b, GridFileVersion %x
177
178# AutoCAD
179# Merge of the different contributions and updates from https://en.wikipedia.org/wiki/Dwg
180# and https://www.iana.org/assignments/media-types/image/vnd.dwg
1810	string	MC0.0	DWG AutoDesk AutoCAD Release 1.0
182!:mime image/vnd.dwg
1830	string	AC1.2	DWG AutoDesk AutoCAD Release 1.2
184!:mime image/vnd.dwg
1850	string	AC1.3	DWG AutoDesk AutoCAD Release 1.3
186!:mime image/vnd.dwg
1870	string	AC1.40	DWG AutoDesk AutoCAD Release 1.40
188!:mime image/vnd.dwg
1890	string	AC1.50	DWG AutoDesk AutoCAD Release 2.05
190!:mime image/vnd.dwg
1910	string	AC2.10	DWG AutoDesk AutoCAD Release 2.10
192!:mime image/vnd.dwg
1930	string	AC2.21	DWG AutoDesk AutoCAD Release 2.21
194!:mime image/vnd.dwg
1950	string	AC2.22	DWG AutoDesk AutoCAD Release 2.22
196!:mime image/vnd.dwg
1970	string	AC1001	DWG AutoDesk AutoCAD Release 2.22
198!:mime image/vnd.dwg
1990	string	AC1002	DWG AutoDesk AutoCAD Release 2.50
200!:mime image/vnd.dwg
2010	string	AC1003	DWG AutoDesk AutoCAD Release 2.60
202!:mime image/vnd.dwg
2030	string	AC1004	DWG AutoDesk AutoCAD Release 9
204!:mime image/vnd.dwg
2050	string	AC1006	DWG AutoDesk AutoCAD Release 10
206!:mime image/vnd.dwg
2070	string	AC1009	DWG AutoDesk AutoCAD Release 11/12
208!:mime image/vnd.dwg
209# AutoCAD DWG versions R13/R14 (www.autodesk.com)
210# Written December 01, 2003 by Lester Hightower
211# Based on the DWG File Format Specifications at http://www.opendwg.org/
212# AutoCad, from Nahuel Greco
213# AutoCAD DWG versions R12/R13/R14 (www.autodesk.com)
2140	string	AC1012	DWG AutoDesk AutoCAD Release 13
215!:mime image/vnd.dwg
2160	string	AC1013	DWG AutoDesk AutoCAD Release 13c3
217!:mime image/vnd.dwg
2180	string	AC1014	DWG AutoDesk AutoCAD Release 14
219!:mime image/vnd.dwg
2200	string	AC1015	DWG AutoDesk AutoCAD 2000
221!:mime image/vnd.dwg
222
223# A new version of AutoCAD DWG
224# Sergey Zaykov (mail_of_sergey@mail.ru, sergey_zaikov@rambler.ru,
225# ICQ 358572321)
226# From various sources like:
227# https://autodesk.blogs.com/between_the_lines/autocad-release-history.html
2280	string	AC1018	DWG AutoDesk AutoCAD 2004/2005/2006
229!:mime image/vnd.dwg
2300	string	AC1021	DWG AutoDesk AutoCAD 2007/2008/2009
231!:mime image/vnd.dwg
2320	string	AC1024	DWG AutoDesk AutoCAD 2010/2011/2012
233!:mime image/vnd.dwg
2340	string	AC1027	DWG AutoDesk AutoCAD 2013-2017
235!:mime image/vnd.dwg
236
237# From GNU LibreDWG
2380	string	AC1032	DWG AutoDesk AutoCAD 2018/2019/2020
239!:mime image/vnd.dwg
2400	string	AC1035	DWG AutoDesk AutoCAD 2021
241!:mime image/vnd.dwg
242
243# KOMPAS 2D drawing from ASCON
244# This is KOMPAS 2D drawing or fragment of drawing but is not detailed nor
245# gathered nor specification
246# ASCON https://ascon.net/main/ in English,
247#	https://ascon.ru/ main site in Russian
248# Extension is CDW for drawing and FRW for fragment of drawing
249# Sergey Zaykov (mail_of_sergey@mail.ru, sergey_zaikov@rambler.ru,
250# ICQ 358572321, https://vkontakte.ru/id16076543)
251# From:
252# https://sd.ascon.ru/otrs/customer.pl?Action=CustomerFAQ&CategoryID=4&ItemID=292
253# (in russian) and my experiments
2540	string	KF
255>2	belong	0x4E00000C	Kompas drawing 12.0 SP1
256>2	belong	0x4D00000C	Kompas drawing 12.0
257>2	belong	0x3200000B	Kompas drawing 11.0 SP1
258>2	belong	0x3100000B	Kompas drawing 11.0
259>2	belong	0x2310000A	Kompas drawing 10.0 SP1
260>2	belong	0x2110000A	Kompas drawing 10.0
261>2	belong	0x08000009	Kompas drawing 9.0 SP1
262>2	belong	0x05000009	Kompas drawing 9.0
263>2	belong	0x33010008	Kompas drawing 8+
264>2	belong	0x1A000008	Kompas drawing 8.0
265>2	belong	0x2C010107	Kompas drawing 7+
266>2	belong	0x05000007	Kompas drawing 7.0
267>2	belong	0x32000006	Kompas drawing 6+
268>2	belong	0x09000006	Kompas drawing 6.0
269>2	belong	0x5C009005	Kompas drawing 5.11R03
270>2	belong	0x54009005	Kompas drawing 5.11R02
271>2	belong	0x51009005	Kompas drawing 5.11R01
272>2	belong	0x22009005	Kompas drawing 5.10R03
273>2	belong	0x22009005	Kompas drawing 5.10R02 mar
274>2	belong	0x21009005	Kompas drawing 5.10R02 febr
275>2	belong	0x19009005	Kompas drawing 5.10R01
276>2	belong	0xF4008005	Kompas drawing 5.9R01.003
277>2	belong	0x1C008005	Kompas drawing 5.9R01.002
278>2	belong	0x11008005	Kompas drawing 5.8R01.003
279
280# CAD: file(1) magic for computer aided design files
281# Phillip Griffith <phillip dot griffith at gmail dot com>
282# AutoCAD magic taken from the Open Design Alliance's OpenDWG specifications.
283#
284
285# 3DS (3d Studio files)
2860	leshort		0x4d4d
287>6	leshort		0x2
288>>8	lelong		0xa
289>>>16	leshort		0x3d3d	3D Studio model
290# Beat sgi MMV
291!:strength +20
292!:mime	image/x-3ds
293!:ext 3ds
294
295# MegaCAD 2D/3D drawing (.prt)
296# https://megacad.de/
297# From: Markus Heidelberg <markus.heidelberg@web.de>
2980	string	MegaCad23\0	MegaCAD 2D/3D drawing
299
300# Hoops CAD files
301# https://docs.techsoft3d.com/visualize/3df/latest/build/general/hsf/\
302# HSF_architecture.html
303# Stephane Charette <stephane.charette@gmail.com>
3040	string	;;\040HSF\040V		OpenHSF (Hoops Stream Format)
305>7	regex/9 V[.0-9]{4,5}\040	%s
306!:ext hsf
307
308# AutoCAD Drawing Exchange Format
309# Update:	Joerg Jenderek
310# URL:		http://fileformats.archiveteam.org/wiki/DXF
311#		https://en.wikipedia.org/wiki/AutoCAD_DXF
312# Reference:	http://mark0.net/download/triddefs_xml.7z/defs/d/
313#		dxf-var0.trid.xml dxf-var0u.trid.xml dxf-var2.trid.xml dxf-var2u.trid.xml
314# Note:		called "AutoCAD Drawing eXchange Format" by TrID and
315#		"Drawing Interchange File Format (ASCII)" by DROID
316# GRR: some samples does not match 1st test like: abydos.dxf
3170	regex		\^[\ \t]*0\r?\000$
318>1	regex		\^[\ \t]*SECTION\r?$
319>>2	regex		\^[\ \t]*2\r?$
320# GRR: some samples without HEADER section like: airplan2.dxf
321>>>3	regex		\^[\ \t]*HEADER\r?$	AutoCAD Drawing Exchange Format
322#!:mime	application/x-dxf
323!:mime	image/vnd.dxf
324!:ext	dxf
325# DROID PUID fmt/64	fmt-64-signature-id-99.dxf
326>>>>&1	search/8192	MC0.0			\b, 1.0
327# DROID PUID fmt/65	fmt-65-signature-id-100.dxf
328>>>>&1	search/8192	AC1.2			\b, 1.2
329# DROID PUID fmt/66	fmt-66-signature-id-101.dxf
330>>>>&1	search/8192	AC1.3			\b, 1.3
331# DROID PUID fmt/67	fmt-67-signature-id-102.dxf
332>>>>&1	search/8192	AC1.40			\b, 1.4
333# DROID PUID fmt/68	fmt-68-signature-id-103.dxf
334>>>>&1	search/8192	AC1.50			\b, 2.0
335# DROID PUID fmt/69	fmt-69-signature-id-104.dxf
336>>>>&1	search/8192	AC2.10			\b, 2.1
337# DROID PUID fmt/70	fmt-70-signature-id-105.dxf
338>>>>&1	search/8192	AC2.21			\b, 2.2
339# DROID PUID fmt/71	fmt-71-signature-id-106.dxf
340>>>>&1	search/8192	AC1002			\b, 2.5
341# DROID PUID fmt/72	fmt-72-signature-id-107.dxf
342>>>>&1	search/8192	AC1003			\b, 2.6
343# DROID PUID fmt/73	fmt-73-signature-id-108.dxf
344>>>>&1	search/8192	AC1004			\b, R9
345>>>>&1	search/8192	AC1006			\b, R10
346# http://cd.textfiles.com/amigaenv/DXF/OBJEKTE/LASTMINUTE/apple.dxf
347#>>>>&1	search/8192	AC1008			\b, Rfoo
348>>>>&1	search/8192	AC1009			\b, R11/R12
349>>>>&1	search/8192	AC1012			\b, R13
350>>>>&1	search/8192	AC1013			\b, R13c3
351>>>>&1	search/8192	AC1014			\b, R14
352>>>>&1	search/8192	AC1015			\b, version 2000
353>>>>&1	search/8192	AC1018			\b, version 2004
354>>>>&1	search/8192	AC1021			\b, version 2007
355>>>>&1	search/8192	AC1024			\b, version 2010
356>>>>&1	search/8192	AC1027			\b, version 2013
357>>>>&1	search/8192	AC1032			\b, version 2018
358>>>>&1	search/8192	AC1035			\b, version 2021
359
360# The Sketchup 3D model format https://www.sketchup.com/
3610	string	\xff\xfe\xff\x0e\x53\x00\x6b\x00\x65\x00\x74\x00\x63\x00\x68\x00\x55\x00\x70\x00\x20\x00\x4d\x00\x6f\x00\x64\x00\x65\x00\x6c\x00	SketchUp Model
362!:mime application/vnd.sketchup.skp
363!:ext skp
364
3654	regex/b	P[0-9][0-9]\\.[0-9][0-9][0-9][0-9]\\.[0-9][0-9][0-9][0-9]\\.[0-9]	NAXOS CAD System file from version %s
366!:strength +40
367
368# glTF (GL Transmission Format) - by the Khronos Group
369# Reference: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#glb-file-format-specification
3700	string		glTF		glTF binary model
371>4	ulelong		x		\b, version %d
372>8	ulelong		x		\b, length %d bytes
373!:mime	model/gltf-binary
374!:ext	glb
375
376# FBX (FilmBoX) - by Kaydara/Autodesk
377# Reference: https://code.blender.org/2013/08/fbx-binary-file-format-specification
3780	string	Kaydara\ FBX\ Binary\ \ \0	Kaydara FBX model,
379>&2	ulelong	x	version %d
380!:ext	fbx
381
382# PLY (Polygon File Format/Stanford Triangle Format) - by Greg Turk
383# Reference: https://web.archive.org/web/20161204152348/http://www.dcs.ed.ac.uk/teaching/cs4/www/graphics/Web/ply.html
3840	string	ply\n          	PLY model,
385!:ext	ply
386>4	string	format\ ascii\ 	ASCII,
387>>&0	regex/6	[0-9.]+        	version %s
388>4	string	format\ binary  	binary,
389>>&0	string	_little_endian\ 	little endian,
390>>>&0	regex/6	[0-9.]+         	version %s
391>>&0	string	_big_endian\ 	big endian,
392>>>&0	regex/6	[0-9.]+      	version %s
393
394# VRML (Virtual Reality Modeling Language) - by the Web3D Consortium
395# From:      Michel Briand <michelbriand@free.fr>
396# Reference: https://www.web3d.org/standards
3970	string/w	#VRML\ V1.0\ ascii	VRML 1 file
398!:mime	model/vrml
399!:ext	wrl
4000	string/w	#VRML\ V2.0\ utf8	ISO/IEC 14772 VRML 97 file
401!:mime	model/vrml
402!:ext	wrl
403# X3D, VRML encoded
4040	string	#X3D	X3D (Extensible 3D) model, VRML format
405>4	string	V
406>>5	regex/6	[0-9.]+	\b, version %s
407!:mime	model/x3d+vrml
408!:ext	x3dv
409
410## XML-based 3D CAD Formats
411# From: Michel Briand <michelbriand@free.fr>, Oliver Galvin <odg@riseup.net>
4120	string/w        \<?xml\ version=
413!:strength + 5
414# X3D (Extensible 3D)
415# Schema:    https://www.web3d.org/specifications/x3d-3.2.dtd
416# MIME Type: https://www.iana.org/assignments/media-types/model/x3d+xml
417# Example:   https://www.web3d.org/x3d/content/examples/Basic/course/CreateX3DFromStringRandomSpheres.x3d
418>20	search/1000/w   \<!DOCTYPE\ X3D         X3D (Extensible 3D) model, XML document
419!:mime	model/x3d+xml
420!:ext	x3d
421# COLLADA (COLLAborative Design Activity) - by the Khronos Group
422# Schema:    http://www.collada.org/2005/11/COLLADASchema
423# Reference: https://www.khronos.org/collada
424>20	search/1000/w	\<COLLADA	COLLADA model, XML document
425!:mime	model/vnd.collada+xml
426!:ext	dae
427# 3MF (3D Manufacturing Format) - by the 3MF Consortium
428# Schema:    http://schemas.microsoft.com/3dmanufacturing/core/2015/02
429# Reference: https://3mf.io/specification
430>20	search/1000/w	xmlns="http://schemas.microsoft.com/3dmanufacturing	3MF (3D Manufacturing Format) model, XML document
431!:mime	model/3mf
432!:ext	3mf
433# AMF (Additive Manufacturing File)
434# Reference: https://www.astm.org/Standards/ISOASTM52915.htm
435>20	search/1000/w	\<amf	AMF (Additive Manufacturing Format) model, XML document
436!:mime	application/x-amf
437!:ext	amf
438