2 #------------------------------------------------------------------------------
3 # $File: cad,v 1.23 2020/05/30 23:58:07 christos Exp $
4 # autocad: file(1) magic for cad files
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.
13 # http://www.wotsit.org/search.asp
14 # https://filext.com/detaillist.php?extdetail=DGN
15 # https://filext.com/detaillist.php?extdetail=CIT
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
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
28 0 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
42 # test for length of 1st element is multiple of blocks a 512 bytes
45 # test for DGN or CEL by jump words (uleshort) forward to next element
47 # 2nd element type: 8~Digitizer~DesiGNfile 1~library cell header other~CIT
48 #>>&1 ubyte&0x7F x \b, 2nd type %u
51 >>>2 uleshort =0x02FE Bentley/Intergraph Microstation CAD drawing
52 !:mime application/x-bentley-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
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
96 #>>>>>32 uleshort&0x000F !0 \b, class 0x%4.4x
98 #>>>>>34 uleshort x \b, Symbology 0x%4.4x
99 # test for 2nd element type 1~library cell header
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
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
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
118 >>4 uleshort 0x0018 \b, CCITT Group 4 1-bit
119 !:mime image/x-intergraph-cit
121 >>4 uleshort 27 \b, Adaptive RLE RGB
122 !:mime image/x-intergraph-rgb
125 >>>4 uleshort x \b, Type %u
126 !:mime image/x-intergraph
128 #>4 uleshort 0 \b, no data
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
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
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
170 #>492 ubequad !0 \b, MinValue 0x%llx
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
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
181 0 string MC0.0 DWG AutoDesk AutoCAD Release 1.0
183 0 string AC1.2 DWG AutoDesk AutoCAD Release 1.2
185 0 string AC1.3 DWG AutoDesk AutoCAD Release 1.3
187 0 string AC1.40 DWG AutoDesk AutoCAD Release 1.40
189 0 string AC1.50 DWG AutoDesk AutoCAD Release 2.05
191 0 string AC2.10 DWG AutoDesk AutoCAD Release 2.10
193 0 string AC2.21 DWG AutoDesk AutoCAD Release 2.21
195 0 string AC2.22 DWG AutoDesk AutoCAD Release 2.22
197 0 string AC1001 DWG AutoDesk AutoCAD Release 2.22
199 0 string AC1002 DWG AutoDesk AutoCAD Release 2.50
201 0 string AC1003 DWG AutoDesk AutoCAD Release 2.60
203 0 string AC1004 DWG AutoDesk AutoCAD Release 9
205 0 string AC1006 DWG AutoDesk AutoCAD Release 10
207 0 string AC1009 DWG AutoDesk AutoCAD Release 11/12
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)
214 0 string AC1012 DWG AutoDesk AutoCAD Release 13
216 0 string AC1014 DWG AutoDesk AutoCAD Release 14
218 0 string AC1015 DWG AutoDesk AutoCAD 2000/2002
221 # A new version of AutoCAD DWG
222 # Sergey Zaykov (mail_of_sergey@mail.ru, sergey_zaikov@rambler.ru,
224 # From various sources like:
225 # https://autodesk.blogs.com/between_the_lines/autocad-release-history.html
226 0 string AC1018 DWG AutoDesk AutoCAD 2004/2005/2006
228 0 string AC1021 DWG AutoDesk AutoCAD 2007/2008/2009
230 0 string AC1024 DWG AutoDesk AutoCAD 2010/2011/2012
232 0 string AC1027 DWG AutoDesk AutoCAD 2013-2017
236 0 string AC1032 DWG AutoDesk AutoCAD 2018/2019
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)
248 # https://sd.ascon.ru/otrs/customer.pl?Action=CustomerFAQ&CategoryID=4&ItemID=292
249 # (in russian) and my experiments
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
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.
281 # 3DS (3d Studio files)
285 >>>16 leshort 0x3d3d 3D Studio model
289 # MegaCAD 2D/3D drawing (.prt)
290 # https://megacad.de/
291 # From: Markus Heidelberg <markus.heidelberg@web.de>
292 0 string MegaCad23\0 MegaCAD 2D/3D drawing
295 # https://docs.techsoft3d.com/visualize/3df/latest/build/general/hsf/\
296 # HSF_architecture.html
297 # Stephane Charette <stephane.charette@gmail.com>
298 0 string ;;\020HSF\020V OpenHSF (Hoops Stream Format)
299 >7 regex/9 V[.0-9]{4,5}\020 %s
302 # AutoCAD Drawing Exchange Format
303 0 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
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
318 # The Sketchup 3D model format https://www.sketchup.com/
319 0 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
323 4 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