@buerli.io/headless 0.4.0-beta.2 → 0.4.0-beta.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.
@@ -1,4 +1,4 @@
1
- import { BooleanOperationType, ChamferType, FlipType, ReorientedType, WorkAxisType, WorkCoordSystemType, WorkPlaneType, WorkPointType, ViewType, OrientationType, ExtrusionType, BrepElemType } from '@buerli.io/classcad';
1
+ import { BooleanOperationType, ChamferType, FlipType, ReorientedType, WorkAxisType, WorkCoordSystemType, WorkPlaneType, WorkPointType, ViewType, OrientationType, ExtrusionType, BrepElemType, SVGModusType } from '@buerli.io/classcad';
2
2
  import { ObjectID, PointMemValue } from '@buerli.io/core';
3
3
  import { BufferGeometry, Scene } from 'three';
4
4
  /**
@@ -154,16 +154,20 @@ export declare type ApiHistory = {
154
154
  /**
155
155
  * Creates different 2D views, depending on the given view types, in the given product.
156
156
  * @param productId id of the product where the view will be created in
157
- * @param viewTypes array of view types. E.g. 'Top', 'Front', 'Iso', ...
157
+ * @param viewTypes array of view types. E.g. [ViewType.TOP, ViewType.RIGHT_90, ViewType.ISO, ...
158
+ * @param viewOptions optional object of options (currently color and layer) to set for the views.
159
+ * - color: number value 0 - 256, see AutoCAD Color Index (ACI). 256 = color defined by layer
160
+ * - layer: string value, defines the view's layer
161
+ * - Default = { color: 256, layer: '0'}
158
162
  * @example
159
163
  * // Optionally add dimensions to the product, see addDimension() or addDimensions()
160
164
  * await api.addDimensions(...)
161
165
  *
162
166
  * // Create the wanted views
163
- * await api.create2DViews(productId, ['Top', 'Right_90°', 'Iso'])
167
+ * await api.create2DViews(productId, [ViewType.TOP, ViewType.RIGHT_90, ViewType.ISO], { color: 2, layer: '6'})
164
168
  * @image // tbd
165
169
  */
166
- create2DViews: (productId: VID, viewTypes: ViewType[]) => IDs;
170
+ create2DViews: (productId: VID, viewTypes: ViewType[], viewOptions?: ViewOptionsType) => IDs;
167
171
  /**
168
172
  * This method returns the boundary box of the given views.
169
173
  * @param productId id of the product from where the boundary box will returned
@@ -196,23 +200,35 @@ export declare type ApiHistory = {
196
200
  /**
197
201
  * Export the placed views as dxf file.
198
202
  * @param productId id of the product where the views exist for export
203
+ * @param dxfTemplateFilename optional filename to load different dxf template. E.g. 'StandardTemplate.dxf'
199
204
  * @example
200
205
  * // After creating and placing the views, see place2DViews(), you can export them
201
206
  * // You will get the dxf stream back
202
207
  * await api.exportDXF(productId)
203
208
  * @image // tbd
204
209
  */
205
- exportDXF: (productId: VID) => Promise<Uint8Array | null>;
210
+ exportDXF: (productId: VID, dxfTemplateFilename?: string) => Promise<Uint8Array | null>;
206
211
  /**
207
- * Export the placed views as svg file.
212
+ * Exports the placed views as dxf and converts it into svg stream.
208
213
  * @param productId id of the product where the views exist for export
214
+ * @param modus optional modus to define how drawing will fit into svg file,
215
+ * - SVGModusType.WHOLE_DRAWING or SVGModusType.FIT_WHOLE_DRAWING
216
+ * - Default = SVGModusType.FIT_WHOLE_DRAWING
217
+ * @param renderSize optional rendered size [x, y] of the drawing.
218
+ * - x = horizontal size, y = vertical size
219
+ * - Default = 1024 x 768
220
+ * - Effects only if modus = SVGModusType.WHOLE_DRAWING
221
+ * @param dxfTemplateFilename optional filename to load different dxf template. E.g. 'StandardTemplate.dxf'
209
222
  * @example
210
223
  * // After creating and placing the views, see place2DViews(), you can export them
211
224
  * // You will get the svg stream back
212
225
  * await api.exportSVG(productId)
213
226
  * @image // tbd
214
227
  */
215
- exportSVG: (productId: VID) => Promise<Uint8Array | null>;
228
+ exportSVG: (productId: VID, modus?: SVGModusType, renderSize?: {
229
+ x: number;
230
+ y: number;
231
+ }, dxfTemplateFilename?: string) => Promise<Uint8Array | null>;
216
232
  /**
217
233
  * Remove existing dimensions from the view.
218
234
  * @param dimensionsIds ids of the dimensions to be removed
@@ -1166,6 +1182,10 @@ export declare type DimensionType = {
1166
1182
  };
1167
1183
  dxfView: ViewType;
1168
1184
  };
1185
+ export declare type ViewOptionsType = {
1186
+ color?: number;
1187
+ layer?: string;
1188
+ };
1169
1189
  /**
1170
1190
  * Information about constraint.
1171
1191
  * [
package/build/history.js CHANGED
@@ -6,7 +6,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
6
6
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
7
7
  };
8
8
  /* eslint-disable max-lines */
9
- import { ccAPI, CCClasses, ccUtils, DataType, } from '@buerli.io/classcad';
9
+ import { ccAPI, CCClasses, ccUtils, DataType, SVGModusType, } from '@buerli.io/classcad';
10
10
  import { api, getDrawing, lineSegmentsFilter, loopFilter, MathUtils, planeFilter, pointFilter, } from '@buerli.io/core';
11
11
  import { Group, Mesh, MeshStandardMaterial, Scene, Vector3 } from 'three';
12
12
  import * as BufferGeometryUtils_ from 'three/examples/jsm/utils/BufferGeometryUtils';
@@ -310,7 +310,7 @@ export default class CAD {
310
310
  dim.dimParam.dimTextAngle,
311
311
  dim.dimParam.dimOrientation,
312
312
  dim.dimParam.dimColor || 256,
313
- dim.dimParam.dimLayer || '2',
313
+ dim.dimParam.dimLayer || '1',
314
314
  ],
315
315
  dim.dxfView,
316
316
  ];
@@ -337,7 +337,7 @@ export default class CAD {
337
337
  dim.dimParam.dimTextAngle,
338
338
  dim.dimParam.dimOrientation,
339
339
  dim.dimParam.dimColor || 256,
340
- dim.dimParam.dimLayer || '2',
340
+ dim.dimParam.dimLayer || '1',
341
341
  ],
342
342
  dim.dxfView,
343
343
  ]);
@@ -346,9 +346,11 @@ export default class CAD {
346
346
  return ccAPI.drawing2D.addDimensions(drawingId, dimsToAdd);
347
347
  }, ...dimensions);
348
348
  },
349
- create2DViews: (productId, viewTypes) => {
349
+ create2DViews: (productId, viewTypes, viewOptions) => {
350
350
  return this.resolve(async ([rProductId]) => {
351
- const viewIds = await ccAPI.drawing2D.create2DViews(drawingId, rProductId, viewTypes);
351
+ const color = (viewOptions === null || viewOptions === void 0 ? void 0 : viewOptions.color) ? viewOptions.color : 256;
352
+ const layer = (viewOptions === null || viewOptions === void 0 ? void 0 : viewOptions.layer) ? viewOptions.layer : '0';
353
+ const viewIds = await ccAPI.drawing2D.create2DViews(drawingId, rProductId, viewTypes, [color, layer]);
352
354
  if (viewIds !== null) {
353
355
  await ccAPI.drawing2D.centerAllViews(drawingId, rProductId, viewTypes);
354
356
  return viewIds;
@@ -373,14 +375,16 @@ export default class CAD {
373
375
  return ccAPI.drawing2D.place2DViews(drawingId, rProductId, viewPositionParams);
374
376
  }, productId);
375
377
  },
376
- exportDXF: (productId) => {
378
+ exportDXF: (productId, dxfTemplateFilename) => {
377
379
  return this.resolve(async ([rProductId]) => {
378
- return ccAPI.drawing2D.exportDXF(drawingId, rProductId);
380
+ return ccAPI.drawing2D.exportDXF(drawingId, rProductId, dxfTemplateFilename);
379
381
  }, productId);
380
382
  },
381
- exportSVG: (productId) => {
383
+ exportSVG: (productId, modus, renderSize, dxfTemplateFilename) => {
382
384
  return this.resolve(async ([rProductId]) => {
383
- return ccAPI.drawing2D.exportSVG(drawingId, rProductId);
385
+ modus = modus ? modus : SVGModusType.FIT_WHOLE_DRAWING;
386
+ const renderSizeParam = (renderSize === null || renderSize === void 0 ? void 0 : renderSize.x) && (renderSize === null || renderSize === void 0 ? void 0 : renderSize.y) ? [renderSize.x, renderSize.y] : undefined;
387
+ return ccAPI.drawing2D.exportSVG(drawingId, rProductId, modus, renderSizeParam, dxfTemplateFilename);
384
388
  }, productId);
385
389
  },
386
390
  removeDimensions: (dimensionIds) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerli.io/headless",
3
- "version": "0.4.0-beta.2",
3
+ "version": "0.4.0-beta.3",
4
4
  "description": "A non-manifold CAD workflow for the web",
5
5
  "author": "AWV Informatik AG <info@awv-informatik.ch>",
6
6
  "license": "ISC",
@@ -30,7 +30,7 @@
30
30
  "three": ">=0.138"
31
31
  },
32
32
  "dependencies": {
33
- "@buerli.io/classcad": "0.4.0-beta.2",
33
+ "@buerli.io/classcad": "0.4.0-beta.3",
34
34
  "flat-promise": "^1.0.3"
35
35
  }
36
36
  }