@design-core/core 0.0.1 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/.eslintrc.json +14 -7
  2. package/.github/workflows/DesignCoreQA.yml +3 -1
  3. package/README.md +11 -4
  4. package/TODO.md +19 -0
  5. package/core/core/core.js +49 -42
  6. package/core/designCore.js +61 -2
  7. package/core/dimensions/alignedDimension.js +142 -0
  8. package/core/dimensions/angularDimension.js +550 -0
  9. package/core/dimensions/baseCircularDimension.js +244 -0
  10. package/core/dimensions/baseDimension.js +558 -0
  11. package/core/dimensions/baseLinearDimension.js +371 -0
  12. package/core/dimensions/diametricDimension.js +82 -0
  13. package/core/dimensions/dimension.js +298 -0
  14. package/core/dimensions/linearDimension.js +29 -0
  15. package/core/dimensions/radialDimension.js +78 -0
  16. package/core/dimensions/rotatedDimension.js +167 -0
  17. package/core/entities/arc.js +314 -60
  18. package/core/entities/arctext.js +642 -0
  19. package/core/entities/basePolyline.js +553 -94
  20. package/core/entities/circle.js +181 -54
  21. package/core/entities/entity.js +154 -74
  22. package/core/entities/hatch.js +807 -0
  23. package/core/entities/insert.js +200 -39
  24. package/core/entities/line.js +196 -134
  25. package/core/entities/lwpolyline.js +21 -44
  26. package/core/entities/point.js +194 -29
  27. package/core/entities/polyline.js +54 -7
  28. package/core/entities/rectangle.js +43 -13
  29. package/core/entities/solid.js +43 -6
  30. package/core/entities/text.js +324 -181
  31. package/core/lib/boundingBox.js +73 -13
  32. package/core/lib/canvas.js +256 -65
  33. package/core/lib/clipboard.js +198 -0
  34. package/core/lib/colour.js +144 -0
  35. package/core/lib/colours.js +367 -301
  36. package/core/lib/commandLine.js +16 -28
  37. package/core/lib/commandManager.js +115 -58
  38. package/core/lib/constants.js +23 -0
  39. package/core/lib/dxf/dxf.js +249 -34
  40. package/core/lib/dxf/dxfFile.js +23 -38
  41. package/core/lib/dxf/dxfIterator.js +17 -5
  42. package/core/lib/dxf/dxfRead.js +23 -7
  43. package/core/lib/dxf/dxfWrite.js +39 -129
  44. package/core/lib/dxf/handleManager.js +97 -0
  45. package/core/lib/dxf/sections/blocks.js +16 -2
  46. package/core/lib/dxf/sections/entities.js +17 -3
  47. package/core/lib/dxf/sections/header.js +10 -1
  48. package/core/lib/dxf/sections/objects.js +36 -0
  49. package/core/lib/dxf/sections/section.js +43 -5
  50. package/core/lib/dxf/sections/tables.js +17 -3
  51. package/core/lib/entityManager.js +178 -0
  52. package/core/lib/fileio.js +14 -4
  53. package/core/lib/headers.js +229 -0
  54. package/core/lib/input.js +46 -0
  55. package/core/lib/inputManager.js +199 -194
  56. package/core/lib/intersect.js +341 -468
  57. package/core/lib/logging.js +25 -1
  58. package/core/lib/matrix.js +6 -8
  59. package/core/lib/mouse.js +24 -79
  60. package/core/lib/patterns.js +690 -0
  61. package/core/lib/promptOptions.js +133 -0
  62. package/core/lib/scene.js +71 -174
  63. package/core/lib/selectionManager.js +74 -48
  64. package/core/lib/selectionWindow.js +24 -10
  65. package/core/lib/settings.js +18 -11
  66. package/core/lib/snapping.js +129 -21
  67. package/core/lib/stateManager.js +288 -0
  68. package/core/lib/strings.js +57 -5
  69. package/core/lib/utils.js +95 -11
  70. package/core/objects/dictionary.js +43 -0
  71. package/core/objects/dictionaryManager.js +80 -0
  72. package/core/properties/dimType.js +117 -0
  73. package/core/properties/flags.js +66 -0
  74. package/core/properties/property.js +26 -0
  75. package/core/properties/propertyManager.js +65 -19
  76. package/core/tables/appId.js +31 -0
  77. package/core/tables/appIdManager.js +44 -0
  78. package/core/tables/block.js +323 -0
  79. package/core/tables/blockManager.js +48 -0
  80. package/core/tables/blockRecord.js +29 -0
  81. package/core/tables/blockRecordManager.js +37 -0
  82. package/core/tables/dimStyle.js +627 -0
  83. package/core/tables/dimStyleManager.js +187 -0
  84. package/core/tables/endblk.js +28 -0
  85. package/core/tables/layer.js +219 -0
  86. package/core/tables/layerManager.js +47 -0
  87. package/core/tables/ltype.js +85 -0
  88. package/core/tables/ltypeManager.js +65 -0
  89. package/core/tables/style.js +145 -0
  90. package/core/tables/styleManager.js +55 -0
  91. package/core/tables/styleManagerBase.js +110 -0
  92. package/core/tables/tableManagerBase.js +354 -0
  93. package/core/tables/ucs.js +28 -0
  94. package/core/tables/ucsManager.js +44 -0
  95. package/core/tables/view.js +28 -0
  96. package/core/tables/viewManager.js +44 -0
  97. package/core/tables/vport.js +70 -0
  98. package/core/tables/vportManager.js +65 -0
  99. package/core/tools/chamfer.js +343 -0
  100. package/core/tools/chamferFilletBase.js +162 -0
  101. package/core/tools/copy.js +68 -40
  102. package/core/tools/copybase.js +65 -0
  103. package/core/tools/copyclip.js +59 -0
  104. package/core/tools/cornerEntity.js +138 -0
  105. package/core/tools/cutclip.js +72 -0
  106. package/core/tools/distance.js +37 -9
  107. package/core/tools/erase.js +43 -13
  108. package/core/tools/explode.js +117 -0
  109. package/core/tools/extend.js +71 -32
  110. package/core/tools/fillet.js +336 -0
  111. package/core/tools/identify.js +33 -6
  112. package/core/tools/matchProp.js +106 -0
  113. package/core/tools/mirror.js +141 -0
  114. package/core/tools/move.js +65 -32
  115. package/core/tools/offset.js +321 -0
  116. package/core/tools/pan.js +54 -0
  117. package/core/tools/pasteclip.js +93 -0
  118. package/core/tools/purge.js +90 -0
  119. package/core/tools/rotate.js +105 -70
  120. package/core/tools/scale.js +166 -0
  121. package/core/tools/tool.js +14 -4
  122. package/core/tools/trim.js +71 -32
  123. package/core/tools/zoom.js +152 -0
  124. package/package.json +3 -305
  125. package/test/dimensions/alignedDimension.test.js +211 -0
  126. package/test/dimensions/angularDimension.test.js +243 -0
  127. package/test/dimensions/baseDimension.test.js +239 -0
  128. package/test/dimensions/diametricDimension.test.js +203 -0
  129. package/test/dimensions/dimension.test.js +102 -0
  130. package/test/dimensions/radialDimension.test.js +203 -0
  131. package/test/dimensions/rotatedDimension.test.js +224 -0
  132. package/test/entities/arc.test.js +463 -41
  133. package/test/entities/arctext.test.js +329 -0
  134. package/test/entities/basePolyline.test.js +459 -10
  135. package/test/entities/circle.test.js +312 -7
  136. package/test/entities/entity.test.js +28 -9
  137. package/test/entities/hatch.test.js +606 -0
  138. package/test/entities/insert.test.js +90 -0
  139. package/test/entities/line.test.js +182 -6
  140. package/test/entities/point.test.js +375 -37
  141. package/test/entities/solid.test.js +156 -0
  142. package/test/entities/text.test.js +533 -7
  143. package/test/integration/exportIntegration.reference.dxf +1706 -0
  144. package/test/integration/exportIntegration.test.js +186 -0
  145. package/test/integration/importExportIntegration.test.js +126 -0
  146. package/test/integration/intersectionIntegration.test.js +880 -0
  147. package/test/integration/userInputIntegration.reference.dxf +1410 -0
  148. package/test/integration/userInputIntegration.test.js +269 -0
  149. package/test/lib/boundingBox.test.js +26 -2
  150. package/test/lib/canvas.test.js +613 -5
  151. package/test/lib/clipboard.test.js +70 -0
  152. package/test/lib/colour.test.js +114 -0
  153. package/test/lib/colours.test.js +63 -18
  154. package/test/lib/commandLine.test.js +159 -22
  155. package/test/lib/commandManager.test.js +4 -4
  156. package/test/lib/constants.test.js +9 -0
  157. package/test/lib/dxf/dxfFile.test.js +6 -2
  158. package/test/lib/dxf/dxfIterator.test.js +1 -1
  159. package/test/lib/dxf/dxfWrite.test.js +173 -0
  160. package/test/lib/dxf/handleManager.test.js +137 -0
  161. package/test/lib/dxf/sections/blocks.test.js +5 -5
  162. package/test/lib/dxf/sections/entities.test.js +4 -4
  163. package/test/lib/dxf/sections/header.test.js +18 -4
  164. package/test/lib/dxf/sections/objects.test.js +132 -0
  165. package/test/lib/dxf/sections/section.test.js +29 -29
  166. package/test/lib/dxf/sections/tables.test.js +3 -3
  167. package/test/lib/entityManager.test.js +163 -0
  168. package/test/lib/headers.test.js +233 -0
  169. package/test/lib/inputManager.test.js +1144 -5
  170. package/test/lib/intersect.test.js +454 -331
  171. package/test/lib/logging.test.js +1 -1
  172. package/test/lib/matrix.test.js +1 -1
  173. package/test/lib/mouse.test.js +327 -4
  174. package/test/lib/patterns.test.js +105 -0
  175. package/test/lib/promptOptions.test.js +179 -0
  176. package/test/lib/scene.test.js +16 -52
  177. package/test/lib/selectionManager.test.js +17 -5
  178. package/test/lib/settings.test.js +111 -5
  179. package/test/lib/snapping.test.js +142 -4
  180. package/test/lib/stateManager.test.js +155 -0
  181. package/test/lib/utils.test.js +81 -1
  182. package/test/objects/dictionary.test.js +81 -0
  183. package/test/objects/dictionaryManager.test.js +34 -0
  184. package/test/properties/dimType.test.js +62 -0
  185. package/test/properties/flags.test.js +164 -0
  186. package/test/properties/property.test.js +13 -0
  187. package/test/properties/propertyManager.test.js +10 -11
  188. package/test/tables/appId.test.js +46 -0
  189. package/test/tables/appIdManager.test.js +72 -0
  190. package/test/tables/block.test.js +157 -0
  191. package/test/tables/blockManager.test.js +52 -0
  192. package/test/tables/blockRecord.test.js +39 -0
  193. package/test/tables/blockRecordManager.test.js +60 -0
  194. package/test/tables/dimstyle.test.js +72 -0
  195. package/test/tables/endblk.test.js +30 -0
  196. package/test/tables/layer.test.js +95 -0
  197. package/test/tables/layerManager.test.js +172 -0
  198. package/test/{styles → tables}/ltype.test.js +7 -7
  199. package/test/{styles → tables}/ltypeManager.test.js +2 -2
  200. package/test/tables/style.test.js +44 -0
  201. package/test/tables/stylemanagerbase.test.js +220 -0
  202. package/test/tables/tableManagerBase.test.js +194 -0
  203. package/test/tables/ucs.test.js +37 -0
  204. package/test/tables/ucsManager.test.js +48 -0
  205. package/test/tables/view.test.js +37 -0
  206. package/test/tables/viewManager.test.js +48 -0
  207. package/test/tables/vport.test.js +117 -0
  208. package/test/tables/vportManager.test.js +54 -0
  209. package/test/test-helpers/test-helpers.js +66 -0
  210. package/test/tools/chamfer.test.js +970 -0
  211. package/test/tools/chamferFilletBase.test.js +446 -0
  212. package/test/tools/copy.test.js +22 -14
  213. package/test/tools/copybase.test.js +93 -0
  214. package/test/tools/copyclip.test.js +92 -0
  215. package/test/tools/cornerEntity.test.js +201 -0
  216. package/test/tools/cutclip.test.js +94 -0
  217. package/test/tools/distance.test.js +140 -18
  218. package/test/tools/erase.test.js +12 -12
  219. package/test/tools/explode.test.js +45 -0
  220. package/test/tools/extend.test.js +326 -44
  221. package/test/tools/fillet.test.js +831 -0
  222. package/test/tools/identify.test.js +115 -16
  223. package/test/tools/matchProp.test.js +84 -0
  224. package/test/tools/mirror.test.js +475 -0
  225. package/test/tools/move.test.js +75 -19
  226. package/test/tools/offset.test.js +748 -0
  227. package/test/tools/pan.test.js +72 -0
  228. package/test/tools/pasteclip.test.js +100 -0
  229. package/test/tools/purge.test.js +89 -0
  230. package/test/tools/rotate.test.js +89 -23
  231. package/test/tools/scale.test.js +529 -0
  232. package/test/tools/trim.test.js +419 -84
  233. package/test/tools/zoom.test.js +504 -0
  234. package/core/entities/alignedDimension.js +0 -279
  235. package/core/entities/angularDimension.js +0 -194
  236. package/core/entities/baseDimension.js +0 -227
  237. package/core/entities/block.js +0 -247
  238. package/core/entities/diametricDimension.js +0 -133
  239. package/core/entities/dimension.js +0 -202
  240. package/core/entities/radialDimension.js +0 -126
  241. package/core/styles/dimStyle.js +0 -719
  242. package/core/styles/dimStyleManager.js +0 -47
  243. package/core/styles/layer.js +0 -133
  244. package/core/styles/layerManager.js +0 -40
  245. package/core/styles/ltype.js +0 -86
  246. package/core/styles/ltypeManager.js +0 -50
  247. package/core/styles/style.js +0 -158
  248. package/core/styles/styleManager.js +0 -43
  249. package/core/styles/styleManagerBase.js +0 -299
  250. package/test/entities/block.test.js +0 -22
  251. package/test/styles/dimstyle.test.js +0 -19
  252. package/test/styles/layerManager.test.js +0 -150
  253. package/test/styles/style.test.js +0 -33
  254. package/test/styles/stylemanagerbase.test.js +0 -219
@@ -1,719 +0,0 @@
1
- import {DXFFile} from '../lib/dxf/dxfFile.js';
2
- import {Logging} from '../lib/logging.js';
3
-
4
- export class DimStyle {
5
- constructor(data) {
6
- // Define Properties
7
- this.type = this.constructor.name;
8
- this.standardFlags = 0;
9
- this.name = '';
10
- this.DIMPOST = ''; // 3 - General dimensioning suffix
11
- this.DIMAPOST = ''; // 4 - Alternate dimensioning suffix
12
- this.DIMBLK = ''; // 5 - Arrow block name
13
- this.DIMBLK1 = ''; // 6 - First arrow block name
14
- this.DIMBLK2 = ''; // 7 - Second arrow block name
15
- this.DIMSCALE = 1.0; // 40 - dimension scale
16
- this.DIMASZ = 2.5; // 41 - arrow size
17
- this.DIMEXO = 0.625; // 42 - offset from origin
18
- this.DIMDLI = 3.75; // 43 - Baseline spacing
19
- this.DIMEXE = 1.25; // 44- extend beyond dim lines
20
- this.DIMRND = 0.0; // 45 - Rounding value for dimension distances
21
- this.DIMDLE = 0.0; // 46 - Dimension line extension
22
- this.DIMTP = 0.0; // 47 - Plus tolerance
23
- this.DIMTM = 0.0; // 48 - Minus tolerance
24
- this.DIMTXT = 2.5; // 140 - Dimensioning text height
25
- this.DIMCEN = 2.5; // 141 - centre marks
26
- this.DIMTSZ = 0.0; // 142 - Dimensioning tick size; 0 = no ticks
27
- this.DIMALTF = 0.0394; // 143 - multiplier for alternate units
28
- this.DIMLFAC = 1.0; // 144 - Measurement scale factor
29
- this.DIMTVP = 0.0; // 145 - Text vertical position, The DIMTVP value is used when DIMTAD is off.
30
- this.DIMTFAC = 1.0; // 146 - Dimension tolerance display scale factor
31
- this.DIMGAP = 0.6250; // 147 - offset from dimline
32
- this.DIMTOL = 0; // 71 - Dimension tolerances generated if nonzero
33
- this.DIMLIM = 0; // 72 - Dimension limits generated if nonzero
34
- this.DIMTIH = 0; // 73 - Text inside horizontal if nonzero, 0 = Aligns text with the dimension line, 1 = Draws text horizontally
35
- this.DIMTOH = 0; // 74 - Text outside horizontal if nonzero, 0 = Aligns text with the dimension line, 1 = Draws text horizontally
36
- this.DIMSE1 = false; // 75 - First extension line suppressed if nonzero
37
- this.DIMSE2 = false; // 76 - Second extension line suppressed if nonzero
38
- this.DIMTAD = 0; // 77 -Text above dimension line if nonzero
39
- this.DIMZIN = 0; // 78 - Zero suppression for “feet & inch” dimensions
40
- this.DIMALT = 0; // 170 - Alternate unit dimensioning performed if nonzero
41
- this.DIMALTD = 2; // 171 - Alternate unit decimal places
42
- this.DIMTOFL = 0; // 172 - If text outside extensions, force line extensions between extensions if nonzero
43
- this.DIMSAH = 0; // 173 - Use separate arrow blocks if nonzero
44
- this.DIMTIX = 0; // 174 - Force text inside extensions if nonzero
45
- this.DIMSOXD = 0; // 175 - Suppress outside-extensions dimension lines if nonzero
46
- this.DIMCLRD = 0; // 176 - Dimension line color, range is 0 = BYBLOCK, 256 = BYLAYER
47
- this.DIMCLRE = 0; // 177 - Dimension extension line color, range is 0 = BYBLOCK, 256 = BYLAYER
48
- this.DIMCLRT = 0; // 178 - Dimension text color, range is 0 = BYBLOCK, 256 = BYLAYER
49
- this.DIMADEC = 0; // 179 - Number of precision places displayed in angular dimensions - Stored as dictionary
50
- this.DIMUNIT= 2; // 270 - (obsolete, now use DIMLUNIT AND DIMFRAC)
51
- this.DIMDEC = 2; // 271 - Number of decimal places for the tolerance values of a primary units dimension
52
- this.DIMTDEC = 2; // 272 - Number of decimal places to display the tolerance values
53
- this.DIMALTU = 2; // 273 - Units format for alternate units of all dimension style family members except angular
54
- this.DIMALTTD = 3; // 274 - Number of decimal places for tolerance values of an alternate units dimension
55
- this.DIMAUNIT = 0; // 275 - Angle format for angular dimensions
56
- this.DIMFRAC = 0; // 276 - Fraction format when DIMLUNIT is set to 4 (Architectural) or 5 (Fractional).
57
- this.DIMLUNIT = 2; // 277 - Sets units for all dimension types except Angular
58
- this.DIMDSEP = ','; // 278 - Single-character decimal separator used when creating dimensions whose unit format is decimal - Stored as dictionary
59
- this.DIMTMOVE = 0; // 279 - Dimension text movement rules
60
- this.DIMJUST = 0; // 280 - Horizontal dimension text position
61
- this.DIMSD1 = false; // 281 - Suppression of first extension line
62
- this.DIMSD2 = false; // 282 - Suppression of second extension line
63
- this.DIMTOLJ = 0; // 283 - Vertical justification for tolerance values
64
- this.DIMTZIN = 8; // 284 - Controls suppression of zeros for tolerance values
65
- this.DIMALTZ = 0; // 285 - Controls suppression of zeros for alternate unit dimension values
66
- this.DIMALTTZ = 0; // 286 - Controls suppression of zeros for alternate tolerance values
67
- this.DIMFIT = 3; // 287 - (obsolete, now use DIMATFIT and DIMTMOVE)
68
- this.DIMUPT = 0; // 288 - Cursor functionality for user-positioned text, 0 = Cursor controls only the dimension line location, 1 = Cursor controls both the text position and the dimension line location
69
- this.DIMATFIT = 3; // 289 - Controls dimension text and arrow placement when space is not sufficient to place both within the extension lines
70
- this.DIMTXSTY = 'Standard'; // 340 - (handle of referenced STYLE)
71
- this.DIMLDRBLK = ''; // 341 - (handle of referenced BLOCK)
72
- this.DIMBLK = ''; // 342 - (handle of referenced BLOCK)
73
- this.DIMBLK1 = ''; // 343 - (handle of referenced BLOCK)
74
- this.DIMBLK2 = ''; // 344 - (handle of referenced BLOCK)
75
- this.DIMLWD = -2; // 371 - (lineweight enum value)
76
- this.DIMLWE = -2; // 372 - (lineweight enum value)
77
-
78
- /*
79
- The following properties are not implemented
80
- DIMALTRND - R2000
81
- DIMANNO - R2008
82
- DIMARCSYM - R2007
83
- DIMASSOC - 2002
84
- DIMASO - OBSOLETE
85
- DIMAZIN - R2000
86
- DIMCONSTRAINTICON - R2010
87
- DIMFXL - R2007
88
- DIMFXLON - R2007
89
- DIMJOGANG - R2007
90
- DIMLTEX1 - R2007
91
- DIMLTEX2 - R2007
92
- DIMLTYPE - R2007
93
- DIMSHO - OBSOLETE
94
- DIMTFILL - R2007
95
- DIMTFILLCLR - R2007
96
- DIMTXTDIRECTION - R2010
97
- */
98
-
99
- if (data) {
100
- if (data.name || data[2]) {
101
- // DXF Groupcode 2 - ltype name
102
- this.name = data.name || data[2];
103
- }
104
-
105
- if (data[3]) {
106
- // DXF Groupcode 3 - General dimensioning suffix
107
- this.DIMPOST = data[3];
108
- }
109
-
110
- if (data[4]) {
111
- // DXF Groupcode 4 - Alternate dimensioning suffix
112
- this.DIMAPOST = data[4];
113
- }
114
-
115
- if (data[5]) {
116
- // DXF Groupcode 5 - Arrow block name
117
- this.DIMBLK = data[5];
118
-
119
- const err = 'DXF Groupcode 5 - obsolete';
120
- Logging.instance.warn(`${this.type} - ${err}`);
121
- }
122
-
123
- if (data[6]) {
124
- // DXF Groupcode 6 - First arrow block name
125
- this.DIMBLK1 = data[6];
126
-
127
- const err = 'DXF Groupcode 6 - obsolete';
128
- Logging.instance.warn(`${this.type} - ${err}`);
129
- }
130
-
131
- if (data[7]) {
132
- // DXF Groupcode 7 - Second arrow block name
133
- this.DIMBLK2 = data[7];
134
-
135
- const err = 'DXF Groupcode 7 - obsolete';
136
- Logging.instance.warn(`${this.type} - ${err}`);
137
- }
138
-
139
- if (data[40]) {
140
- // DXF Groupcode 40 - dimension scale
141
- /*
142
- Sets the overall scale factor applied to dimensioning variables that specify sizes, distances, or offsets.
143
- Also affects the leader objects with the LEADER command.
144
- Use MLEADERSCALE to scale multileader objects created with the MLEADER command.
145
- 0.0 = A reasonable default value is computed based on the scaling between the current model space viewport and paper space.
146
- If you are in paper space or model space and not using the paper space feature, the scale factor is 1.0.
147
- >0 = A scale factor is computed that leads text sizes, arrowhead sizes, and other scaled distances to plot at their face values.
148
-
149
- DIMSCALE does not affect measured lengths, coordinates, or angles.
150
- Use DIMSCALE to control the overall scale of dimensions.
151
- However, if the current dimension style is annotative, DIMSCALE is automatically set to zero and the dimension scale is controlled by the CANNOSCALE system variable.
152
- DIMSCALE cannot be set to a non-zero value when using annotative dimensions.
153
- */
154
- this.DIMSCALE = data[40];
155
- }
156
-
157
- if (data[41]) {
158
- // DXF Groupcode 41 - arrow size
159
- this.DIMASZ = data[41];
160
- }
161
-
162
- if (data[42]) {
163
- // DXF Groupcode 42 - offset from origin
164
- this.DIMEXO = data[42];
165
- }
166
-
167
- if (data[43]) {
168
- // DXF Groupcode 43 - Baseline spacing
169
- this.DIMDLI = data[43];
170
- }
171
-
172
- if (data[44]) {
173
- // DXF Groupcode 44- extend beyond dim lines
174
- this.DIMEXE = data[44];
175
- }
176
-
177
- if (data[45]) {
178
- // DXF Groupcode 45 - Rounding value for dimension distances
179
- this.DIMRND = data[45];
180
- }
181
-
182
- if (data[45]) {
183
- // DXF Groupcode 46 - Dimension line extension
184
- this.DIMDLE = data[46];
185
- }
186
-
187
- if (data[47]) {
188
- // DXF Groupcode 47 - Plus tolerance
189
- this.DIMTP = data[47];
190
- }
191
-
192
- if (data[48]) {
193
- // DXF Groupcode 48 - Minus tolerance
194
- this.DIMTM = data[48];
195
- }
196
-
197
- if (data[140]) {
198
- // DXF Groupcode 140 - Dimensioning text height
199
- this.DIMTXT = data[140];
200
- }
201
-
202
- if (data[141]) {
203
- // DXF Groupcode 141 - centre marks
204
- this.DIMCEN = data[141];
205
- }
206
-
207
- if (data[142]) {
208
- // DXF Groupcode 142 - Dimensioning tick size; 0 = no ticks
209
- this.DIMTSZ = data[142];
210
- }
211
-
212
- if (data[143]) {
213
- // DXF Groupcode 143 - multiplier for alternate units
214
- this.DIMALTF = data[143];
215
- }
216
-
217
- if (data[144]) {
218
- // DXF Groupcode 144 - Measurement scale factor
219
- this.DIMLFAC = data[144];
220
- }
221
-
222
- if (data[145]) {
223
- // DXF Groupcode 145 - Text vertical position
224
- this.DIMTVP = data[145];
225
- }
226
-
227
- if (data[146]) {
228
- // DXF Groupcode 146 - Dimension tolerance display scale factor
229
- this.DIMTFAC = data[146];
230
- }
231
-
232
- if (data[147]) {
233
- // DXF Groupcode 147 - offset from dimline
234
- // The value of DIMGAP is also used as the minimum length of each segment of the dimension line.
235
- // To locate the components of a linear dimension within the extension lines, enough space must be available for both arrowheads (2 x DIMASZ),
236
- // both dimension line segments (2 x DIMGAP), a gap on either side of the dimension text (another 2 x DIMGAP), and the length of the dimension text,
237
- // which depends on its size and number of decimal places displayed
238
- this.DIMGAP = data[147];
239
- }
240
-
241
- if (data.standardFlags || data[70]) {
242
- // DXF Groupcode 70 - standard flags
243
- /*
244
- 1 = If set, this entry describes a shape
245
- 4 = Vertical text
246
- 16 = If set, table entry is externally dependent on an xref
247
- 32 = If this bit and bit 16 are both set, the externally dependent xref has been successfully resolved
248
- 64 = If set, the table entry was referenced by at least one entity in the drawing the last time the drawing was edited.
249
- (This flag is for the benefit of AutoCAD commands. It can be ignored.
250
- */
251
- this.standardFlags = data.standardFlags || data[70];
252
- }
253
-
254
- if (data[71]) {
255
- // DXF Groupcode 71 - Dimension tolerances generated if nonzero
256
- // Setting DIMTOL to on (1) turns DIMLIM off (0)
257
- this.DIMTOL = data[71];
258
- }
259
-
260
- if (data[72]) {
261
- // DXF Groupcode 72 - Dimension limits generated if nonzero
262
- // 0 = Dimension limits are not generated as default text
263
- // 1 = Dimension limits are generated as default text
264
- // Setting DIMLIM to on (1) turns DIMTOL off (0)
265
- this.DIMLIM = data[72];
266
- }
267
-
268
- if (data[73]) {
269
- // DXF Groupcode 73 - Text inside horizontal if nonzero
270
- // 0 = Aligns text with the dimension line
271
- // 1 = Draws text horizontally
272
- this.DIMTIH = data[73];
273
- }
274
-
275
- if (data[74]) {
276
- // DXF Groupcode 74 - Text outside horizontal if nonzero
277
- // 0 = Aligns text with the dimension line
278
- // 1 = Draws text horizontally
279
- this.DIMTOH = data[74];
280
- }
281
-
282
- if (data[75]) {
283
- // DXF Groupcode 75 - First extension line suppressed if nonzero
284
- this.DIMSE1 = Boolean(data[75]);
285
- }
286
-
287
- if (data[76]) {
288
- // DXF Groupcode 76 - Second extension line suppressed if nonzero
289
- this.DIMSE2 = Boolean(data[76]);
290
- }
291
-
292
- if (data[77]) {
293
- // DXF Groupcode 77 -Text above dimension line if nonzero
294
- // 0 = Centers the dimension text between the extension lines.
295
- // 1 = Places the dimension text above the dimension line except when the dimension line is not horizontal and text inside the extension lines is forced horizontal ( DIMTIH = 1). The distance from the dimension line to the baseline of the lowest line of text is the current DIMGAP value.
296
- // 2 = Places the dimension text on the side of the dimension line farthest away from the defining points.
297
- // 3 = Places the dimension text to conform to Japanese Industrial Standards (JIS).
298
- // 4 = Places the dimension text below the dimension line.
299
-
300
- this.DIMTAD = data[77];
301
- }
302
-
303
- if (data[78]) {
304
- // DXF Groupcode 78 - Zero suppression for “feet & inch” dimensions
305
- /*
306
- Values 0-3 affect feet-and-inch dimensions only:
307
-
308
- 0 = Suppresses zero feet and precisely zero inches
309
- 1 = Includes zero feet and precisely zero inches
310
- 2 = Includes zero feet and suppresses zero inches
311
- 3 = Includes zero inches and suppresses zero feet
312
- 4 = Suppresses leading zeros in decimal dimensions (for example, 0.5000 becomes .5000)
313
- 8 = Suppresses trailing zeros in decimal dimensions (for example, 12.5000 becomes 12.5)
314
- 12 = Suppresses both leading and trailing zeros (for example, 0.5000 becomes .5)
315
- */
316
- this.DIMZIN = data[78];
317
- }
318
-
319
- if (data[170]) {
320
- // DXF Groupcode 170 - Alternate unit dimensioning performed if nonzero
321
- this.DIMALT = data[170];
322
- }
323
-
324
- if (data[171]) {
325
- // DXF Groupcode 171 - Alternate unit decimal places
326
- this.DIMALTD = data[171];
327
- }
328
-
329
- if (data[172]) {
330
- // DXF Groupcode 172 - If text outside extensions, force line extensions between extensions if nonzero
331
- this.DIMTOFL = data[172];
332
- }
333
-
334
- if (data[173]) {
335
- // DXF Groupcode 173 - Use separate arrow blocks if nonzero
336
- /*
337
- Off = Use arrowhead blocks set by DIMBLK
338
- On = Use arrowhead blocks set by DIMBLK1 and DIMBLK2
339
- */
340
- this.DIMSAH = data[173];
341
- }
342
-
343
- if (data[174]) {
344
- // DXF Groupcode 174 - Force text inside extensions if nonzero
345
- /*
346
- Off = Varies with the type of dimension.
347
- For linear and angular dimensions, text is placed inside the extension lines if there is sufficient room.
348
- For radius and diameter dimensions that don’t fit inside the circle or arc, DIMTIX has no effect and always forces the text outside the circle or arc.
349
-
350
- On = Draws dimension text between the extension lines even if it would ordinarily be placed outside those lines
351
- */
352
- this.DIMTIX = data[174];
353
- }
354
-
355
- if (data[175]) {
356
- // DXF Groupcode 175 - Suppress outside-extensions dimension lines if nonzero
357
- /*
358
- If not enough space is available inside the extension lines and DIMTIX is on, setting DIMSOXD to On suppresses the arrowheads.
359
- If DIMTIX is off, DIMSOXD has no effect
360
-
361
- Off = Arrowheads are not suppressed
362
- On = Arrowheads are suppressed
363
- */
364
- this.DIMSOXD = data[175];
365
- }
366
-
367
- if (data[176]) {
368
- // DXF Groupcode 176 - Dimension line color, range is 0 = BYBLOCK, 256 = BYLAYER
369
- this.DIMCLRD = data[176];
370
- }
371
-
372
- if (data[177]) {
373
- // DXF Groupcode 177 - Dimension extension line color, range is 0 = BYBLOCK, 256 = BYLAYER
374
- this.DIMCLRE = data[177];
375
- }
376
-
377
- if (data[178]) {
378
- // DXF Groupcode 178 - Dimension text color, range is 0 = BYBLOCK, 256 = BYLAYER
379
- this.DIMCLRT = data[178];
380
- }
381
-
382
- if (data[179]) {
383
- // DXF Groupcode 179 - Number of precision places displayed in angular dimensions
384
- this.DIMADEC = data[179];
385
- }
386
-
387
- if (data[270]) {
388
- // DXF Groupcode 270 - (obsolete, now use DIMLUNIT AND DIMFRAC)
389
- this.DIMUNIT = data[270];
390
-
391
- const err = `obsolete group code - 270`;
392
- Logging.instance.warn(`${this.type} - ${err}`);
393
- }
394
-
395
- if (data[271]) {
396
- // DXF Groupcode 271 - Number of decimal places for the tolerance values of a primary units dimension
397
- this.DIMDEC = data[271];
398
- }
399
-
400
- if (data[272]) {
401
- // DXF Groupcode 272 - Number of decimal places to display the tolerance values
402
- // This system variable has no effect unless DIMTOL is set to On. The default for DIMTOL is Off
403
- this.DIMTDEC = data[272];
404
- }
405
-
406
- if (data[273]) {
407
- // DXF Groupcode 273 - Units format for alternate units of all dimension style family members except angular:
408
- // 1 = Scientific; 2 = Decimal; 3 = Engineering;
409
- // 4 = Architectural (stacked); 5 = Fractional (stacked);
410
- // 6 = Architectural; 7 = Fractional
411
- this.DIMALTU = data[273];
412
- }
413
-
414
- if (data[274]) {
415
- // DXF Groupcode 274 - Number of decimal places for tolerance values of an alternate units dimension
416
- this.DIMALTTD = data[274];
417
- }
418
-
419
- if (data[275]) {
420
- // DXF Groupcode 275 - Angle format for angular dimensions:
421
- // 0 = Decimal degrees; 1 = Degrees/minutes/seconds;
422
- // 2 = Gradians; 3 = Radians; 4 = Surveyor’s units
423
- this.DIMAUNIT = data[275];
424
- }
425
-
426
- if (data[276]) {
427
- // DXF Groupcode 276 - Fraction format when DIMLUNIT is set to 4 (Architectural) or 5 (Fractional).
428
- this.DIMFRAC = data[276];
429
- }
430
-
431
- if (data[277]) {
432
- // DXF Groupcode 277 - Sets units for all dimension types except Angular:
433
- // 1 = Scientific; 2 = Decimal; 3 = Engineering;
434
- // 4 = Architectural; 5 = Fractional; 6 = Windows desktop
435
- this.DIMLUNIT = data[277];
436
- }
437
-
438
- if (data[278]) {
439
- // DXF Groupcode 278 - Single-character decimal separator used when creating dimensions whose unit format is decimal
440
- // Period - ?
441
- // Comma - 44
442
- // Space - 32
443
- this.DIMDSEP = data[278];
444
- }
445
-
446
- if (data[279]) {
447
- // DXF Groupcode 279 - Dimension text movement rules:
448
- // 0 = Moves the dimension line with dimension text
449
- // 1 = Adds a leader when dimension text is moved
450
- // 2 = Allows text to be moved freely without a leader
451
- this.DIMTMOVE = data[279];
452
- }
453
-
454
- if (data[280]) {
455
- // DXF Groupcode 280 - Horizontal dimension text position:
456
- // 0 = Above dimension line and center-justified between extension lines
457
- // 1 = Above dimension line and next to first extension line
458
- // 2 = Above dimension line and next to second extension line
459
- // 3 = Above and center-justified to first extension line
460
- // 4 = Above and center-justified to second extension line
461
- this.DIMJUST = data[280];
462
- }
463
-
464
- if (data[281]) {
465
- // DXF Groupcode 281 - Suppression of first extension line:
466
- // 0 = Not suppressed; 1 = Suppressed
467
- this.DIMSD1 = Boolean(data[281]);
468
- }
469
-
470
- if (data[282]) {
471
- // DXF Groupcode 282 - Suppression of second extension line:
472
- // 0 = Not suppressed; 1 = Suppressed
473
- this.DIMSD2 = Boolean(data[282]);
474
- }
475
-
476
- if (data[283]) {
477
- // DXF Groupcode 283 - Vertical justification for tolerance values:
478
- // 0 = Top; 1 = Middle; 2 = Bottom
479
- this.DIMTOLJ = data[283];
480
- }
481
-
482
- if (data[284]) {
483
- // DXF Groupcode 284 - Controls suppression of zeros for tolerance values:
484
- // 0 = Suppresses zero feet and precisely zero inches
485
- // 1 = Includes zero feet and precisely zero inches
486
- // 2 = Includes zero feet and suppresses zero inches
487
- // 3 = Includes zero inches and suppresses zero feet
488
- this.DIMTZIN = data[284];
489
- }
490
-
491
- if (data[285]) {
492
- // DXF Groupcode 285 - Controls suppression of zeros for alternate unit dimension values:
493
- // 0 = Suppresses zero feet and precisely zero inches
494
- // 1 = Includes zero feet and precisely zero inches
495
- // 2 = Includes zero feet and suppresses zero inches
496
- // 3 = Includes zero inches and suppresses zero feet
497
- this.DIMALTZ = data[285];
498
- }
499
-
500
- if (data[286]) {
501
- // DXF Groupcode 286 - Controls suppression of zeros for alternate tolerance values:
502
- // 0 = Suppresses zero feet and precisely zero inches
503
- // 1 = Includes zero feet and precisely zero inches
504
- // 2 = Includes zero feet and suppresses zero inches
505
- // 3 = Includes zero inches and suppresses zero feet
506
- this.DIMALTTZ = data[286];
507
- }
508
-
509
- if (data[287]) {
510
- // DXF Groupcode 287 - (obsolete, now use DIMATFIT and DIMTMOVE)
511
- this.DIMFIT = data[287];
512
-
513
- const err = `obsolete group code - 287`;
514
- Logging.instance.warn(`${this.type} - ${err}`);
515
- }
516
-
517
- if (data[288]) {
518
- // DXF Groupcode 288 - Cursor functionality for user-positioned text:
519
- // 0 = Controls only the dimension line location
520
- // 1 = Controls the text position as well as the dimension line location
521
- this.DIMUPT = data[288];
522
- }
523
-
524
- if (data[289]) {
525
- // DXF Groupcode 289 - Controls dimension text and arrow placement when space is not sufficient to place both within the extension lines:
526
- // 0 = Places both text and arrows outside extension lines
527
- // 1 = Moves arrows first, then text
528
- // 2 = Moves text first, then arrows
529
- // 3 = Moves either text or arrows, whichever fits best AutoCAD adds a leader to moved dimension text when DIMTMOVE is set to 1
530
- this.DIMATFIT = data[289];
531
- }
532
-
533
- if (data[340]) {
534
- // DXF Groupcode 340 - (handle of referenced STYLE)
535
- this.DIMTXSTY = data[340];
536
- }
537
-
538
- if (data[341]) {
539
- // DXF Groupcode 341 - (handle of referenced BLOCK)
540
- this.DIMLDRBLK = data[341];
541
- }
542
-
543
- if (data[342]) {
544
- // DXF Groupcode 342 - (handle of referenced BLOCK)
545
- /*
546
- “” = closed filled
547
- “_DOT” = dot
548
- “_DOTSMALL” = dot small
549
- “_DOTBLANK”= dot blank
550
- “_ORIGIN” = origin indicator
551
- “_ORIGIN2” = origin indicator 2
552
- “_OPEN” = open
553
- “_OPEN90” = right angle
554
- “_OPEN30” = open 30
555
- “_CLOSED” = closed
556
- “_SMALL” = dot small blank
557
- “_NONE” = none
558
- “_OBLIQUE” = oblique
559
- “_BOXFILLED” = box filled
560
- “_BOXBLANK” = box
561
- “_CLOSEDBLANK” = closed blank
562
- “_DATUMFILLED” = datum triangle filled
563
- “_DATUMBLANK” = datum triangle
564
- “_INTEGRAL” = integral
565
- “_ARCHTICK” = architectural tick
566
- */
567
- this.DIMBLK = data[342];
568
- }
569
-
570
- if (data[343]) {
571
- // DXF Groupcode 343 - (handle of referenced BLOCK)
572
- this.DIMBLK1 = data[343];
573
- }
574
-
575
- if (data[344]) {
576
- // DXF Groupcode 344 - (handle of referenced BLOCK)
577
- this.DIMBLK2 = data[344];
578
- }
579
-
580
- if (data[371]) {
581
- // DXF Groupcode 371 - (lineweight enum value)
582
- /*
583
- -3 Default (the LWDEFAULT value)
584
- -2 BYBLOCK
585
- -1 BYLAYER
586
- */
587
- this.DIMLWD = data[371];
588
- }
589
-
590
- if (data[372]) {
591
- // DXF Groupcode 372 - (lineweight enum value)
592
- /*
593
- -3 Default (the LWDEFAULT value)
594
- -2 BYBLOCK
595
- -1 BYLAYER
596
- */
597
- this.DIMLWE = data[372];
598
- }
599
- }
600
-
601
- const err = 'DXF Groupcodes incomplete';
602
- Logging.instance.warn(`${this.type} - ${err}`);
603
- }
604
-
605
- /**
606
- * Get valueName property value from dimstyle
607
- * @param {string} valueName
608
- * @returns value or undefined
609
- */
610
- getValue(valueName) {
611
- if (this.hasOwnProperty(valueName)) {
612
- return this[valueName];
613
- }
614
-
615
- const err = `Getting Value - ${valueName}`;
616
- Logging.instance.warn(`${this.type} - ${err}`);
617
- return;
618
- }
619
-
620
- /**
621
- * Get the vertical value
622
- * @returns {bool}
623
- */
624
- get vertical() {
625
- // Vertical value is bitmasked in standardflags as value 4
626
- return Boolean(this.standardFlags & 4);
627
- }
628
-
629
- /**
630
- * Set the vertical value
631
- * @param {boolean} bool
632
- */
633
- set vertical(bool) {
634
- if (bool) {
635
- // Add vertical flag
636
- this.standardFlags = (this.standardFlags | 4);
637
- } else {
638
- // remove vertical flag
639
- this.standardFlags = (this.standardFlags ^ (this.standardFlags & 4));
640
- }
641
- }
642
-
643
-
644
- dxf(file) {
645
- file.writeGroupCode('0', 'DIMSTYLE');
646
- file.writeGroupCode('105', file.nextHandle(), DXFFile.Version.R2000); // Handle
647
- file.writeGroupCode('100', 'AcDbSymbolTableRecord', DXFFile.Version.R2000);
648
- file.writeGroupCode('100', 'AcDbDimStyleTableRecord', DXFFile.Version.R2000);
649
- file.writeGroupCode('2', this.name); // Stylename
650
- file.writeGroupCode('70', this.standardFlags);
651
- file.writeGroupCode('3', this.DIMPOST);
652
- file.writeGroupCode('4', this.DIMAPOST);
653
- file.writeGroupCode('5', this.DIMBLK);
654
- file.writeGroupCode('6', this.DIMBLK1);
655
- file.writeGroupCode('7', this.DIMBLK2);
656
- file.writeGroupCode('40', this.DIMSCALE);
657
- file.writeGroupCode('41', this.DIMASZ);
658
- file.writeGroupCode('42', this.DIMEXO);
659
- file.writeGroupCode('43', this.DIMDLI);
660
- file.writeGroupCode('44', this.DIMEXE);
661
- file.writeGroupCode('45', this.DIMRND);
662
- file.writeGroupCode('46', this.DIMDLE);
663
- file.writeGroupCode('47', this.DIMTP);
664
- file.writeGroupCode('48', this.DIMTM);
665
- file.writeGroupCode('140', this.DIMTXT);
666
- file.writeGroupCode('141', this.DIMCEN);
667
- file.writeGroupCode('142', this.DIMTSZ);
668
- file.writeGroupCode('143', this.DIMALTF);
669
- file.writeGroupCode('144', this.DIMLFAC);
670
- file.writeGroupCode('145', this.DIMTVP);
671
- file.writeGroupCode('146', this.DIMTFAC);
672
- file.writeGroupCode('147', this.DIMGAP);
673
- file.writeGroupCode('71', this.DIMTOL);
674
- file.writeGroupCode('72', this.DIMLIM);
675
- file.writeGroupCode('73', this.DIMTIH);
676
- file.writeGroupCode('74', this.DIMTOH);
677
- file.writeGroupCode('75', this.DIMSE1 ? 1 : 0); // convert bool to int
678
- file.writeGroupCode('76', this.DIMSE2 ? 1 : 0); // convert bool to int
679
- file.writeGroupCode('77', this.DIMTAD);
680
- file.writeGroupCode('78', this.DIMZIN);
681
- file.writeGroupCode('170', this.DIMALT);
682
- file.writeGroupCode('171', this.DIMALTD);
683
- file.writeGroupCode('172', this.DIMTOFL);
684
- file.writeGroupCode('173', this.DIMSAH);
685
- file.writeGroupCode('174', this.DIMTIX);
686
- file.writeGroupCode('175', this.DIMSOXD);
687
- file.writeGroupCode('176', this.DIMCLRD);
688
- file.writeGroupCode('177', this.DIMCLRE);
689
- file.writeGroupCode('178', this.DIMCLRT);
690
- file.writeGroupCode('179', this.DIMADEC, DXFFile.Version.R14);
691
- // file.writeGroupCode('270', this.DIMUNIT); // obsolete, now use DIMLUNIT AND DIMFRAC
692
- file.writeGroupCode('271', this.DIMDEC);
693
- file.writeGroupCode('272', this.DIMTDEC, DXFFile.Version.R13);
694
- file.writeGroupCode('273', this.DIMALTU, DXFFile.Version.R13);
695
- file.writeGroupCode('274', this.DIMALTTD, DXFFile.Version.R13);
696
- file.writeGroupCode('275', this.DIMAUNIT, DXFFile.Version.R13);
697
- file.writeGroupCode('276', this.DIMFRAC, DXFFile.Version.R2000);
698
- file.writeGroupCode('277', this.DIMLUNIT, DXFFile.Version.R2000);
699
- // file.writeGroupCode('278', this.DIMDSEP, DXFFile.Version.R14)); - TODO: AutoCAD uses a numberical description
700
- file.writeGroupCode('279', this.DIMTMOVE, DXFFile.Version.R2000);
701
- file.writeGroupCode('280', this.DIMJUST, DXFFile.Version.R13);
702
- file.writeGroupCode('281', this.DIMSD1 ? 1 : 0, DXFFile.Version.R13); // convert bool to int
703
- file.writeGroupCode('282', this.DIMSD2 ? 1 : 0, DXFFile.Version.R13); // convert bool to int
704
- file.writeGroupCode('283', this.DIMTOLJ, DXFFile.Version.R13);
705
- file.writeGroupCode('284', this.DIMTZIN, DXFFile.Version.R13);
706
- file.writeGroupCode('285', this.DIMALTZ, DXFFile.Version.R13);
707
- file.writeGroupCode('286', this.DIMALTTZ, DXFFile.Version.R13);
708
- file.writeGroupCode('287', this.DIMFIT);
709
- file.writeGroupCode('288', this.DIMUPT, DXFFile.Version.R13);
710
- file.writeGroupCode('289', this.DIMATFIT, DXFFile.Version.R2000);
711
- file.writeGroupCode('340', this.DIMTXSTY, DXFFile.Version.R13);
712
- file.writeGroupCode('341', this.DIMLDRBLK, DXFFile.Version.R2000);
713
- file.writeGroupCode('342', this.DIMBLK);
714
- file.writeGroupCode('343', this.DIMBLK1);
715
- file.writeGroupCode('344', this.DIMBLK2);
716
- file.writeGroupCode('371', this.DIMLWD, DXFFile.Version.R2000);
717
- file.writeGroupCode('372', this.DIMLWE, DXFFile.Version.R2000);
718
- }
719
- }