@buerli.io/headless 0.4.0 → 0.5.0-beta.1

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.
@@ -64,7 +64,7 @@ export declare type ApiHistory = {
64
64
  ownerId: VID;
65
65
  transformation: Transform;
66
66
  name?: string;
67
- }[]) => IDs;
67
+ }[]) => Promise<ObjectID[] | null>;
68
68
  /**
69
69
  * Adds a dimension to the product in the 3D view
70
70
  * @param dimension dimension to be added to a product
@@ -150,7 +150,7 @@ export declare type ApiHistory = {
150
150
  dimLayer?: string;
151
151
  };
152
152
  dxfView: ViewType;
153
- }[]) => IDs;
153
+ }[]) => Promise<ObjectID[] | null>;
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
@@ -590,7 +590,7 @@ export declare type ApiHistory = {
590
590
  */
591
591
  createExpressions: (partId: VID, ...members: {
592
592
  name: string;
593
- value: number | PointMemValue | string;
593
+ value: number | string;
594
594
  }[]) => Promise<boolean>;
595
595
  /**
596
596
  * Creates a new assembly template. This template can be used multiple times as a sub assembly in the root assembly.
@@ -799,11 +799,11 @@ export declare type ApiHistory = {
799
799
  */
800
800
  deleteExpressions: (partId: VID, members: string[]) => Promise<boolean>;
801
801
  /**
802
- * Loads a sketch from a of1 filestream and adds its elements to a new sketch.
802
+ * Loads a sketch from a ofb filestream and adds its elements to a new sketch.
803
803
  * The id of this new created sketch will be returned.
804
804
  *
805
805
  * @param partId id of the part we want to create the new sketch and copy the sketch elements into it
806
- * @param strm stream of of1 file which contains the sketch
806
+ * @param strm stream of ofb file which contains the sketch
807
807
  * @param planeId id of the face or workplane to set the new sketch on
808
808
  * @param name optional name of the sketch to load from filestream
809
809
  */
@@ -944,7 +944,7 @@ export declare type ApiHistory = {
944
944
  * const xDir = { x: 1, y: 0, z: 0 }
945
945
  * const yDir = { x: 0, y: 1, z: 0 }
946
946
  * const nutBoltAsm = await api.createRootAssembly('NutBolt_Asm')
947
- * const bolt = await api.loadProduct(arraybuffer, 'of1')
947
+ * const bolt = await api.loadProduct(arraybuffer, 'ofb')
948
948
  * const boltRefId = await api.addNode(bolt, nutBoltAsm, [pt0, xDir, yDir])
949
949
  * const wcsIdOrigin = await api.getWorkCoordSystem(boltRefId, 'WCS_Origin')
950
950
  * await api.createFastenedOriginConstraint(nutBoltAsm, { refId: boltRefId, wcsId: wcsIdOrigin[0] }, 0, 0, 0, 0, 0, 'FOC')
@@ -982,7 +982,7 @@ export declare type ApiHistory = {
982
982
  /**
983
983
  * Writes the current drawing to a stream and returns the data.
984
984
  *
985
- * Important notes about the of1 format:
985
+ * Important notes about the ofb format:
986
986
  * - It contains binary geometry blocks.
987
987
  * - Do not try to convert it to text, the geometry blocks will get damaged!
988
988
  *
@@ -990,15 +990,15 @@ export declare type ApiHistory = {
990
990
  * @example // tbd
991
991
  * @image // tbd
992
992
  */
993
- save: (type: DataTypes) => Promise<Uint8Array | null>;
993
+ save: (type: 'ofb' | 'stp') => Promise<Uint8Array | null>;
994
994
  /**
995
995
  * POSTs the result to the given url.
996
996
  * @param url The url to POST the model to.
997
- * @param filetype The file type be saved (of1, stp).
997
+ * @param filetype The file type be saved (ofb, stp).
998
998
  * @example // tbd
999
999
  * @image // tbd
1000
1000
  */
1001
- saveToUrl: (url: string, filetype: 'of1' | 'stp') => Promise<boolean>;
1001
+ saveToUrl: (url: string, filetype: 'ofb' | 'stp') => Promise<boolean>;
1002
1002
  /**
1003
1003
  * Loads the given buffer.
1004
1004
  * @param content data as arraybuffer
@@ -1006,35 +1006,35 @@ export declare type ApiHistory = {
1006
1006
  * @example // tbd
1007
1007
  * @image // tbd
1008
1008
  */
1009
- load: (content: ArrayBuffer, type: DataTypes) => Promise<number[] | null>;
1009
+ load: (content: ArrayBuffer, type: 'ofb' | 'stp') => Promise<number[] | null>;
1010
1010
  /**
1011
1011
  * Loads from the given url.
1012
1012
  * @param url The url to load data from.
1013
- * @param filetype The type of data delivered by the url (of1, stp).
1013
+ * @param filetype The type of data delivered by the url (ofb, stp).
1014
1014
  * @example // tbd
1015
1015
  * @image // tbd
1016
1016
  */
1017
- loadFromUrl: (url: string, filetype: 'of1' | 'stp') => Promise<number[] | null>;
1017
+ loadFromUrl: (url: string, filetype: 'ofb' | 'stp') => Promise<number[] | null>;
1018
1018
  /**
1019
1019
  * Loads a product into the current drawing.
1020
1020
  * @param content data as arraybuffer
1021
1021
  * @param type type of the data to load
1022
1022
  * @example
1023
1023
  * // Loads an existing product
1024
- * const part = api.loadProduct(arraybuffer, 'of1')
1024
+ * const part = api.loadProduct(arraybuffer, 'ofb')
1025
1025
  * const geoms = await api.createBufferGeometry(part)
1026
1026
  * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1027
1027
  * @image // tbd
1028
1028
  */
1029
- loadProduct: (content: ArrayBuffer, type: DataTypes) => Promise<number[] | null>;
1029
+ loadProduct: (content: ArrayBuffer, type: 'ofb' | 'stp') => Promise<number[] | null>;
1030
1030
  /**
1031
1031
  * Loads a product from the given URL into the current drawing.
1032
1032
  * @param url The url to load data from.
1033
- * @param filetype The type of data delivered by the url (of1, stp).
1033
+ * @param filetype The type of data delivered by the url ('ofb', 'stp').
1034
1034
  * @example // tbd
1035
1035
  * @image // tbd
1036
1036
  */
1037
- loadProductFromUrl: (url: string, filetype: string) => Promise<number[] | null>;
1037
+ loadProductFromUrl: (url: string, filetype: 'ofb' | 'stp') => Promise<number[] | null>;
1038
1038
  /**
1039
1039
  * Creates a new feature and appends geometry to it. This method can be used to import specific geometry
1040
1040
  * which can be used for further operations like boolean, translations and so on.
@@ -1045,7 +1045,7 @@ export declare type ApiHistory = {
1045
1045
  * @example // tbd
1046
1046
  * @image // tbd
1047
1047
  */
1048
- importFeature: (partId: VID, content: ArrayBuffer, format: SupportedImportFormats, name?: string) => ID;
1048
+ importFeature: (partId: VID, content: ArrayBuffer, format: 'stp' | 'step', name?: string) => ID;
1049
1049
  /**
1050
1050
  * Removes a node from an assembly node
1051
1051
  * @param referenceId id of the node to remove
@@ -1127,7 +1127,7 @@ export declare type ApiHistory = {
1127
1127
  */
1128
1128
  setExpressions: (partId: VID, ...members: {
1129
1129
  name: string;
1130
- value: number | PointMemValue | string;
1130
+ value: number | string;
1131
1131
  }[]) => Promise<boolean>;
1132
1132
  /**
1133
1133
  * Updates multiple expression sets in different parts at once
@@ -1141,7 +1141,7 @@ export declare type ApiHistory = {
1141
1141
  partId: number;
1142
1142
  members: {
1143
1143
  name: string;
1144
- value: number | PointMemValue | string;
1144
+ value: number | string;
1145
1145
  }[];
1146
1146
  }[]) => Promise<boolean>;
1147
1147
  };
@@ -1163,8 +1163,6 @@ declare type Point = {
1163
1163
  z: number;
1164
1164
  };
1165
1165
  export declare type Transform = [Point, Point, Point];
1166
- declare type DataTypes = 'of1' | 'stp' | 'step';
1167
- declare type SupportedImportFormats = 'STEP' | 'STP' | 'SAT' | 'IWB' | 'IWP' | 'IWC' | 'IGS' | 'STL' | 'DXF' | 'DWG';
1168
1166
  export declare type DimensionType = {
1169
1167
  productId: VID;
1170
1168
  dimParam: {
@@ -1186,6 +1184,36 @@ export declare type ViewOptionsType = {
1186
1184
  color?: number;
1187
1185
  layer?: string;
1188
1186
  };
1187
+ export declare type FastenedOriginConstraintType = {
1188
+ constrId: VID;
1189
+ mate1: {
1190
+ matePath: VID[];
1191
+ wcsId: VID;
1192
+ flip: number;
1193
+ reoriented: number;
1194
+ };
1195
+ xOffset: number | string;
1196
+ yOffset: number | string;
1197
+ zOffset: number | string;
1198
+ };
1199
+ export declare type FastenedConstraintType = {
1200
+ constrId: VID;
1201
+ mate1: {
1202
+ matePath: VID[];
1203
+ wcsId: VID;
1204
+ flip: number;
1205
+ reoriented: number;
1206
+ };
1207
+ mate2: {
1208
+ matePath: VID[];
1209
+ wcsId: VID;
1210
+ flip: number;
1211
+ reoriented: number;
1212
+ };
1213
+ xOffset: number | string;
1214
+ yOffset: number | string;
1215
+ zOffset: number | string;
1216
+ };
1189
1217
  /**
1190
1218
  * Information about constraint.
1191
1219
  * [
package/build/history.js CHANGED
@@ -39,12 +39,13 @@ const getDataType = (value) => {
39
39
  * @returns cclass type of given type
40
40
  */
41
41
  const getDimensionType = (type) => {
42
+ let cclass = CCClasses.CCLinearDimension;
42
43
  switch (type) {
43
44
  case 'LinearDimension':
44
- return CCClasses.CCLinearDimension;
45
- case undefined:
45
+ cclass = CCClasses.CCLinearDimension;
46
46
  break;
47
47
  }
48
+ return cclass;
48
49
  };
49
50
  /**
50
51
  * Transforms the transformation which is local to the ownerId into global
@@ -283,74 +284,94 @@ export default class CAD {
283
284
  return ccAPI.assemblyBuilder.addNode(drawingId, rProductId, rOwnerId, globalTransformation, name);
284
285
  }, productId, ownerId);
285
286
  },
286
- addNodes: (...nodes) => {
287
- return this.resolve(async ([...rNodes]) => {
288
- const nodesToAdd = [];
289
- rNodes.forEach(node => {
290
- const globalTransformation = getGlobalTransformation(drawingId, node.ownerId, node.transformation) || node.transformation;
291
- nodesToAdd.push([node.productId, node.ownerId, globalTransformation, node.name]);
292
- });
293
- return ccAPI.assemblyBuilder.addNodes(drawingId, nodesToAdd);
294
- }, ...nodes);
287
+ addNodes: async (...nodes) => {
288
+ var e_1, _a;
289
+ const nodesToAdd = [];
290
+ try {
291
+ for (var nodes_1 = __asyncValues(nodes), nodes_1_1; nodes_1_1 = await nodes_1.next(), !nodes_1_1.done;) {
292
+ const node = nodes_1_1.value;
293
+ const [rProductId, rOwnerId] = await new Promise(res => this.resolve(id => res(id), node.productId, node.ownerId));
294
+ const nodeParam = {
295
+ referenceId: rProductId,
296
+ ownerId: rOwnerId,
297
+ transformation: getGlobalTransformation(drawingId, rOwnerId, node.transformation) || node.transformation,
298
+ name: node.name,
299
+ };
300
+ nodesToAdd.push(nodeParam);
301
+ }
302
+ }
303
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
304
+ finally {
305
+ try {
306
+ if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) await _a.call(nodes_1);
307
+ }
308
+ finally { if (e_1) throw e_1.error; }
309
+ }
310
+ return ccAPI.assemblyBuilder.addNodes(drawingId, nodesToAdd);
295
311
  },
296
312
  addDimension: (dim) => {
297
313
  return this.resolve(async ([rProductId]) => {
298
314
  const dimensionType = getDimensionType(dim.dimParam.dimType);
299
- if (dim.dimParam.dimOrientation !== undefined && dim.dxfView !== undefined) {
300
- const dimParam = [
301
- rProductId,
302
- [
303
- dimensionType || 'CC_LinearDimenion',
304
- dim.dimParam.dimName || 'Dimension',
305
- dim.dimParam.dimLabel,
306
- dim.dimParam.dimValue || null,
307
- dim.dimParam.dimStartPos,
308
- dim.dimParam.dimEndPos,
309
- dim.dimParam.dimTextPos,
310
- dim.dimParam.dimTextAngle,
311
- dim.dimParam.dimOrientation,
312
- dim.dimParam.dimColor || 256,
313
- dim.dimParam.dimLayer || '1',
314
- ],
315
- dim.dxfView,
316
- ];
317
- return ccAPI.drawing2D.addDimension(drawingId, dimParam);
318
- }
315
+ const dimParam = {
316
+ productId: rProductId,
317
+ param: {
318
+ type: dimensionType,
319
+ name: dim.dimParam.dimName,
320
+ label: dim.dimParam.dimLabel,
321
+ value: dim.dimParam.dimValue,
322
+ startPos: dim.dimParam.dimStartPos,
323
+ endPos: dim.dimParam.dimEndPos,
324
+ textPos: dim.dimParam.dimTextPos,
325
+ textAngle: dim.dimParam.dimTextAngle,
326
+ orientation: dim.dimParam.dimOrientation,
327
+ color: dim.dimParam.dimColor,
328
+ layer: dim.dimParam.dimLayer,
329
+ },
330
+ dxfView: dim.dxfView,
331
+ };
332
+ return ccAPI.drawing2D.addDimension(drawingId, dimParam);
319
333
  }, dim.productId);
320
334
  },
321
- addDimensions: (...dimensions) => {
322
- return this.resolve(async ([...rDimensions]) => {
323
- const dimsToAdd = [];
324
- rDimensions.forEach(dim => {
335
+ addDimensions: async (...dimensions) => {
336
+ var e_2, _a;
337
+ const dimParamsToAdd = [];
338
+ try {
339
+ for (var dimensions_1 = __asyncValues(dimensions), dimensions_1_1; dimensions_1_1 = await dimensions_1.next(), !dimensions_1_1.done;) {
340
+ const dim = dimensions_1_1.value;
341
+ const [rProductId] = await new Promise(res => this.resolve(id => res(id), dim.productId));
325
342
  const dimensionType = getDimensionType(dim.dimParam.dimType);
326
- if (dim.dimParam.dimOrientation !== undefined && dim.dxfView !== undefined) {
327
- dimsToAdd.push([
328
- dim.productId,
329
- [
330
- dimensionType || 'CC_LinearDimenion',
331
- dim.dimParam.dimName || 'Dimension',
332
- dim.dimParam.dimLabel,
333
- dim.dimParam.dimValue || null,
334
- dim.dimParam.dimStartPos,
335
- dim.dimParam.dimEndPos,
336
- dim.dimParam.dimTextPos,
337
- dim.dimParam.dimTextAngle,
338
- dim.dimParam.dimOrientation,
339
- dim.dimParam.dimColor || 256,
340
- dim.dimParam.dimLayer || '1',
341
- ],
342
- dim.dxfView,
343
- ]);
344
- }
345
- });
346
- return ccAPI.drawing2D.addDimensions(drawingId, dimsToAdd);
347
- }, ...dimensions);
343
+ const dimParam = {
344
+ productId: rProductId,
345
+ param: {
346
+ type: dimensionType,
347
+ name: dim.dimParam.dimName,
348
+ label: dim.dimParam.dimLabel,
349
+ value: dim.dimParam.dimValue,
350
+ startPos: dim.dimParam.dimStartPos,
351
+ endPos: dim.dimParam.dimEndPos,
352
+ textPos: dim.dimParam.dimTextPos,
353
+ textAngle: dim.dimParam.dimTextAngle,
354
+ orientation: dim.dimParam.dimOrientation,
355
+ color: dim.dimParam.dimColor,
356
+ layer: dim.dimParam.dimLayer,
357
+ },
358
+ dxfView: dim.dxfView,
359
+ };
360
+ dimParamsToAdd.push(dimParam);
361
+ }
362
+ }
363
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
364
+ finally {
365
+ try {
366
+ if (dimensions_1_1 && !dimensions_1_1.done && (_a = dimensions_1.return)) await _a.call(dimensions_1);
367
+ }
368
+ finally { if (e_2) throw e_2.error; }
369
+ }
370
+ return ccAPI.drawing2D.addDimensions(drawingId, dimParamsToAdd);
348
371
  },
349
372
  create2DViews: (productId, viewTypes, viewOptions) => {
350
373
  return this.resolve(async ([rProductId]) => {
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]);
374
+ const viewIds = await ccAPI.drawing2D.create2DViews(drawingId, rProductId, viewTypes, viewOptions);
354
375
  if (viewIds !== null) {
355
376
  await ccAPI.drawing2D.centerAllViews(drawingId, rProductId, viewTypes);
356
377
  return viewIds;
@@ -366,13 +387,7 @@ export default class CAD {
366
387
  },
367
388
  place2DViews: (productId, viewPositions) => {
368
389
  return this.resolve(async ([rProductId]) => {
369
- const viewPositionParams = [];
370
- viewPositions.forEach(viewPos => {
371
- if (viewPos.viewType !== undefined) {
372
- viewPositionParams.push([viewPos.viewType, viewPos.vector]);
373
- }
374
- });
375
- return ccAPI.drawing2D.place2DViews(drawingId, rProductId, viewPositionParams);
390
+ return ccAPI.drawing2D.place2DViews(drawingId, rProductId, viewPositions);
376
391
  }, productId);
377
392
  },
378
393
  exportDXF: (productId, dxfTemplateFilename) => {
@@ -603,7 +618,7 @@ export default class CAD {
603
618
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
604
619
  const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
605
620
  const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
606
- await ccAPI.assemblyBuilder.updateFastenedConstraint(drawingId, constraintId, [rMatePath1, rWcs1, mate1.flip, mate1.reoriented], [rMatePath2, rWcs2, mate2.flip, mate2.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
621
+ await ccAPI.assemblyBuilder.updateFastenedConstraint(drawingId, constraintId, { matePath: rMatePath1, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented }, { matePath: rMatePath2, wcsId: rWcs2, flip: mate2.flip, reoriented: mate2.reoriented }, xOffsetParam, yOffsetParam, zOffsetParam);
607
622
  return constraintId;
608
623
  }
609
624
  return null;
@@ -615,10 +630,10 @@ export default class CAD {
615
630
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
616
631
  const yOffsetParam = { value: yOffset, isExpr: typeof xOffset === 'string' };
617
632
  const zOffsetParam = { value: zOffset, isExpr: typeof xOffset === 'string' };
618
- await ccAPI.assemblyBuilder.updateFastenedConstraint(drawingId, rConstrId, [rMatePath1, rWcs1, mate1.flip, mate1.reoriented], [rMatePath2, rWcs2, mate2.flip, mate2.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
633
+ await ccAPI.assemblyBuilder.updateFastenedConstraint(drawingId, rConstrId, { matePath: rMatePath1, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented }, { matePath: rMatePath2, wcsId: rWcs2, flip: mate2.flip, reoriented: mate2.reoriented }, xOffsetParam, yOffsetParam, zOffsetParam);
619
634
  },
620
635
  updateFastenedConstraints: async (...constraints) => {
621
- var e_1, _a;
636
+ var e_3, _a;
622
637
  const constrToAdd = [];
623
638
  try {
624
639
  for (var constraints_1 = __asyncValues(constraints), constraints_1_1; constraints_1_1 = await constraints_1.next(), !constraints_1_1.done;) {
@@ -626,25 +641,35 @@ export default class CAD {
626
641
  const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
627
642
  const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
628
643
  const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
629
- const xOffsetParam = [constr.xOffset, typeof constr.xOffset === 'string'];
630
- const yOffsetParam = [constr.yOffset, typeof constr.yOffset === 'string'];
631
- const zOffsetParam = [constr.zOffset, typeof constr.zOffset === 'string'];
632
- constrToAdd.push([
633
- rConstrId,
634
- [rMatePath1, rWcs1, constr.mate1.flip, constr.mate1.reoriented],
635
- [rMatePath2, rWcs2, constr.mate2.flip, constr.mate2.reoriented],
636
- xOffsetParam,
637
- yOffsetParam,
638
- zOffsetParam,
639
- ]);
644
+ const xOffsetParam = { value: constr.xOffset, isExpr: typeof constr.xOffset === 'string' };
645
+ const yOffsetParam = { value: constr.yOffset, isExpr: typeof constr.yOffset === 'string' };
646
+ const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
647
+ constrToAdd.push({
648
+ constrId: rConstrId,
649
+ mate1: {
650
+ matePath: rMatePath1,
651
+ wcsId: rWcs1,
652
+ flip: constr.mate1.flip,
653
+ reoriented: constr.mate1.reoriented,
654
+ },
655
+ mate2: {
656
+ matePath: rMatePath2,
657
+ wcsId: rWcs2,
658
+ flip: constr.mate2.flip,
659
+ reoriented: constr.mate2.reoriented,
660
+ },
661
+ xOffset: xOffsetParam,
662
+ yOffset: yOffsetParam,
663
+ zOffset: zOffsetParam,
664
+ });
640
665
  }
641
666
  }
642
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
667
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
643
668
  finally {
644
669
  try {
645
670
  if (constraints_1_1 && !constraints_1_1.done && (_a = constraints_1.return)) await _a.call(constraints_1);
646
671
  }
647
- finally { if (e_1) throw e_1.error; }
672
+ finally { if (e_3) throw e_3.error; }
648
673
  }
649
674
  await ccAPI.assemblyBuilder.updateFastenedConstraints(drawingId, constrToAdd);
650
675
  },
@@ -656,7 +681,7 @@ export default class CAD {
656
681
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
657
682
  const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
658
683
  const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
659
- await ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, constraintId, [rMatePath, rWcs1, mate1.flip, mate1.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
684
+ await ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, constraintId, { matePath: rMatePath, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented }, xOffsetParam, yOffsetParam, zOffsetParam);
660
685
  return constraintId;
661
686
  }
662
687
  return null;
@@ -667,36 +692,41 @@ export default class CAD {
667
692
  const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
668
693
  const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
669
694
  const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
670
- await ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, rConstrId, [rMatePath, rWcs1, mate1.flip, mate1.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
695
+ await ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, rConstrId, { matePath: rMatePath, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented }, xOffsetParam, yOffsetParam, zOffsetParam);
671
696
  },
672
697
  updateFastenedOriginConstraints: async (...constraints) => {
673
- var e_2, _a;
674
- const constrToAdd = [];
698
+ var e_4, _a;
699
+ const constraintsToAdd = [];
675
700
  try {
676
701
  for (var constraints_2 = __asyncValues(constraints), constraints_2_1; constraints_2_1 = await constraints_2.next(), !constraints_2_1.done;) {
677
702
  const constr = constraints_2_1.value;
678
703
  const [rConstrId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId));
679
704
  const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
680
- const xOffsetParam = [constr.xOffset, typeof constr.xOffset === 'string'];
681
- const yOffsetParam = [constr.yOffset, typeof constr.yOffset === 'string'];
682
- const zOffsetParam = [constr.zOffset, typeof constr.zOffset === 'string'];
683
- constrToAdd.push([
684
- rConstrId,
685
- [rMatePath, rWcs1, constr.mate1.flip, constr.mate1.reoriented],
686
- xOffsetParam,
687
- yOffsetParam,
688
- zOffsetParam,
689
- ]);
705
+ const xOffsetParam = { value: constr.xOffset, isExpr: typeof constr.xOffset === 'string' };
706
+ const yOffsetParam = { value: constr.yOffset, isExpr: typeof constr.yOffset === 'string' };
707
+ const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
708
+ constraintsToAdd.push({
709
+ constrId: rConstrId,
710
+ mate1: {
711
+ matePath: rMatePath,
712
+ wcsId: rWcs1,
713
+ flip: constr.mate1.flip,
714
+ reoriented: constr.mate1.reoriented,
715
+ },
716
+ xOffset: xOffsetParam,
717
+ yOffset: yOffsetParam,
718
+ zOffset: zOffsetParam,
719
+ });
690
720
  }
691
721
  }
692
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
722
+ catch (e_4_1) { e_4 = { error: e_4_1 }; }
693
723
  finally {
694
724
  try {
695
725
  if (constraints_2_1 && !constraints_2_1.done && (_a = constraints_2.return)) await _a.call(constraints_2);
696
726
  }
697
- finally { if (e_2) throw e_2.error; }
727
+ finally { if (e_4) throw e_4.error; }
698
728
  }
699
- await ccAPI.assemblyBuilder.updateFastenedOriginConstraints(drawingId, constrToAdd);
729
+ await ccAPI.assemblyBuilder.updateFastenedOriginConstraints(drawingId, constraintsToAdd);
700
730
  },
701
731
  createBufferGeometry: async (objectId) => {
702
732
  await this.queue;
@@ -737,12 +767,12 @@ export default class CAD {
737
767
  const membersToAdd = [];
738
768
  members.forEach(mem => {
739
769
  const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen STrings
740
- const dataType = isExpr ? DataType.REAL : getDataType(mem.value); // TODO: Aktuell nur Real Werte als Expression
770
+ const dataType = DataType.REAL; // TODO: Aktuell nur Real Werte als Expression
741
771
  const featureAPIParam = {
742
772
  value: mem.value,
743
773
  isExpr: isExpr,
744
774
  };
745
- membersToAdd.push([mem.name, featureAPIParam, dataType]);
775
+ membersToAdd.push({ name: mem.name, value: featureAPIParam, dataType });
746
776
  });
747
777
  const success = featureAPI.updateExpressionSet(drawingId, rPartId, membersToAdd, [], []);
748
778
  return success;
@@ -1140,12 +1170,12 @@ export default class CAD {
1140
1170
  return this.resolve(async ([rPartId]) => {
1141
1171
  const membersToModify = [];
1142
1172
  members.forEach(mem => {
1143
- const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen STrings
1173
+ const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen Strings
1144
1174
  const featureAPIParam = {
1145
1175
  value: mem.value,
1146
- isExpr: isExpr,
1176
+ isExpr,
1147
1177
  };
1148
- membersToModify.push([mem.name, featureAPIParam]);
1178
+ membersToModify.push({ name: mem.name, value: featureAPIParam });
1149
1179
  });
1150
1180
  const success = featureAPI.updateExpressionSet(drawingId, rPartId, [], membersToModify, []);
1151
1181
  return success;
@@ -1157,10 +1187,19 @@ export default class CAD {
1157
1187
  rExprSets.forEach(exprSet => {
1158
1188
  const membersToModify = [];
1159
1189
  exprSet.members.forEach((mem) => {
1160
- const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen STrings
1161
- membersToModify.push([mem.name, [mem.value, isExpr]]);
1190
+ const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen Strings
1191
+ const featureAPIParam = {
1192
+ value: mem.value,
1193
+ isExpr,
1194
+ };
1195
+ membersToModify.push({ name: mem.name, value: featureAPIParam });
1196
+ });
1197
+ exprSetsToSet.push({
1198
+ productId: exprSet.partId,
1199
+ toAddMembers: [],
1200
+ toModifyMembers: membersToModify,
1201
+ toDeleteList: [],
1162
1202
  });
1163
- exprSetsToSet.push([exprSet.partId, [], membersToModify, []]);
1164
1203
  });
1165
1204
  const success = await featureAPI.updateExpressionSets(drawingId, exprSetsToSet);
1166
1205
  return success;
package/build/solid.d.ts CHANGED
@@ -223,9 +223,9 @@ export declare type ApiNoHistory = {
223
223
  intersect: (solidId: VID, keepSolid: boolean, ...bodies: VID[]) => ID;
224
224
  /**
225
225
  * Loads an arraybuffer in native file format. Native file format
226
- * is 'of1', if you want to load 'stp' file formats, use import function.
226
+ * is 'ofb', if you want to load 'stp' file formats, use import function.
227
227
  * Current drawing will be overwritten by loaded data.
228
- * @param data data as arraybuffer in of1 format
228
+ * @param data data as arraybuffer in ofb format
229
229
  * @example // tbd
230
230
  * @image // tbd
231
231
  */
@@ -321,14 +321,14 @@ export declare type ApiNoHistory = {
321
321
  rotateTo: (solidId: VID, rotationVec: Vec) => Promise<void>;
322
322
  /**
323
323
  * Writes the current drawing as native file format to a stream and returns the data.
324
- * Native file is 'of1', for 'stp' file format use export method.
324
+ * Native file is 'ofb', for 'stp' file format use export method.
325
325
  *
326
- * Important notes about the of1 format:
326
+ * Important notes about the ofb format:
327
327
  * - It contains binary geometry blocks.
328
328
  * - Do not try to convert it to text, the geometry blocks will get damaged!
329
329
  *
330
330
  * @example
331
- * // Creates a rotated box and gets the of1 data.
331
+ * // Creates a rotated box and gets the ofb data.
332
332
  * const boxId = api.box(10, 10, 10)
333
333
  * api.rotateTo(boxId, [Math.PI / 4, 0, Math.PI / 4])
334
334
  * const data = api.save()
package/build/solid.js CHANGED
@@ -302,7 +302,7 @@ export default class CAD {
302
302
  },
303
303
  load: (data) => {
304
304
  return this.resolve(async () => {
305
- const productId = await solidAPI.load(drawingId, data, 'of1', true);
305
+ const productId = await solidAPI.load(drawingId, data, 'ofb', true);
306
306
  if (productId !== null) {
307
307
  const drawing = getDrawing(drawingId);
308
308
  const solids = drawing.structure.tree[productId].solids;
@@ -355,7 +355,7 @@ export default class CAD {
355
355
  },
356
356
  save: () => {
357
357
  return this.resolve(async () => {
358
- return solidAPI.save(drawingId, 'of1');
358
+ return solidAPI.save(drawingId, 'ofb');
359
359
  });
360
360
  },
361
361
  scale: (target, pointOrFactor) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerli.io/headless",
3
- "version": "0.4.0",
3
+ "version": "0.5.0-beta.1",
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",
@@ -20,17 +20,17 @@
20
20
  "prettify": "prettier --write \"./{src,tests}/**/*.{js,jsx,ts,tsx,json}\""
21
21
  },
22
22
  "devDependencies": {
23
- "@types/three": "^0.137",
23
+ "@types/three": "^0.143",
24
24
  "copyfiles": "^2.1.1",
25
25
  "rimraf": "^2.6.3",
26
- "three": "^0.138",
27
- "typescript": "4.1.2"
26
+ "three": "^0.143",
27
+ "typescript": "4.8.4"
28
28
  },
29
29
  "peerDependencies": {
30
30
  "three": ">=0.138"
31
31
  },
32
32
  "dependencies": {
33
- "@buerli.io/classcad": "0.4.0",
33
+ "@buerli.io/classcad": "0.5.0-beta.1",
34
34
  "flat-promise": "^1.0.3"
35
35
  }
36
36
  }