xref: /dragonfly/contrib/file/magic/Magdir/cad (revision 739f0ef867128a933e021db3d831e906fcafd825)
1
2#------------------------------------------------------------------------------
3# $File: cad,v 1.29 2021/12/06 19:33:27 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    ;;\020HSF\020V                OpenHSF (Hoops Stream Format)
305>7        regex/9 V[.0-9]{4,5}\020      %s
306!:ext hsf
307
308# AutoCAD Drawing Exchange Format
3090         regex               \^[\ \t]*0\r?\000$
310>1        regex               \^[\ \t]*SECTION\r?$
311>>2       regex               \^[\ \t]*2\r?$
312>>>3      regex               \^[\ \t]*HEADER\r?$ AutoCAD Drawing Exchange Format
313!:mime    application/x-dxf
314!:ext     dxf
315>>>>&1    search/8192         AC1006                        \b, R10
316>>>>&1    search/8192         AC1009                        \b, R11/R12
317>>>>&1    search/8192         AC1012                        \b, R13
318>>>>&1    search/8192         AC1013                        \b, R13c3
319>>>>&1    search/8192         AC1014                        \b, R14
320>>>>&1    search/8192         AC1015                        \b, version 2000
321>>>>&1    search/8192         AC1018                        \b, version 2004
322>>>>&1    search/8192         AC1021                        \b, version 2007
323>>>>&1    search/8192         AC1024                        \b, version 2010
324>>>>&1    search/8192         AC1027                        \b, version 2013
325>>>>&1    search/8192         AC1032                        \b, version 2018
326>>>>&1    search/8192         AC1035                        \b, version 2021
327
328# The Sketchup 3D model format https://www.sketchup.com/
3290         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
330!:mime application/vnd.sketchup.skp
331!:ext skp
332
3334         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
334!:strength +40
335
336# glTF (GL Transmission Format) - by the Khronos Group
337# Reference: https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#glb-file-format-specification
3380         string              glTF                glTF binary model
339>4        ulelong             x                   \b, version %d
340>8        ulelong             x                   \b, length %d bytes
341!:mime    model/gltf-binary
342!:ext     glb
343
344# FBX (FilmBoX) - by Kaydara/Autodesk
345# Reference: https://code.blender.org/2013/08/fbx-binary-file-format-specification
3460         string    Kaydara\ FBX\ Binary\ \ \0    Kaydara FBX model,
347>&2       ulelong   x         version %d
348!:ext     fbx
349
350# PLY (Polygon File Format/Stanford Triangle Format) - by Greg Turk
351# Reference: https://web.archive.org/web/20161204152348/http://www.dcs.ed.ac.uk/teaching/cs4/www/graphics/Web/ply.html
3520         string    ply\n               PLY model,
353!:ext     ply
354>4        string    format\ ascii\      ASCII,
355>>&0      regex/6   [0-9.]+             version %s
356>4        string    format\ binary      binary,
357>>&0      string    _little_endian\     little endian,
358>>>&0     regex/6   [0-9.]+             version %s
359>>&0      string    _big_endian\        big endian,
360>>>&0     regex/6   [0-9.]+             version %s
361
362# VRML (Virtual Reality Modeling Language) - by the Web3D Consortium
363# From:      Michel Briand <michelbriand@free.fr>
364# Reference: https://www.web3d.org/standards
3650         string/w  #VRML\ V1.0\ ascii  VRML 1 file
366!:mime    model/vrml
367!:ext     wrl
3680         string/w  #VRML\ V2.0\ utf8   ISO/IEC 14772 VRML 97 file
369!:mime    model/vrml
370!:ext     wrl
371# X3D, VRML encoded
3720         string    #X3D      X3D (Extensible 3D) model, VRML format
373>4        string    V
374>>5       regex/6   [0-9.]+   \b, version %s
375!:mime    model/x3d+vrml
376!:ext     x3dv
377
378## XML-based 3D CAD Formats
379# From: Michel Briand <michelbriand@free.fr>, Oliver Galvin <odg@riseup.net>
3800         string/w        \<?xml\ version=
381!:strength + 5
382# X3D (Extensible 3D)
383# Schema:    https://www.web3d.org/specifications/x3d-3.2.dtd
384# MIME Type: https://www.iana.org/assignments/media-types/model/x3d+xml
385# Example:   https://www.web3d.org/x3d/content/examples/Basic/course/CreateX3DFromStringRandomSpheres.x3d
386>20       search/1000/w   \<!DOCTYPE\ X3D         X3D (Extensible 3D) model, XML document
387!:mime    model/x3d+xml
388!:ext     x3d
389# COLLADA (COLLAborative Design Activity) - by the Khronos Group
390# Schema:    http://www.collada.org/2005/11/COLLADASchema
391# Reference: https://www.khronos.org/collada
392>20       search/1000/w       \<COLLADA COLLADA model, XML document
393!:mime    model/vnd.collada+xml
394!:ext     dae
395# 3MF (3D Manufacturing Format) - by the 3MF Consortium
396# Schema:    http://schemas.microsoft.com/3dmanufacturing/core/2015/02
397# Reference: https://3mf.io/specification
398>20       search/1000/w       xmlns="http://schemas.microsoft.com/3dmanufacturing         3MF (3D Manufacturing Format) model, XML document
399!:mime    model/3mf
400!:ext     3mf
401# AMF (Additive Manufacturing File)
402# Reference: https://www.astm.org/Standards/ISOASTM52915.htm
403>20       search/1000/w       \<amf     AMF (Additive Manufacturing Format) model, XML document
404!:mime    application/x-amf
405!:ext     amf
406