cad 12 KB

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