@buerli.io/headless 0.3.0 → 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.
- package/build/history.d.ts +36 -16
- package/build/history.js +110 -73
- package/build/solid.js +3 -1
- package/package.json +6 -5
package/build/history.d.ts
CHANGED
|
@@ -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.
|
|
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, [
|
|
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
|
-
*
|
|
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
|
|
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
|
|
@@ -412,7 +428,7 @@ export declare type ApiHistory = {
|
|
|
412
428
|
wcsId: VID;
|
|
413
429
|
flip: FlipType;
|
|
414
430
|
reoriented: ReorientedType;
|
|
415
|
-
}, xOffset: number | string, yOffset: number | string, zOffset: number | string, name: string) =>
|
|
431
|
+
}, xOffset: number | string, yOffset: number | string, zOffset: number | string, name: string) => Promise<ObjectID | null>;
|
|
416
432
|
/**
|
|
417
433
|
* Updates a fastened constraint.
|
|
418
434
|
* @param constrId id of the constraint to update
|
|
@@ -444,13 +460,13 @@ export declare type ApiHistory = {
|
|
|
444
460
|
updateFastenedConstraints: (...constraints: {
|
|
445
461
|
constrId: VID;
|
|
446
462
|
mate1: {
|
|
447
|
-
matePath:
|
|
463
|
+
matePath: VID[];
|
|
448
464
|
wcsId: VID;
|
|
449
465
|
flip: number;
|
|
450
466
|
reoriented: number;
|
|
451
467
|
};
|
|
452
468
|
mate2: {
|
|
453
|
-
matePath:
|
|
469
|
+
matePath: VID[];
|
|
454
470
|
wcsId: VID;
|
|
455
471
|
flip: number;
|
|
456
472
|
reoriented: number;
|
|
@@ -500,7 +516,7 @@ export declare type ApiHistory = {
|
|
|
500
516
|
wcsId: VID;
|
|
501
517
|
flip: FlipType;
|
|
502
518
|
reoriented: ReorientedType;
|
|
503
|
-
}, xOffset: number | string, yOffset: number | string, zOffset: number | string, name: string) =>
|
|
519
|
+
}, xOffset: number | string, yOffset: number | string, zOffset: number | string, name: string) => Promise<ObjectID | null>;
|
|
504
520
|
/**
|
|
505
521
|
* Updates a fastened origin constraint.
|
|
506
522
|
* @param constrId id of the constraint to update
|
|
@@ -524,10 +540,10 @@ export declare type ApiHistory = {
|
|
|
524
540
|
* @image // tbd
|
|
525
541
|
*/
|
|
526
542
|
updateFastenedOriginConstraints: (...constraints: {
|
|
527
|
-
constrId:
|
|
543
|
+
constrId: VID;
|
|
528
544
|
mate1: {
|
|
529
|
-
matePath:
|
|
530
|
-
wcsId:
|
|
545
|
+
matePath: VID[];
|
|
546
|
+
wcsId: VID;
|
|
531
547
|
flip: number;
|
|
532
548
|
reoriented: number;
|
|
533
549
|
};
|
|
@@ -1137,9 +1153,9 @@ export default class CAD {
|
|
|
1137
1153
|
init(callback: (api: ApiHistory) => void): () => Promise<void>;
|
|
1138
1154
|
destroy(): void;
|
|
1139
1155
|
}
|
|
1140
|
-
declare type VID = ObjectID |
|
|
1156
|
+
declare type VID = ObjectID | null | Promise<ObjectID | null>;
|
|
1141
1157
|
declare type VIDs = ObjectID[] | Promise<ObjectID[]>;
|
|
1142
|
-
declare type ID = Promise<ObjectID
|
|
1158
|
+
declare type ID = Promise<ObjectID | null>;
|
|
1143
1159
|
declare type IDs = Promise<ObjectID[]>;
|
|
1144
1160
|
declare type Point = {
|
|
1145
1161
|
x: number;
|
|
@@ -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
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
2
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
3
|
+
var m = o[Symbol.asyncIterator], i;
|
|
4
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
5
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
6
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
7
|
+
};
|
|
1
8
|
/* eslint-disable max-lines */
|
|
2
|
-
import { ccAPI, CCClasses, ccUtils, DataType, } from '@buerli.io/classcad';
|
|
9
|
+
import { ccAPI, CCClasses, ccUtils, DataType, SVGModusType, } from '@buerli.io/classcad';
|
|
3
10
|
import { api, getDrawing, lineSegmentsFilter, loopFilter, MathUtils, planeFilter, pointFilter, } from '@buerli.io/core';
|
|
4
11
|
import { Group, Mesh, MeshStandardMaterial, Scene, Vector3 } from 'three';
|
|
5
12
|
import * as BufferGeometryUtils_ from 'three/examples/jsm/utils/BufferGeometryUtils';
|
|
@@ -303,7 +310,7 @@ export default class CAD {
|
|
|
303
310
|
dim.dimParam.dimTextAngle,
|
|
304
311
|
dim.dimParam.dimOrientation,
|
|
305
312
|
dim.dimParam.dimColor || 256,
|
|
306
|
-
dim.dimParam.dimLayer || '
|
|
313
|
+
dim.dimParam.dimLayer || '1',
|
|
307
314
|
],
|
|
308
315
|
dim.dxfView,
|
|
309
316
|
];
|
|
@@ -330,7 +337,7 @@ export default class CAD {
|
|
|
330
337
|
dim.dimParam.dimTextAngle,
|
|
331
338
|
dim.dimParam.dimOrientation,
|
|
332
339
|
dim.dimParam.dimColor || 256,
|
|
333
|
-
dim.dimParam.dimLayer || '
|
|
340
|
+
dim.dimParam.dimLayer || '1',
|
|
334
341
|
],
|
|
335
342
|
dim.dxfView,
|
|
336
343
|
]);
|
|
@@ -339,9 +346,11 @@ export default class CAD {
|
|
|
339
346
|
return ccAPI.drawing2D.addDimensions(drawingId, dimsToAdd);
|
|
340
347
|
}, ...dimensions);
|
|
341
348
|
},
|
|
342
|
-
create2DViews: (productId, viewTypes) => {
|
|
349
|
+
create2DViews: (productId, viewTypes, viewOptions) => {
|
|
343
350
|
return this.resolve(async ([rProductId]) => {
|
|
344
|
-
const
|
|
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]);
|
|
345
354
|
if (viewIds !== null) {
|
|
346
355
|
await ccAPI.drawing2D.centerAllViews(drawingId, rProductId, viewTypes);
|
|
347
356
|
return viewIds;
|
|
@@ -366,14 +375,16 @@ export default class CAD {
|
|
|
366
375
|
return ccAPI.drawing2D.place2DViews(drawingId, rProductId, viewPositionParams);
|
|
367
376
|
}, productId);
|
|
368
377
|
},
|
|
369
|
-
exportDXF: (productId) => {
|
|
378
|
+
exportDXF: (productId, dxfTemplateFilename) => {
|
|
370
379
|
return this.resolve(async ([rProductId]) => {
|
|
371
|
-
return ccAPI.drawing2D.exportDXF(drawingId, rProductId);
|
|
380
|
+
return ccAPI.drawing2D.exportDXF(drawingId, rProductId, dxfTemplateFilename);
|
|
372
381
|
}, productId);
|
|
373
382
|
},
|
|
374
|
-
exportSVG: (productId) => {
|
|
383
|
+
exportSVG: (productId, modus, renderSize, dxfTemplateFilename) => {
|
|
375
384
|
return this.resolve(async ([rProductId]) => {
|
|
376
|
-
|
|
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);
|
|
377
388
|
}, productId);
|
|
378
389
|
},
|
|
379
390
|
removeDimensions: (dimensionIds) => {
|
|
@@ -583,90 +594,109 @@ export default class CAD {
|
|
|
583
594
|
return null;
|
|
584
595
|
}, partId, ...references);
|
|
585
596
|
},
|
|
586
|
-
createFastenedConstraint: (asmId, mate1, mate2, xOffset, yOffset, zOffset, name) => {
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
593
|
-
rMatePath1 = Array.isArray(rMatePath1) ? rMatePath1 : [rMatePath1];
|
|
594
|
-
rMatePath2 = Array.isArray(rMatePath2) ? rMatePath2 : [rMatePath2];
|
|
595
|
-
await ccAPI.assemblyBuilder.updateFastenedConstraint(drawingId, constraintId, [rMatePath1, rMate1.wcsId, rMate1.flip, rMate1.reoriented], [rMatePath2, rMate2.wcsId, rMate2.flip, rMate2.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
|
|
596
|
-
return constraintId;
|
|
597
|
-
}
|
|
598
|
-
return null;
|
|
599
|
-
}, asmId, mate1, mate2, ...mate1.matePath, ...mate2.matePath);
|
|
600
|
-
},
|
|
601
|
-
updateFastenedConstraint: (constrId, mate1, mate2, xOffset, yOffset, zOffset) => {
|
|
602
|
-
return this.resolve(async ([rConstrId, rMate1, rMate2, rMatePath1, rMatePath2]) => {
|
|
597
|
+
createFastenedConstraint: async (asmId, mate1, mate2, xOffset, yOffset, zOffset, name) => {
|
|
598
|
+
const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
|
|
599
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
600
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
601
|
+
const constraintId = await ccAPI.assemblyBuilder.create3DConstraint(drawingId, rAsmId, CCClasses.CCFastenedConstraint, name);
|
|
602
|
+
if (constraintId != null) {
|
|
603
603
|
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
604
|
-
const yOffsetParam = { value: yOffset, isExpr: typeof
|
|
605
|
-
const zOffsetParam = { value: zOffset, isExpr: typeof
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
},
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
604
|
+
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
605
|
+
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);
|
|
607
|
+
return constraintId;
|
|
608
|
+
}
|
|
609
|
+
return null;
|
|
610
|
+
},
|
|
611
|
+
updateFastenedConstraint: async (constrId, mate1, mate2, xOffset, yOffset, zOffset) => {
|
|
612
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constrId, mate1.wcsId, mate2.wcsId));
|
|
613
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
614
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
615
|
+
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
616
|
+
const yOffsetParam = { value: yOffset, isExpr: typeof xOffset === 'string' };
|
|
617
|
+
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);
|
|
619
|
+
},
|
|
620
|
+
updateFastenedConstraints: async (...constraints) => {
|
|
621
|
+
var e_1, _a;
|
|
622
|
+
const constrToAdd = [];
|
|
623
|
+
try {
|
|
624
|
+
for (var constraints_1 = __asyncValues(constraints), constraints_1_1; constraints_1_1 = await constraints_1.next(), !constraints_1_1.done;) {
|
|
625
|
+
const constr = constraints_1_1.value;
|
|
626
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
627
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
628
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
615
629
|
const xOffsetParam = [constr.xOffset, typeof constr.xOffset === 'string'];
|
|
616
630
|
const yOffsetParam = [constr.yOffset, typeof constr.yOffset === 'string'];
|
|
617
631
|
const zOffsetParam = [constr.zOffset, typeof constr.zOffset === 'string'];
|
|
618
632
|
constrToAdd.push([
|
|
619
|
-
|
|
620
|
-
[
|
|
621
|
-
[
|
|
633
|
+
rConstrId,
|
|
634
|
+
[rMatePath1, rWcs1, constr.mate1.flip, constr.mate1.reoriented],
|
|
635
|
+
[rMatePath2, rWcs2, constr.mate2.flip, constr.mate2.reoriented],
|
|
622
636
|
xOffsetParam,
|
|
623
637
|
yOffsetParam,
|
|
624
638
|
zOffsetParam,
|
|
625
639
|
]);
|
|
626
|
-
});
|
|
627
|
-
await ccAPI.assemblyBuilder.updateFastenedConstraints(drawingId, constrToAdd);
|
|
628
|
-
}, ...constraints);
|
|
629
|
-
},
|
|
630
|
-
createFastenedOriginConstraint: (asmId, mate1, xOffset, yOffset, zOffset, name) => {
|
|
631
|
-
return this.resolve(async ([rAsmId, rMatePath, rMateWcsId]) => {
|
|
632
|
-
const constraintId = await ccAPI.assemblyBuilder.create3DConstraint(drawingId, rAsmId, CCClasses.CCFastenedOriginConstraint, name);
|
|
633
|
-
if (constraintId != null) {
|
|
634
|
-
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
635
|
-
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
636
|
-
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
637
|
-
rMatePath = Array.isArray(rMatePath) ? rMatePath : [rMatePath];
|
|
638
|
-
await ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, constraintId, [rMatePath, rMateWcsId, mate1.flip, mate1.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
|
|
639
|
-
return constraintId;
|
|
640
640
|
}
|
|
641
|
-
|
|
642
|
-
|
|
641
|
+
}
|
|
642
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
643
|
+
finally {
|
|
644
|
+
try {
|
|
645
|
+
if (constraints_1_1 && !constraints_1_1.done && (_a = constraints_1.return)) await _a.call(constraints_1);
|
|
646
|
+
}
|
|
647
|
+
finally { if (e_1) throw e_1.error; }
|
|
648
|
+
}
|
|
649
|
+
await ccAPI.assemblyBuilder.updateFastenedConstraints(drawingId, constrToAdd);
|
|
643
650
|
},
|
|
644
|
-
|
|
645
|
-
|
|
651
|
+
createFastenedOriginConstraint: async (asmId, mate1, xOffset, yOffset, zOffset, name) => {
|
|
652
|
+
const [rAsmId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId));
|
|
653
|
+
const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
654
|
+
const constraintId = await ccAPI.assemblyBuilder.create3DConstraint(drawingId, rAsmId, CCClasses.CCFastenedOriginConstraint, name);
|
|
655
|
+
if (constraintId != null) {
|
|
646
656
|
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
647
657
|
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
648
658
|
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
}
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
659
|
+
await ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, constraintId, [rMatePath, rWcs1, mate1.flip, mate1.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
|
|
660
|
+
return constraintId;
|
|
661
|
+
}
|
|
662
|
+
return null;
|
|
663
|
+
},
|
|
664
|
+
updateFastenedOriginConstraint: async (constrId, mate1, xOffset, yOffset, zOffset) => {
|
|
665
|
+
const [rConstrId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), constrId, mate1.wcsId));
|
|
666
|
+
const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
667
|
+
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
668
|
+
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
669
|
+
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
670
|
+
await ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, rConstrId, [rMatePath, rWcs1, mate1.flip, mate1.reoriented], xOffsetParam, yOffsetParam, zOffsetParam);
|
|
671
|
+
},
|
|
672
|
+
updateFastenedOriginConstraints: async (...constraints) => {
|
|
673
|
+
var e_2, _a;
|
|
674
|
+
const constrToAdd = [];
|
|
675
|
+
try {
|
|
676
|
+
for (var constraints_2 = __asyncValues(constraints), constraints_2_1; constraints_2_1 = await constraints_2.next(), !constraints_2_1.done;) {
|
|
677
|
+
const constr = constraints_2_1.value;
|
|
678
|
+
const [rConstrId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId));
|
|
679
|
+
const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
657
680
|
const xOffsetParam = [constr.xOffset, typeof constr.xOffset === 'string'];
|
|
658
681
|
const yOffsetParam = [constr.yOffset, typeof constr.yOffset === 'string'];
|
|
659
682
|
const zOffsetParam = [constr.zOffset, typeof constr.zOffset === 'string'];
|
|
660
683
|
constrToAdd.push([
|
|
661
|
-
|
|
662
|
-
[
|
|
684
|
+
rConstrId,
|
|
685
|
+
[rMatePath, rWcs1, constr.mate1.flip, constr.mate1.reoriented],
|
|
663
686
|
xOffsetParam,
|
|
664
687
|
yOffsetParam,
|
|
665
688
|
zOffsetParam,
|
|
666
689
|
]);
|
|
667
|
-
}
|
|
668
|
-
|
|
669
|
-
|
|
690
|
+
}
|
|
691
|
+
}
|
|
692
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
693
|
+
finally {
|
|
694
|
+
try {
|
|
695
|
+
if (constraints_2_1 && !constraints_2_1.done && (_a = constraints_2.return)) await _a.call(constraints_2);
|
|
696
|
+
}
|
|
697
|
+
finally { if (e_2) throw e_2.error; }
|
|
698
|
+
}
|
|
699
|
+
await ccAPI.assemblyBuilder.updateFastenedOriginConstraints(drawingId, constrToAdd);
|
|
670
700
|
},
|
|
671
701
|
createBufferGeometry: async (objectId) => {
|
|
672
702
|
await this.queue;
|
|
@@ -693,7 +723,12 @@ export default class CAD {
|
|
|
693
723
|
const scene = new Scene();
|
|
694
724
|
if (rObjectId != null) {
|
|
695
725
|
const rootObj = structureTree[rObjectId];
|
|
696
|
-
|
|
726
|
+
if (rootObj) {
|
|
727
|
+
await createRecursiveScene(rootObj, drawingId, scene, options);
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
730
|
+
throw new Error('Root object does not exist!');
|
|
731
|
+
}
|
|
697
732
|
}
|
|
698
733
|
return scene;
|
|
699
734
|
},
|
|
@@ -984,7 +1019,7 @@ export default class CAD {
|
|
|
984
1019
|
const featureName = name ? name : 'Import';
|
|
985
1020
|
const importFeatureId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCImport, featureName);
|
|
986
1021
|
if (importFeatureId !== null) {
|
|
987
|
-
const solids = await featureAPI.
|
|
1022
|
+
const solids = await featureAPI.updateImport(drawingId, importFeatureId, content, format, featureName);
|
|
988
1023
|
if (solids !== null) {
|
|
989
1024
|
return importFeatureId;
|
|
990
1025
|
}
|
|
@@ -996,6 +1031,7 @@ export default class CAD {
|
|
|
996
1031
|
return this.resolve(async ([rPartId, rPlaneId]) => {
|
|
997
1032
|
const sketch = await sketcherAPI.createSketch(drawingId, rPartId);
|
|
998
1033
|
if (sketch) {
|
|
1034
|
+
await featureAPI.closeFeature(drawingId, sketch);
|
|
999
1035
|
const tree = getDrawing(drawingId).structure.tree;
|
|
1000
1036
|
const plane = tree[rPlaneId];
|
|
1001
1037
|
if (plane && base.isA(plane.class, CCClasses.CCWorkPlane)) {
|
|
@@ -1013,6 +1049,7 @@ export default class CAD {
|
|
|
1013
1049
|
return this.resolve(async ([rPartId, rPlaneId, rSketchId]) => {
|
|
1014
1050
|
const sketch = await sketcherAPI.createSketch(drawingId, rPartId);
|
|
1015
1051
|
if (sketch) {
|
|
1052
|
+
await featureAPI.closeFeature(drawingId, sketch);
|
|
1016
1053
|
const tree = getDrawing(drawingId).structure.tree;
|
|
1017
1054
|
const plane = tree[rPlaneId];
|
|
1018
1055
|
if (plane && base.isA(plane.class, CCClasses.CCWorkPlane)) {
|
package/build/solid.js
CHANGED
|
@@ -182,7 +182,9 @@ export default class CAD {
|
|
|
182
182
|
this.queue = Promise.resolve(0);
|
|
183
183
|
}
|
|
184
184
|
resolve(callback, ...args) {
|
|
185
|
-
return (this.queue = this.queue
|
|
185
|
+
return (this.queue = this.queue
|
|
186
|
+
.then(() => Promise.all(args).then(callback))
|
|
187
|
+
.catch(e => {
|
|
186
188
|
// catch is necessary to avoid error promises in the queue
|
|
187
189
|
}));
|
|
188
190
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@buerli.io/headless",
|
|
3
|
-
"version": "0.
|
|
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",
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
"scripts": {
|
|
13
13
|
"ver": "npm version",
|
|
14
14
|
"prepack": "npm run clean && npm run build",
|
|
15
|
-
"clean": "rimraf ./build",
|
|
16
|
-
"build": "tsc",
|
|
15
|
+
"clean": "rimraf ./build && rimraf ./tsconfig.tsbuildinfo",
|
|
16
|
+
"build": "tsc -v && tsc",
|
|
17
17
|
"build:dev": "tsc --sourceMap true --declarationMap true",
|
|
18
18
|
"test": "echo no tests yet",
|
|
19
19
|
"lint": "eslint \"./src/**/*.ts?(x)\"",
|
|
@@ -23,13 +23,14 @@
|
|
|
23
23
|
"@types/three": "^0.137",
|
|
24
24
|
"copyfiles": "^2.1.1",
|
|
25
25
|
"rimraf": "^2.6.3",
|
|
26
|
-
"three": "^0.138"
|
|
26
|
+
"three": "^0.138",
|
|
27
|
+
"typescript": "4.1.2"
|
|
27
28
|
},
|
|
28
29
|
"peerDependencies": {
|
|
29
30
|
"three": ">=0.138"
|
|
30
31
|
},
|
|
31
32
|
"dependencies": {
|
|
32
|
-
"@buerli.io/classcad": "0.
|
|
33
|
+
"@buerli.io/classcad": "0.4.0-beta.3",
|
|
33
34
|
"flat-promise": "^1.0.3"
|
|
34
35
|
}
|
|
35
36
|
}
|