cad 15 KB

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