@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.
- package/build/history.d.ts +50 -22
- package/build/history.js +147 -108
- package/build/solid.d.ts +5 -5
- package/build/solid.js +2 -2
- package/package.json +5 -5
package/build/history.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export declare type ApiHistory = {
|
|
|
64
64
|
ownerId: VID;
|
|
65
65
|
transformation: Transform;
|
|
66
66
|
name?: string;
|
|
67
|
-
}[]) =>
|
|
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
|
-
}[]) =>
|
|
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 |
|
|
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
|
|
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
|
|
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, '
|
|
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
|
|
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:
|
|
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 (
|
|
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: '
|
|
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:
|
|
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 (
|
|
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: '
|
|
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, '
|
|
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:
|
|
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 (
|
|
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:
|
|
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:
|
|
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 |
|
|
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 |
|
|
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
|
-
|
|
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
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
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
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
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
|
-
|
|
323
|
-
|
|
324
|
-
|
|
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
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
|
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
|
-
|
|
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,
|
|
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,
|
|
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
|
|
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 =
|
|
630
|
-
const yOffsetParam =
|
|
631
|
-
const zOffsetParam =
|
|
632
|
-
constrToAdd.push(
|
|
633
|
-
rConstrId,
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
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 (
|
|
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 (
|
|
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,
|
|
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,
|
|
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
|
|
674
|
-
const
|
|
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 =
|
|
681
|
-
const yOffsetParam =
|
|
682
|
-
const zOffsetParam =
|
|
683
|
-
|
|
684
|
-
rConstrId,
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
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 (
|
|
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 (
|
|
727
|
+
finally { if (e_4) throw e_4.error; }
|
|
698
728
|
}
|
|
699
|
-
await ccAPI.assemblyBuilder.updateFastenedOriginConstraints(drawingId,
|
|
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 =
|
|
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(
|
|
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
|
|
1173
|
+
const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen Strings
|
|
1144
1174
|
const featureAPIParam = {
|
|
1145
1175
|
value: mem.value,
|
|
1146
|
-
isExpr
|
|
1176
|
+
isExpr,
|
|
1147
1177
|
};
|
|
1148
|
-
membersToModify.push(
|
|
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
|
|
1161
|
-
|
|
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 '
|
|
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
|
|
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 '
|
|
324
|
+
* Native file is 'ofb', for 'stp' file format use export method.
|
|
325
325
|
*
|
|
326
|
-
* Important notes about the
|
|
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
|
|
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, '
|
|
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, '
|
|
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.
|
|
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.
|
|
23
|
+
"@types/three": "^0.143",
|
|
24
24
|
"copyfiles": "^2.1.1",
|
|
25
25
|
"rimraf": "^2.6.3",
|
|
26
|
-
"three": "^0.
|
|
27
|
-
"typescript": "4.
|
|
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.
|
|
33
|
+
"@buerli.io/classcad": "0.5.0-beta.1",
|
|
34
34
|
"flat-promise": "^1.0.3"
|
|
35
35
|
}
|
|
36
36
|
}
|