xref: /dragonfly/contrib/file/magic/Magdir/cad (revision 655933d6)
1
2#------------------------------------------------------------------------------
3# $File: cad,v 1.25 2021/02/23 00:51:10 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 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	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!:mime	image/x-3ds
291!:ext 3ds
292
293# MegaCAD 2D/3D drawing (.prt)
294# https://megacad.de/
295# From: Markus Heidelberg <markus.heidelberg@web.de>
2960	string	MegaCad23\0	MegaCAD 2D/3D drawing
297
298# Hoops CAD files
299# https://docs.techsoft3d.com/visualize/3df/latest/build/general/hsf/\
300# HSF_architecture.html
301# Stephane Charette <stephane.charette@gmail.com>
3020	string	;;\020HSF\020V		OpenHSF (Hoops Stream Format)
303>7	regex/9 V[.0-9]{4,5}\020	%s
304!:ext hsf
305
306# AutoCAD Drawing Exchange Format
3070	regex		\^[\ \t]*0\r?\000$
308>1	regex		\^[\ \t]*SECTION\r?$
309>>2	regex		\^[\ \t]*2\r?$
310>>>3	regex		\^[\ \t]*HEADER\r?$	AutoCAD Drawing Exchange Format
311!:mime	application/x-dxf
312!:ext	dxf
313>>>>&1	search/8192	AC1006			\b, R10
314>>>>&1	search/8192	AC1009			\b, R11/R12
315>>>>&1	search/8192	AC1012			\b, R13
316>>>>&1	search/8192	AC1013			\b, R13c3
317>>>>&1	search/8192	AC1014			\b, R14
318>>>>&1	search/8192	AC1015			\b, version 2000
319>>>>&1	search/8192	AC1018			\b, version 2004
320>>>>&1	search/8192	AC1021			\b, version 2007
321>>>>&1	search/8192	AC1024			\b, version 2010
322>>>>&1	search/8192	AC1027			\b, version 2013
323>>>>&1	search/8192	AC1032			\b, version 2018
324>>>>&1	search/8192	AC1035			\b, version 2021
325
326# The Sketchup 3D model format https://www.sketchup.com/
3270	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
328!:mime application/vnd.sketchup.skp
329!:ext skp
330
3314	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
332!:strength +40
333