xref: /freebsd/contrib/file/magic/Magdir/cad (revision d7d962ead0b6e5e8a39202d0590022082bf5bfb6)
1
2#------------------------------------------------------------------------------
3# $File: cad,v 1.23 2020/05/30 23:58:07 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 libray 2FEh~DGN 9FEh,DFEh~CIT
36#>2	uleshort	x			\b, words 0x%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 0x%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 0x%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 0x%4.4x
95# class 0~Primary
96#>>>>>32		uleshort&0x000F	!0		\b, class 0x%4.4x
97# Symbology
98#>>>>>34		uleshort	x		\b, Symbology 0x%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 0x%x
155# RotationAngle; Rotation angle of raster data
156#>196	ubequad		!0			\b, RotationAngle 0x%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 0x%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 0x%llx
171# MaxValue
172#>500	ubequad		!0			\b, MaxValue 0x%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	AC1014	DWG AutoDesk AutoCAD Release 14
217!:mime image/vnd.dwg
2180	string	AC1015	DWG AutoDesk AutoCAD 2000/2002
219!:mime image/vnd.dwg
220
221# A new version of AutoCAD DWG
222# Sergey Zaykov (mail_of_sergey@mail.ru, sergey_zaikov@rambler.ru,
223# ICQ 358572321)
224# From various sources like:
225# https://autodesk.blogs.com/between_the_lines/autocad-release-history.html
2260	string	AC1018	DWG AutoDesk AutoCAD 2004/2005/2006
227!:mime image/vnd.dwg
2280	string	AC1021	DWG AutoDesk AutoCAD 2007/2008/2009
229!:mime image/vnd.dwg
2300	string	AC1024	DWG AutoDesk AutoCAD 2010/2011/2012
231!:mime image/vnd.dwg
2320	string	AC1027	DWG AutoDesk AutoCAD 2013-2017
233!:mime image/vnd.dwg
234
235# From GNU LibreDWG
2360	string	AC1032	DWG AutoDesk AutoCAD 2018/2019
237!:mime image/vnd.dwg
238
239# KOMPAS 2D drawing from ASCON
240# This is KOMPAS 2D drawing or fragment of drawing but is not detailed nor
241# gathered nor specification
242# ASCON https://ascon.net/main/ in English,
243#	https://ascon.ru/ main site in Russian
244# Extension is CDW for drawing and FRW for fragment of drawing
245# Sergey Zaykov (mail_of_sergey@mail.ru, sergey_zaikov@rambler.ru,
246# ICQ 358572321, https://vkontakte.ru/id16076543)
247# From:
248# https://sd.ascon.ru/otrs/customer.pl?Action=CustomerFAQ&CategoryID=4&ItemID=292
249# (in russian) and my experiments
2500	string	KF
251>2	belong	0x4E00000C	Kompas drawing 12.0 SP1
252>2	belong	0x4D00000C	Kompas drawing 12.0
253>2	belong	0x3200000B	Kompas drawing 11.0 SP1
254>2	belong	0x3100000B	Kompas drawing 11.0
255>2	belong	0x2310000A	Kompas drawing 10.0 SP1
256>2	belong	0x2110000A	Kompas drawing 10.0
257>2	belong	0x08000009	Kompas drawing 9.0 SP1
258>2	belong	0x05000009	Kompas drawing 9.0
259>2	belong	0x33010008	Kompas drawing 8+
260>2	belong	0x1A000008	Kompas drawing 8.0
261>2	belong	0x2C010107	Kompas drawing 7+
262>2	belong	0x05000007	Kompas drawing 7.0
263>2	belong	0x32000006	Kompas drawing 6+
264>2	belong	0x09000006	Kompas drawing 6.0
265>2	belong	0x5C009005	Kompas drawing 5.11R03
266>2	belong	0x54009005	Kompas drawing 5.11R02
267>2	belong	0x51009005	Kompas drawing 5.11R01
268>2	belong	0x22009005	Kompas drawing 5.10R03
269>2	belong	0x22009005	Kompas drawing 5.10R02 mar
270>2	belong	0x21009005	Kompas drawing 5.10R02 febr
271>2	belong	0x19009005	Kompas drawing 5.10R01
272>2	belong	0xF4008005	Kompas drawing 5.9R01.003
273>2	belong	0x1C008005	Kompas drawing 5.9R01.002
274>2	belong	0x11008005	Kompas drawing 5.8R01.003
275
276# CAD: file(1) magic for computer aided design files
277# Phillip Griffith <phillip dot griffith at gmail dot com>
278# AutoCAD magic taken from the Open Design Alliance's OpenDWG specifications.
279#
280
281# 3DS (3d Studio files)
2820	leshort		0x4d4d
283>6	leshort		0x2
284>>8	lelong		0xa
285>>>16	leshort		0x3d3d	3D Studio model
286!:mime	image/x-3ds
287!:ext 3ds
288
289# MegaCAD 2D/3D drawing (.prt)
290# https://megacad.de/
291# From: Markus Heidelberg <markus.heidelberg@web.de>
2920	string	MegaCad23\0	MegaCAD 2D/3D drawing
293
294# Hoops CAD files
295# https://docs.techsoft3d.com/visualize/3df/latest/build/general/hsf/\
296# HSF_architecture.html
297# Stephane Charette <stephane.charette@gmail.com>
2980	string	;;\020HSF\020V		OpenHSF (Hoops Stream Format)
299>7	regex/9 V[.0-9]{4,5}\020	%s
300!:ext hsf
301
302# AutoCAD Drawing Exchange Format
3030	regex		\^[\ \t]*0\r?\000$
304>1	regex		\^[\ \t]*SECTION\r?$
305>>2	regex		\^[\ \t]*2\r?$
306>>>3	regex		\^[\ \t]*HEADER\r?$	AutoCAD Drawing Exchange Format
307!:mime	application/x-dxf
308!:ext	dxf
309>>>>&1	search/8192	AC1006			\b, R10
310>>>>&1	search/8192	AC1009			\b, R11/R12
311>>>>&1	search/8192	AC1012			\b, R13
312>>>>&1	search/8192	AC1014			\b, R14
313>>>>&1	search/8192	AC1015			\b, version 2000
314>>>>&1	search/8192	AC1018			\b, version 2004
315>>>>&1	search/8192	AC1021			\b, version 2007
316>>>>&1	search/8192	AC1024			\b, version 2010
317
318# The Sketchup 3D model format https://www.sketchup.com/
3190	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
320!:mime application/vnd.sketchup.skp
321!:ext skp
322
3234	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
324!:strength +40
325