@buerli.io/headless 0.5.0-beta.2 → 0.5.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/cjs/history.js +665 -165
- package/build/cjs/solid.js +70 -15
- package/build/esm/history.js +665 -165
- package/build/esm/solid.js +71 -16
- package/build/types/history.d.ts +323 -212
- package/build/types/index.d.ts +8 -1
- package/build/types/solid.d.ts +13 -3
- package/package.json +2 -2
package/build/esm/history.js
CHANGED
|
@@ -13,26 +13,14 @@ import * as BufferGeometryUtils_ from 'three/examples/jsm/utils/BufferGeometryUt
|
|
|
13
13
|
import { waitForSelect } from './utils/selection';
|
|
14
14
|
const featureAPI = ccAPI.feature;
|
|
15
15
|
const sketcherAPI = ccAPI.sketcher;
|
|
16
|
-
const
|
|
16
|
+
const baseModelerAPI = ccAPI.baseModeler;
|
|
17
|
+
const assemblyBuilderAPI = ccAPI.assemblyBuilder;
|
|
18
|
+
const baseUtils = ccUtils.base;
|
|
19
|
+
const asmUtils = ccUtils.assembly;
|
|
17
20
|
let BufferGeometryUtils = BufferGeometryUtils_;
|
|
18
21
|
if (BufferGeometryUtils.BufferGeometryUtils) {
|
|
19
22
|
BufferGeometryUtils = BufferGeometryUtils.BufferGeometryUtils;
|
|
20
23
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Returns the data type of the given value
|
|
23
|
-
* @param value value to get the data type from
|
|
24
|
-
* @returns datatype of value
|
|
25
|
-
*/
|
|
26
|
-
const getDataType = (value) => {
|
|
27
|
-
switch (typeof value) {
|
|
28
|
-
case 'number':
|
|
29
|
-
return DataType.REAL;
|
|
30
|
-
case 'object':
|
|
31
|
-
return DataType.POINT;
|
|
32
|
-
case 'string':
|
|
33
|
-
return DataType.STRING;
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
24
|
/**
|
|
37
25
|
* Returns the cclass of the given dimension type
|
|
38
26
|
* @param type type of the dimension as string
|
|
@@ -56,7 +44,7 @@ const getDimensionType = (type) => {
|
|
|
56
44
|
*/
|
|
57
45
|
const getGlobalTransformation = (drawingId, ownerId, localTransformation) => {
|
|
58
46
|
const lT = localTransformation;
|
|
59
|
-
const coordSysOwner =
|
|
47
|
+
const coordSysOwner = asmUtils.getCoordSysFromNode(drawingId, ownerId);
|
|
60
48
|
if (coordSysOwner) {
|
|
61
49
|
const origin = [lT[0].x, lT[0].y, lT[0].z];
|
|
62
50
|
const xAxis = [lT[1].x, lT[1].y, lT[1].z];
|
|
@@ -124,83 +112,80 @@ const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray)
|
|
|
124
112
|
}
|
|
125
113
|
};
|
|
126
114
|
/**
|
|
127
|
-
* We traverse recursively over structure tree, starting with object and create
|
|
128
|
-
* for the scene. Each part or assembly will be turned into groups and subgroups. Solids
|
|
129
|
-
* into
|
|
115
|
+
* We traverse recursively over structure tree, starting with object and create THREE objects
|
|
116
|
+
* for the scene. Each part or assembly will be turned into groups and subgroups. Solids which are children of the
|
|
117
|
+
* parts will be turned into groups as well. Children of solids will be merged to meshes. Faces of a solid with different color
|
|
130
118
|
* or transparency will get its own mesh.
|
|
131
119
|
* @param object root object where we start building the three scene
|
|
132
120
|
* @param drawingId id of the drawing
|
|
133
121
|
* @param root the root of the scene
|
|
134
|
-
* @param
|
|
122
|
+
* @param result object containing all the current collected nodes, solids, meshes
|
|
123
|
+
* @param options e.g. meshPerGeometry controls if each geometry element gets a own mesh or if they will be combined/merged
|
|
135
124
|
*/
|
|
136
|
-
const createRecursiveScene = async (object, drawingId, root, options) => {
|
|
125
|
+
const createRecursiveScene = async (object, drawingId, root, result, options) => {
|
|
137
126
|
let cDrawing = getDrawing(drawingId);
|
|
138
127
|
const tree = cDrawing.structure.tree;
|
|
139
128
|
if (object.link || object.solids) {
|
|
140
129
|
// Part
|
|
141
|
-
const
|
|
142
|
-
if (
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
130
|
+
const entities = object.link ? tree[object.link].solids : object.solids;
|
|
131
|
+
if (entities != undefined) {
|
|
132
|
+
const part = new Group();
|
|
133
|
+
part.matrix = MathUtils.convertToMatrix4(object.coordinateSystem);
|
|
134
|
+
part.matrixAutoUpdate = false;
|
|
135
|
+
part.userData = { id: object.id }; // product reference id
|
|
136
|
+
part.name = object.name; // product reference name
|
|
137
|
+
for (const entity of entities) {
|
|
138
|
+
let cachedEntity = cDrawing.geometry.cache[entity];
|
|
139
|
+
if (!cachedEntity) {
|
|
148
140
|
// else get visualisation from classcad
|
|
149
|
-
await ccAPI.baseModeler.requestVisualisationOfEntities(drawingId, [
|
|
141
|
+
await ccAPI.baseModeler.requestVisualisationOfEntities(drawingId, [entity]);
|
|
150
142
|
cDrawing = getDrawing(drawingId); // get current drawing state after request
|
|
151
|
-
|
|
152
|
-
}
|
|
153
|
-
if (cachedSolid) {
|
|
154
|
-
if (options === null || options === void 0 ? void 0 : options.meshPerFace) {
|
|
155
|
-
meshes = [...meshes, ...cachedSolid.meshes.map(m => m)];
|
|
156
|
-
}
|
|
157
|
-
else {
|
|
158
|
-
cachedSolids.push(cachedSolid);
|
|
159
|
-
}
|
|
143
|
+
cachedEntity = cDrawing.geometry.cache[entity];
|
|
160
144
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
part.matrixAutoUpdate = false;
|
|
181
|
-
part.userData = { id: object.id }; // product reference id
|
|
182
|
-
part.name = object.name; // product reference name
|
|
183
|
-
// A cached solid can have different colored faces, e.g. if a brep has been decorated.
|
|
184
|
-
// In that case, we group the meshes with the same color/tranparency
|
|
185
|
-
for (const cs of cachedSolids) {
|
|
186
|
-
const colorMeshesMap = getDifferentColoredMeshesFromSolid(cs);
|
|
187
|
-
Object.keys(colorMeshesMap).forEach(key => {
|
|
188
|
-
const coloredMeshes = colorMeshesMap[key];
|
|
189
|
-
const mesh = new Mesh();
|
|
190
|
-
mesh.userData = { id: cs.container.ownerId }; // solid id
|
|
191
|
-
mesh.name = tree[cs.container.ownerId].name; // solid name
|
|
192
|
-
mesh.geometry = BufferGeometryUtils.mergeBufferGeometries(coloredMeshes.map(m => m.geometry));
|
|
193
|
-
mesh.material = new MeshStandardMaterial({
|
|
194
|
-
color: coloredMeshes[0].color,
|
|
195
|
-
transparent: coloredMeshes[0].opacity < 1,
|
|
196
|
-
opacity: coloredMeshes[0].opacity,
|
|
145
|
+
if (cachedEntity && cachedEntity.meshes.length > 0) {
|
|
146
|
+
const solidObject = cDrawing.structure.tree[cachedEntity.container.ownerId];
|
|
147
|
+
if (solidObject) {
|
|
148
|
+
const _solid = new Group();
|
|
149
|
+
_solid.name = solidObject.name;
|
|
150
|
+
_solid.userData = { id: solidObject.id }; // add solid id to the userData
|
|
151
|
+
if (options === null || options === void 0 ? void 0 : options.meshPerGeometry) {
|
|
152
|
+
// Create a mesh for each geometry element
|
|
153
|
+
cachedEntity.meshes.forEach(m => {
|
|
154
|
+
const mesh = new Mesh();
|
|
155
|
+
mesh.userData = { id: m.graphicId }; // add graphic id to the userData
|
|
156
|
+
mesh.geometry = m.geometry;
|
|
157
|
+
mesh.material = new MeshStandardMaterial({
|
|
158
|
+
color: m.color,
|
|
159
|
+
transparent: m.opacity < 1,
|
|
160
|
+
opacity: m.opacity,
|
|
161
|
+
});
|
|
162
|
+
_solid.add(mesh);
|
|
163
|
+
result.meshes.push(mesh);
|
|
197
164
|
});
|
|
198
|
-
|
|
199
|
-
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
// Merge all geometries into one mesh, sort them by color
|
|
168
|
+
const colorMeshesMap = getDifferentColoredMeshesFromEntity(cachedEntity);
|
|
169
|
+
Object.keys(colorMeshesMap).forEach(key => {
|
|
170
|
+
const coloredMeshes = colorMeshesMap[key];
|
|
171
|
+
const mesh = new Mesh();
|
|
172
|
+
mesh.geometry = BufferGeometryUtils.mergeBufferGeometries(coloredMeshes.map(m => m.geometry));
|
|
173
|
+
mesh.material = new MeshStandardMaterial({
|
|
174
|
+
color: coloredMeshes[0].color,
|
|
175
|
+
transparent: coloredMeshes[0].opacity < 1,
|
|
176
|
+
opacity: coloredMeshes[0].opacity,
|
|
177
|
+
});
|
|
178
|
+
_solid.add(mesh); // Add mesh to solid of the scene
|
|
179
|
+
result.meshes.push(mesh); // Collect mesh to return result later
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
part.add(_solid);
|
|
183
|
+
result.solids.push(_solid);
|
|
200
184
|
}
|
|
201
|
-
root.add(part);
|
|
202
185
|
}
|
|
203
186
|
}
|
|
187
|
+
root.add(part);
|
|
188
|
+
result.nodes.push(part);
|
|
204
189
|
}
|
|
205
190
|
}
|
|
206
191
|
else if (object.children) {
|
|
@@ -210,22 +195,23 @@ const createRecursiveScene = async (object, drawingId, root, options) => {
|
|
|
210
195
|
assembly.matrixAutoUpdate = false;
|
|
211
196
|
assembly.userData = { id: object.id }; // assembly root or product reference id
|
|
212
197
|
assembly.name = object.name; // assembly root or product reference name
|
|
198
|
+
result.nodes.push(assembly);
|
|
213
199
|
root.add(assembly);
|
|
214
200
|
for (const child of object.children) {
|
|
215
201
|
if (tree[child].class === CCClasses.CCProductReference || tree[child].class === CCClasses.CCProductReferenceET) {
|
|
216
|
-
await createRecursiveScene(tree[child], drawingId, assembly, options);
|
|
202
|
+
await createRecursiveScene(tree[child], drawingId, assembly, result, options);
|
|
217
203
|
}
|
|
218
204
|
}
|
|
219
205
|
}
|
|
220
206
|
};
|
|
221
207
|
/**
|
|
222
208
|
* Get all meshes in a map, sorted by their color / transparency
|
|
223
|
-
* @param
|
|
209
|
+
* @param entity entity to look for the meshes
|
|
224
210
|
* @returns map (key = color/transparency as string, value = meshes array)
|
|
225
211
|
*/
|
|
226
|
-
const
|
|
212
|
+
const getDifferentColoredMeshesFromEntity = (entity) => {
|
|
227
213
|
const colorMeshesMap = {};
|
|
228
|
-
|
|
214
|
+
entity.meshes.forEach(mesh => {
|
|
229
215
|
const key = mesh.color.getHexString() + mesh.opacity.toString();
|
|
230
216
|
if (colorMeshesMap[key]) {
|
|
231
217
|
colorMeshesMap[key].push(mesh);
|
|
@@ -278,12 +264,6 @@ export default class CAD {
|
|
|
278
264
|
throw new Error('Drawing could not be created');
|
|
279
265
|
this.drawingId = drawingId;
|
|
280
266
|
const publicApi = {
|
|
281
|
-
addNode: (productId, ownerId, transformation, name) => {
|
|
282
|
-
return this.resolve(async ([rProductId, rOwnerId]) => {
|
|
283
|
-
const globalTransformation = getGlobalTransformation(drawingId, rOwnerId, transformation) || transformation;
|
|
284
|
-
return ccAPI.assemblyBuilder.addNode(drawingId, rProductId, rOwnerId, globalTransformation, name);
|
|
285
|
-
}, productId, ownerId);
|
|
286
|
-
},
|
|
287
267
|
addNodes: async (...nodes) => {
|
|
288
268
|
var e_1, _a;
|
|
289
269
|
const nodesToAdd = [];
|
|
@@ -309,29 +289,6 @@ export default class CAD {
|
|
|
309
289
|
}
|
|
310
290
|
return ccAPI.assemblyBuilder.addNodes(drawingId, nodesToAdd);
|
|
311
291
|
},
|
|
312
|
-
addDimension: (dim) => {
|
|
313
|
-
return this.resolve(async ([rProductId]) => {
|
|
314
|
-
const dimensionType = getDimensionType(dim.dimParam.dimType);
|
|
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);
|
|
333
|
-
}, dim.productId);
|
|
334
|
-
},
|
|
335
292
|
addDimensions: async (...dimensions) => {
|
|
336
293
|
var e_2, _a;
|
|
337
294
|
const dimParamsToAdd = [];
|
|
@@ -502,7 +459,7 @@ export default class CAD {
|
|
|
502
459
|
const cDrawing = await getDrawing(drawingId);
|
|
503
460
|
const sketchLines = [];
|
|
504
461
|
// TODO: Which sketch lines need to be included, is CCClasses.CCCurve and its derivation enough?
|
|
505
|
-
sketchLines.push(...
|
|
462
|
+
sketchLines.push(...baseUtils.getChildren(rSketchId, CCClasses.CCCurve, cDrawing.structure.tree));
|
|
506
463
|
if (sketchLines) {
|
|
507
464
|
const limit1Param = { value: limit1, isExpr: typeof limit1 === 'string' };
|
|
508
465
|
const limit2Param = { value: limit2, isExpr: typeof limit2 === 'string' };
|
|
@@ -526,8 +483,8 @@ export default class CAD {
|
|
|
526
483
|
if (revolve) {
|
|
527
484
|
const cDrawing = await getDrawing(drawingId);
|
|
528
485
|
const sketchLines = [];
|
|
529
|
-
sketchLines.push(...
|
|
530
|
-
sketchLines.push(...
|
|
486
|
+
sketchLines.push(...baseUtils.getChildren(rSketchId, CCClasses.CCCircle, cDrawing.structure.tree));
|
|
487
|
+
sketchLines.push(...baseUtils.getChildren(rSketchId, CCClasses.CCLine, cDrawing.structure.tree));
|
|
531
488
|
if (sketchLines) {
|
|
532
489
|
const angle1Param = { value: angle1, isExpr: typeof angle1 === 'string' };
|
|
533
490
|
const angle2Param = { value: angle2, isExpr: typeof angle2 === 'string' };
|
|
@@ -613,25 +570,25 @@ export default class CAD {
|
|
|
613
570
|
const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
|
|
614
571
|
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
615
572
|
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
616
|
-
const constraintId = await
|
|
573
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCFastenedConstraint, name);
|
|
617
574
|
if (constraintId != null) {
|
|
618
575
|
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
619
576
|
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
620
577
|
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
621
|
-
await
|
|
578
|
+
await assemblyBuilderAPI.updateFastenedConstraints(drawingId, [
|
|
579
|
+
{
|
|
580
|
+
constrId: constraintId,
|
|
581
|
+
mate1: { matePath: rMatePath1, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented },
|
|
582
|
+
mate2: { matePath: rMatePath2, wcsId: rWcs2, flip: mate2.flip, reoriented: mate2.reoriented },
|
|
583
|
+
xOffset: xOffsetParam,
|
|
584
|
+
yOffset: yOffsetParam,
|
|
585
|
+
zOffset: zOffsetParam,
|
|
586
|
+
},
|
|
587
|
+
]);
|
|
622
588
|
return constraintId;
|
|
623
589
|
}
|
|
624
590
|
return null;
|
|
625
591
|
},
|
|
626
|
-
updateFastenedConstraint: async (constrId, mate1, mate2, xOffset, yOffset, zOffset) => {
|
|
627
|
-
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constrId, mate1.wcsId, mate2.wcsId));
|
|
628
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
629
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
630
|
-
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
631
|
-
const yOffsetParam = { value: yOffset, isExpr: typeof xOffset === 'string' };
|
|
632
|
-
const zOffsetParam = { value: zOffset, isExpr: typeof xOffset === 'string' };
|
|
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);
|
|
634
|
-
},
|
|
635
592
|
updateFastenedConstraints: async (...constraints) => {
|
|
636
593
|
var e_3, _a;
|
|
637
594
|
const constrToAdd = [];
|
|
@@ -671,29 +628,29 @@ export default class CAD {
|
|
|
671
628
|
}
|
|
672
629
|
finally { if (e_3) throw e_3.error; }
|
|
673
630
|
}
|
|
674
|
-
await
|
|
631
|
+
await assemblyBuilderAPI.updateFastenedConstraints(drawingId, constrToAdd);
|
|
675
632
|
},
|
|
676
633
|
createFastenedOriginConstraint: async (asmId, mate1, xOffset, yOffset, zOffset, name) => {
|
|
677
634
|
const [rAsmId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId));
|
|
678
635
|
const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
679
|
-
const constraintId = await
|
|
636
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCFastenedOriginConstraint, name);
|
|
680
637
|
if (constraintId != null) {
|
|
681
638
|
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
682
639
|
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
683
640
|
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
684
|
-
await
|
|
641
|
+
await assemblyBuilderAPI.updateFastenedOriginConstraints(drawingId, [
|
|
642
|
+
{
|
|
643
|
+
constrId: constraintId,
|
|
644
|
+
mate1: { matePath: rMatePath, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented },
|
|
645
|
+
xOffset: xOffsetParam,
|
|
646
|
+
yOffset: yOffsetParam,
|
|
647
|
+
zOffset: zOffsetParam,
|
|
648
|
+
},
|
|
649
|
+
]);
|
|
685
650
|
return constraintId;
|
|
686
651
|
}
|
|
687
652
|
return null;
|
|
688
653
|
},
|
|
689
|
-
updateFastenedOriginConstraint: async (constrId, mate1, xOffset, yOffset, zOffset) => {
|
|
690
|
-
const [rConstrId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), constrId, mate1.wcsId));
|
|
691
|
-
const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
692
|
-
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
693
|
-
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
694
|
-
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
695
|
-
await ccAPI.assemblyBuilder.updateFastenedOriginConstraint(drawingId, rConstrId, { matePath: rMatePath, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented }, xOffsetParam, yOffsetParam, zOffsetParam);
|
|
696
|
-
},
|
|
697
654
|
updateFastenedOriginConstraints: async (...constraints) => {
|
|
698
655
|
var e_4, _a;
|
|
699
656
|
const constraintsToAdd = [];
|
|
@@ -726,7 +683,378 @@ export default class CAD {
|
|
|
726
683
|
}
|
|
727
684
|
finally { if (e_4) throw e_4.error; }
|
|
728
685
|
}
|
|
729
|
-
await
|
|
686
|
+
await assemblyBuilderAPI.updateFastenedOriginConstraints(drawingId, constraintsToAdd);
|
|
687
|
+
},
|
|
688
|
+
createCylindricalConstraint: async (asmId, mate1, mate2, zOffsetLimits, zRotationLimits, name) => {
|
|
689
|
+
const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
|
|
690
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
691
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
692
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCCylindricalConstraint, name);
|
|
693
|
+
if (constraintId != null) {
|
|
694
|
+
await assemblyBuilderAPI.updateCylindricalConstraints(drawingId, [
|
|
695
|
+
{
|
|
696
|
+
constrId: constraintId,
|
|
697
|
+
mate1: {
|
|
698
|
+
matePath: rMatePath1,
|
|
699
|
+
wcsId: rWcs1,
|
|
700
|
+
flip: mate1.flip,
|
|
701
|
+
reoriented: mate1.reoriented,
|
|
702
|
+
},
|
|
703
|
+
mate2: {
|
|
704
|
+
matePath: rMatePath2,
|
|
705
|
+
wcsId: rWcs2,
|
|
706
|
+
flip: mate2.flip,
|
|
707
|
+
reoriented: mate2.reoriented,
|
|
708
|
+
},
|
|
709
|
+
zOffsetLimits,
|
|
710
|
+
zRotationLimits,
|
|
711
|
+
},
|
|
712
|
+
]);
|
|
713
|
+
return constraintId;
|
|
714
|
+
}
|
|
715
|
+
return null;
|
|
716
|
+
},
|
|
717
|
+
updateCylindricalConstraints: async (...constraints) => {
|
|
718
|
+
var e_5, _a;
|
|
719
|
+
const constrToAdd = [];
|
|
720
|
+
try {
|
|
721
|
+
for (var constraints_3 = __asyncValues(constraints), constraints_3_1; constraints_3_1 = await constraints_3.next(), !constraints_3_1.done;) {
|
|
722
|
+
const constr = constraints_3_1.value;
|
|
723
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
724
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
725
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
726
|
+
constrToAdd.push({
|
|
727
|
+
constrId: rConstrId,
|
|
728
|
+
mate1: {
|
|
729
|
+
matePath: rMatePath1,
|
|
730
|
+
wcsId: rWcs1,
|
|
731
|
+
flip: constr.mate1.flip,
|
|
732
|
+
reoriented: constr.mate1.reoriented,
|
|
733
|
+
},
|
|
734
|
+
mate2: {
|
|
735
|
+
matePath: rMatePath2,
|
|
736
|
+
wcsId: rWcs2,
|
|
737
|
+
flip: constr.mate2.flip,
|
|
738
|
+
reoriented: constr.mate2.reoriented,
|
|
739
|
+
},
|
|
740
|
+
zOffsetLimits: constr.zOffsetLimits,
|
|
741
|
+
zRotationLimits: constr.zRotationLimits,
|
|
742
|
+
});
|
|
743
|
+
}
|
|
744
|
+
}
|
|
745
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
746
|
+
finally {
|
|
747
|
+
try {
|
|
748
|
+
if (constraints_3_1 && !constraints_3_1.done && (_a = constraints_3.return)) await _a.call(constraints_3);
|
|
749
|
+
}
|
|
750
|
+
finally { if (e_5) throw e_5.error; }
|
|
751
|
+
}
|
|
752
|
+
await assemblyBuilderAPI.updateCylindricalConstraints(drawingId, constrToAdd);
|
|
753
|
+
},
|
|
754
|
+
createRevoluteConstraint: async (asmId, mate1, mate2, zOffset, zRotationLimits, name) => {
|
|
755
|
+
const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
|
|
756
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
757
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
758
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCRevoluteConstraint, name);
|
|
759
|
+
if (constraintId != null) {
|
|
760
|
+
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
761
|
+
await assemblyBuilderAPI.updateRevoluteConstraints(drawingId, [
|
|
762
|
+
{
|
|
763
|
+
constrId: constraintId,
|
|
764
|
+
mate1: {
|
|
765
|
+
matePath: rMatePath1,
|
|
766
|
+
wcsId: rWcs1,
|
|
767
|
+
flip: mate1.flip,
|
|
768
|
+
reoriented: mate1.reoriented,
|
|
769
|
+
},
|
|
770
|
+
mate2: {
|
|
771
|
+
matePath: rMatePath2,
|
|
772
|
+
wcsId: rWcs2,
|
|
773
|
+
flip: mate2.flip,
|
|
774
|
+
reoriented: mate2.reoriented,
|
|
775
|
+
},
|
|
776
|
+
zOffset: zOffsetParam,
|
|
777
|
+
zRotationLimits,
|
|
778
|
+
},
|
|
779
|
+
]);
|
|
780
|
+
return constraintId;
|
|
781
|
+
}
|
|
782
|
+
return null;
|
|
783
|
+
},
|
|
784
|
+
updateRevoluteConstraints: async (...constraints) => {
|
|
785
|
+
var e_6, _a;
|
|
786
|
+
const constrToAdd = [];
|
|
787
|
+
try {
|
|
788
|
+
for (var constraints_4 = __asyncValues(constraints), constraints_4_1; constraints_4_1 = await constraints_4.next(), !constraints_4_1.done;) {
|
|
789
|
+
const constr = constraints_4_1.value;
|
|
790
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
791
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
792
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
793
|
+
const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
|
|
794
|
+
constrToAdd.push({
|
|
795
|
+
constrId: rConstrId,
|
|
796
|
+
mate1: {
|
|
797
|
+
matePath: rMatePath1,
|
|
798
|
+
wcsId: rWcs1,
|
|
799
|
+
flip: constr.mate1.flip,
|
|
800
|
+
reoriented: constr.mate1.reoriented,
|
|
801
|
+
},
|
|
802
|
+
mate2: {
|
|
803
|
+
matePath: rMatePath2,
|
|
804
|
+
wcsId: rWcs2,
|
|
805
|
+
flip: constr.mate2.flip,
|
|
806
|
+
reoriented: constr.mate2.reoriented,
|
|
807
|
+
},
|
|
808
|
+
zOffset: zOffsetParam,
|
|
809
|
+
zRotationLimits: constr.zRotationLimits,
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
}
|
|
813
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
814
|
+
finally {
|
|
815
|
+
try {
|
|
816
|
+
if (constraints_4_1 && !constraints_4_1.done && (_a = constraints_4.return)) await _a.call(constraints_4);
|
|
817
|
+
}
|
|
818
|
+
finally { if (e_6) throw e_6.error; }
|
|
819
|
+
}
|
|
820
|
+
await assemblyBuilderAPI.updateRevoluteConstraints(drawingId, constrToAdd);
|
|
821
|
+
},
|
|
822
|
+
createSliderConstraint: async (asmId, mate1, mate2, xOffset, yOffset, zOffsetLimits, name) => {
|
|
823
|
+
const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
|
|
824
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
825
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
826
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCSliderConstraint, name);
|
|
827
|
+
if (constraintId != null) {
|
|
828
|
+
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
829
|
+
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
830
|
+
await assemblyBuilderAPI.updateSliderConstraints(drawingId, [
|
|
831
|
+
{
|
|
832
|
+
constrId: constraintId,
|
|
833
|
+
mate1: {
|
|
834
|
+
matePath: rMatePath1,
|
|
835
|
+
wcsId: rWcs1,
|
|
836
|
+
flip: mate1.flip,
|
|
837
|
+
reoriented: mate1.reoriented,
|
|
838
|
+
},
|
|
839
|
+
mate2: {
|
|
840
|
+
matePath: rMatePath2,
|
|
841
|
+
wcsId: rWcs2,
|
|
842
|
+
flip: mate2.flip,
|
|
843
|
+
reoriented: mate2.reoriented,
|
|
844
|
+
},
|
|
845
|
+
xOffset: xOffsetParam,
|
|
846
|
+
yOffset: yOffsetParam,
|
|
847
|
+
zOffsetLimits,
|
|
848
|
+
},
|
|
849
|
+
]);
|
|
850
|
+
return constraintId;
|
|
851
|
+
}
|
|
852
|
+
return null;
|
|
853
|
+
},
|
|
854
|
+
updateSliderConstraints: async (...constraints) => {
|
|
855
|
+
var e_7, _a;
|
|
856
|
+
const constrToAdd = [];
|
|
857
|
+
try {
|
|
858
|
+
for (var constraints_5 = __asyncValues(constraints), constraints_5_1; constraints_5_1 = await constraints_5.next(), !constraints_5_1.done;) {
|
|
859
|
+
const constr = constraints_5_1.value;
|
|
860
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
861
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
862
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
863
|
+
const xOffsetParam = { value: constr.xOffset, isExpr: typeof constr.xOffset === 'string' };
|
|
864
|
+
const yOffsetParam = { value: constr.yOffset, isExpr: typeof constr.yOffset === 'string' };
|
|
865
|
+
constrToAdd.push({
|
|
866
|
+
constrId: rConstrId,
|
|
867
|
+
mate1: {
|
|
868
|
+
matePath: rMatePath1,
|
|
869
|
+
wcsId: rWcs1,
|
|
870
|
+
flip: constr.mate1.flip,
|
|
871
|
+
reoriented: constr.mate1.reoriented,
|
|
872
|
+
},
|
|
873
|
+
mate2: {
|
|
874
|
+
matePath: rMatePath2,
|
|
875
|
+
wcsId: rWcs2,
|
|
876
|
+
flip: constr.mate2.flip,
|
|
877
|
+
reoriented: constr.mate2.reoriented,
|
|
878
|
+
},
|
|
879
|
+
xOffset: xOffsetParam,
|
|
880
|
+
yOffset: yOffsetParam,
|
|
881
|
+
zOffsetLimits: constr.zOffsetLimits,
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
}
|
|
885
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
886
|
+
finally {
|
|
887
|
+
try {
|
|
888
|
+
if (constraints_5_1 && !constraints_5_1.done && (_a = constraints_5.return)) await _a.call(constraints_5);
|
|
889
|
+
}
|
|
890
|
+
finally { if (e_7) throw e_7.error; }
|
|
891
|
+
}
|
|
892
|
+
await assemblyBuilderAPI.updateSliderConstraints(drawingId, constrToAdd);
|
|
893
|
+
},
|
|
894
|
+
createPlanarConstraint: async (asmId, mate1, mate2, zOffset, xOffsetLimits, yOffsetLimits, zRotationLimits, name) => {
|
|
895
|
+
const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
|
|
896
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
897
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
898
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCPlanarConstraint, name);
|
|
899
|
+
if (constraintId != null) {
|
|
900
|
+
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
901
|
+
await assemblyBuilderAPI.updatePlanarConstraints(drawingId, [
|
|
902
|
+
{
|
|
903
|
+
constrId: constraintId,
|
|
904
|
+
mate1: {
|
|
905
|
+
matePath: rMatePath1,
|
|
906
|
+
wcsId: rWcs1,
|
|
907
|
+
flip: mate1.flip,
|
|
908
|
+
reoriented: mate1.reoriented,
|
|
909
|
+
},
|
|
910
|
+
mate2: {
|
|
911
|
+
matePath: rMatePath2,
|
|
912
|
+
wcsId: rWcs2,
|
|
913
|
+
flip: mate2.flip,
|
|
914
|
+
reoriented: mate2.reoriented,
|
|
915
|
+
},
|
|
916
|
+
zOffset: zOffsetParam,
|
|
917
|
+
xOffsetLimits,
|
|
918
|
+
yOffsetLimits,
|
|
919
|
+
zRotationLimits,
|
|
920
|
+
},
|
|
921
|
+
]);
|
|
922
|
+
return constraintId;
|
|
923
|
+
}
|
|
924
|
+
return null;
|
|
925
|
+
},
|
|
926
|
+
updatePlanarConstraints: async (...constraints) => {
|
|
927
|
+
var e_8, _a;
|
|
928
|
+
const constrToAdd = [];
|
|
929
|
+
try {
|
|
930
|
+
for (var constraints_6 = __asyncValues(constraints), constraints_6_1; constraints_6_1 = await constraints_6.next(), !constraints_6_1.done;) {
|
|
931
|
+
const constr = constraints_6_1.value;
|
|
932
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
933
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
934
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
935
|
+
const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
|
|
936
|
+
constrToAdd.push({
|
|
937
|
+
constrId: rConstrId,
|
|
938
|
+
mate1: {
|
|
939
|
+
matePath: rMatePath1,
|
|
940
|
+
wcsId: rWcs1,
|
|
941
|
+
flip: constr.mate1.flip,
|
|
942
|
+
reoriented: constr.mate1.reoriented,
|
|
943
|
+
},
|
|
944
|
+
mate2: {
|
|
945
|
+
matePath: rMatePath2,
|
|
946
|
+
wcsId: rWcs2,
|
|
947
|
+
flip: constr.mate2.flip,
|
|
948
|
+
reoriented: constr.mate2.reoriented,
|
|
949
|
+
},
|
|
950
|
+
zOffset: zOffsetParam,
|
|
951
|
+
xOffsetLimits: constr.xOffsetLimits,
|
|
952
|
+
yOffsetLimits: constr.yOffsetLimits,
|
|
953
|
+
zRotationLimits: constr.zRotationLimits,
|
|
954
|
+
});
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
958
|
+
finally {
|
|
959
|
+
try {
|
|
960
|
+
if (constraints_6_1 && !constraints_6_1.done && (_a = constraints_6.return)) await _a.call(constraints_6);
|
|
961
|
+
}
|
|
962
|
+
finally { if (e_8) throw e_8.error; }
|
|
963
|
+
}
|
|
964
|
+
await assemblyBuilderAPI.updatePlanarConstraints(drawingId, constrToAdd);
|
|
965
|
+
},
|
|
966
|
+
createParallelConstraint: async (asmId, mate1, mate2, xOffsetLimits, yOffsetLimits, zOffsetLimits, zRotationLimits, name) => {
|
|
967
|
+
const [rAsmId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), asmId, mate1.wcsId, mate2.wcsId));
|
|
968
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
969
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
970
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(drawingId, rAsmId, CCClasses.CCParallelConstraint, name);
|
|
971
|
+
if (constraintId != null) {
|
|
972
|
+
await assemblyBuilderAPI.updateParallelConstraints(drawingId, [
|
|
973
|
+
{
|
|
974
|
+
constrId: constraintId,
|
|
975
|
+
mate1: {
|
|
976
|
+
matePath: rMatePath1,
|
|
977
|
+
wcsId: rWcs1,
|
|
978
|
+
flip: mate1.flip,
|
|
979
|
+
reoriented: mate1.reoriented,
|
|
980
|
+
},
|
|
981
|
+
mate2: {
|
|
982
|
+
matePath: rMatePath2,
|
|
983
|
+
wcsId: rWcs2,
|
|
984
|
+
flip: mate2.flip,
|
|
985
|
+
reoriented: mate2.reoriented,
|
|
986
|
+
},
|
|
987
|
+
xOffsetLimits,
|
|
988
|
+
yOffsetLimits,
|
|
989
|
+
zOffsetLimits,
|
|
990
|
+
zRotationLimits,
|
|
991
|
+
},
|
|
992
|
+
]);
|
|
993
|
+
return constraintId;
|
|
994
|
+
}
|
|
995
|
+
return null;
|
|
996
|
+
},
|
|
997
|
+
updateParallelConstraints: async (...constraints) => {
|
|
998
|
+
var e_9, _a;
|
|
999
|
+
const constrToAdd = [];
|
|
1000
|
+
try {
|
|
1001
|
+
for (var constraints_7 = __asyncValues(constraints), constraints_7_1; constraints_7_1 = await constraints_7.next(), !constraints_7_1.done;) {
|
|
1002
|
+
const constr = constraints_7_1.value;
|
|
1003
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
1004
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
1005
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
1006
|
+
constrToAdd.push({
|
|
1007
|
+
constrId: rConstrId,
|
|
1008
|
+
mate1: {
|
|
1009
|
+
matePath: rMatePath1,
|
|
1010
|
+
wcsId: rWcs1,
|
|
1011
|
+
flip: constr.mate1.flip,
|
|
1012
|
+
reoriented: constr.mate1.reoriented,
|
|
1013
|
+
},
|
|
1014
|
+
mate2: {
|
|
1015
|
+
matePath: rMatePath2,
|
|
1016
|
+
wcsId: rWcs2,
|
|
1017
|
+
flip: constr.mate2.flip,
|
|
1018
|
+
reoriented: constr.mate2.reoriented,
|
|
1019
|
+
},
|
|
1020
|
+
xOffsetLimits: constr.xOffsetLimits,
|
|
1021
|
+
yOffsetLimits: constr.yOffsetLimits,
|
|
1022
|
+
zOffsetLimits: constr.zOffsetLimits,
|
|
1023
|
+
zRotationLimits: constr.zRotationLimits,
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
1028
|
+
finally {
|
|
1029
|
+
try {
|
|
1030
|
+
if (constraints_7_1 && !constraints_7_1.done && (_a = constraints_7.return)) await _a.call(constraints_7);
|
|
1031
|
+
}
|
|
1032
|
+
finally { if (e_9) throw e_9.error; }
|
|
1033
|
+
}
|
|
1034
|
+
await assemblyBuilderAPI.updateParallelConstraints(drawingId, constrToAdd);
|
|
1035
|
+
},
|
|
1036
|
+
update3dConstraintValues: async (...constrValues) => {
|
|
1037
|
+
var e_10, _a;
|
|
1038
|
+
const constrValueParams = [];
|
|
1039
|
+
try {
|
|
1040
|
+
for (var constrValues_1 = __asyncValues(constrValues), constrValues_1_1; constrValues_1_1 = await constrValues_1.next(), !constrValues_1_1.done;) {
|
|
1041
|
+
const constrVal = constrValues_1_1.value;
|
|
1042
|
+
const [rConstrId] = await new Promise(res => this.resolve(ids => res(ids), constrVal.constrId));
|
|
1043
|
+
constrValueParams.push({
|
|
1044
|
+
constrId: rConstrId,
|
|
1045
|
+
paramName: constrVal.paramName,
|
|
1046
|
+
value: constrVal.value,
|
|
1047
|
+
});
|
|
1048
|
+
}
|
|
1049
|
+
}
|
|
1050
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
1051
|
+
finally {
|
|
1052
|
+
try {
|
|
1053
|
+
if (constrValues_1_1 && !constrValues_1_1.done && (_a = constrValues_1.return)) await _a.call(constrValues_1);
|
|
1054
|
+
}
|
|
1055
|
+
finally { if (e_10) throw e_10.error; }
|
|
1056
|
+
}
|
|
1057
|
+
await assemblyBuilderAPI.update3DConstraintValues(drawingId, constrValueParams);
|
|
730
1058
|
},
|
|
731
1059
|
createBufferGeometry: async (objectId) => {
|
|
732
1060
|
await this.queue;
|
|
@@ -751,16 +1079,21 @@ export default class CAD {
|
|
|
751
1079
|
const cDrawing = getDrawing(drawingId);
|
|
752
1080
|
const structureTree = cDrawing.structure.tree;
|
|
753
1081
|
const scene = new Scene();
|
|
1082
|
+
const result = {
|
|
1083
|
+
nodes: [],
|
|
1084
|
+
solids: [],
|
|
1085
|
+
meshes: [],
|
|
1086
|
+
};
|
|
754
1087
|
if (rObjectId != null) {
|
|
755
1088
|
const rootObj = structureTree[rObjectId];
|
|
756
1089
|
if (rootObj) {
|
|
757
|
-
await createRecursiveScene(rootObj, drawingId, scene, options);
|
|
1090
|
+
await createRecursiveScene(rootObj, drawingId, scene, result, options);
|
|
758
1091
|
}
|
|
759
1092
|
else {
|
|
760
1093
|
throw new Error('Root object does not exist!');
|
|
761
1094
|
}
|
|
762
1095
|
}
|
|
763
|
-
return scene;
|
|
1096
|
+
return Object.assign({ scene }, result);
|
|
764
1097
|
},
|
|
765
1098
|
createExpressions: (partId, ...members) => {
|
|
766
1099
|
return this.resolve(async ([rPartId]) => {
|
|
@@ -774,18 +1107,20 @@ export default class CAD {
|
|
|
774
1107
|
};
|
|
775
1108
|
membersToAdd.push({ name: mem.name, value: featureAPIParam, dataType });
|
|
776
1109
|
});
|
|
777
|
-
const success = featureAPI.
|
|
1110
|
+
const success = featureAPI.updateExpressionSets(drawingId, [
|
|
1111
|
+
{ productId: rPartId, toAddMembers: membersToAdd, toModifyMembers: [], toDeleteList: [] },
|
|
1112
|
+
]);
|
|
778
1113
|
return success;
|
|
779
1114
|
}, partId);
|
|
780
1115
|
},
|
|
781
1116
|
createAssemblyAsTemplate: (name) => {
|
|
782
1117
|
return this.resolve(async ([]) => {
|
|
783
|
-
return await
|
|
1118
|
+
return await assemblyBuilderAPI.createAssemblyAsTemplate(drawingId, name);
|
|
784
1119
|
});
|
|
785
1120
|
},
|
|
786
1121
|
createRootAssembly: (name) => {
|
|
787
1122
|
return this.resolve(async ([]) => {
|
|
788
|
-
return await
|
|
1123
|
+
return await assemblyBuilderAPI.createRootAssembly(drawingId, name);
|
|
789
1124
|
});
|
|
790
1125
|
},
|
|
791
1126
|
createPart: (name) => {
|
|
@@ -797,7 +1132,7 @@ export default class CAD {
|
|
|
797
1132
|
createPartAsTemplate: (name) => {
|
|
798
1133
|
return this.resolve(async ([]) => {
|
|
799
1134
|
const partName = name ? name : 'Part';
|
|
800
|
-
return await
|
|
1135
|
+
return await assemblyBuilderAPI.createPartAsTemplate(drawingId, partName);
|
|
801
1136
|
});
|
|
802
1137
|
},
|
|
803
1138
|
createWorkAxis: (partId, type, references, position, direction, local, name) => {
|
|
@@ -913,7 +1248,7 @@ export default class CAD {
|
|
|
913
1248
|
},
|
|
914
1249
|
getAssemblyFromContainer: (asmName) => {
|
|
915
1250
|
return this.resolve(async ([]) => {
|
|
916
|
-
const asmIds =
|
|
1251
|
+
const asmIds = asmUtils.getAssemblyFromContainer(drawingId, asmName);
|
|
917
1252
|
if (asmIds != undefined) {
|
|
918
1253
|
return Array.isArray(asmIds) ? asmIds : [asmIds];
|
|
919
1254
|
}
|
|
@@ -922,7 +1257,7 @@ export default class CAD {
|
|
|
922
1257
|
},
|
|
923
1258
|
getAssemblyNode: (refId, nodeName) => {
|
|
924
1259
|
return this.resolve(async ([rRefId]) => {
|
|
925
|
-
const nodeIds =
|
|
1260
|
+
const nodeIds = asmUtils.getAssemblyNode(drawingId, rRefId, nodeName);
|
|
926
1261
|
if (nodeIds != undefined) {
|
|
927
1262
|
return Array.isArray(nodeIds) ? nodeIds : [nodeIds];
|
|
928
1263
|
}
|
|
@@ -931,7 +1266,7 @@ export default class CAD {
|
|
|
931
1266
|
},
|
|
932
1267
|
setCurrentNode: (refId) => {
|
|
933
1268
|
return this.resolve(async ([rRefId]) => {
|
|
934
|
-
await
|
|
1269
|
+
await assemblyBuilderAPI.setCurrentNode(drawingId, rRefId);
|
|
935
1270
|
}, refId);
|
|
936
1271
|
},
|
|
937
1272
|
getCurrentNode: () => {
|
|
@@ -942,7 +1277,7 @@ export default class CAD {
|
|
|
942
1277
|
},
|
|
943
1278
|
getCoordSysFromNode: (refId) => {
|
|
944
1279
|
return this.resolve(async ([rRefId]) => {
|
|
945
|
-
const coordSys =
|
|
1280
|
+
const coordSys = asmUtils.getCoordSysFromNode(drawingId, rRefId);
|
|
946
1281
|
if (coordSys != undefined) {
|
|
947
1282
|
return coordSys;
|
|
948
1283
|
}
|
|
@@ -962,7 +1297,7 @@ export default class CAD {
|
|
|
962
1297
|
},
|
|
963
1298
|
getPartFromContainer: (partName) => {
|
|
964
1299
|
return this.resolve(async ([]) => {
|
|
965
|
-
const partIds =
|
|
1300
|
+
const partIds = asmUtils.getPartFromContainer(drawingId, partName);
|
|
966
1301
|
if (partIds != undefined) {
|
|
967
1302
|
return Array.isArray(partIds) ? partIds : [partIds];
|
|
968
1303
|
}
|
|
@@ -971,22 +1306,144 @@ export default class CAD {
|
|
|
971
1306
|
},
|
|
972
1307
|
getWorkCoordSystem: (refId, wcsName) => {
|
|
973
1308
|
return this.resolve(async ([rRefId]) => {
|
|
974
|
-
|
|
1309
|
+
console.warn('Warning: getWorkCoordSystem() is deprecated, use getWorkGeometry() instead, getWorkCoordSystem() will be removed in a future release.');
|
|
1310
|
+
const wcsIds = asmUtils.getWorkCoordSystem(drawingId, rRefId, wcsName);
|
|
975
1311
|
if (wcsIds != undefined) {
|
|
976
1312
|
return Array.isArray(wcsIds) ? wcsIds : [wcsIds];
|
|
977
1313
|
}
|
|
978
1314
|
return null;
|
|
979
1315
|
}, refId);
|
|
980
1316
|
},
|
|
1317
|
+
getWorkGeometry: (refId, type, wgName) => {
|
|
1318
|
+
return this.resolve(async ([rRefId]) => {
|
|
1319
|
+
const wgIds = asmUtils.getWorkGeometry(drawingId, rRefId, type, wgName);
|
|
1320
|
+
if (wgIds != undefined) {
|
|
1321
|
+
return Array.isArray(wgIds) ? wgIds : [wgIds];
|
|
1322
|
+
}
|
|
1323
|
+
return null;
|
|
1324
|
+
}, refId);
|
|
1325
|
+
},
|
|
981
1326
|
getConstraint: (refId, constrName) => {
|
|
982
1327
|
return this.resolve(async ([rRefId]) => {
|
|
983
|
-
|
|
1328
|
+
console.warn('Warning: getConstraint() is deprecated, use specific methods e.g. getFastenedConstraint() instead, getConstraint() will be removed in a future release.');
|
|
1329
|
+
const constrIds = asmUtils.getConstraint(drawingId, rRefId, constrName);
|
|
984
1330
|
if (constrIds != undefined) {
|
|
985
1331
|
return Array.isArray(constrIds) ? constrIds : [constrIds];
|
|
986
1332
|
}
|
|
987
1333
|
return null;
|
|
988
1334
|
}, refId);
|
|
989
1335
|
},
|
|
1336
|
+
getFastenedConstraint: (refId, constrName) => {
|
|
1337
|
+
return this.resolve(async ([rRefId]) => {
|
|
1338
|
+
const constraint = asmUtils.getFastenedConstraint(drawingId, rRefId, constrName);
|
|
1339
|
+
if (constraint != undefined) {
|
|
1340
|
+
return {
|
|
1341
|
+
constrId: constraint.constrId,
|
|
1342
|
+
mate1: constraint.mate1,
|
|
1343
|
+
mate2: constraint.mate2,
|
|
1344
|
+
xOffset: constraint.xOffset.value,
|
|
1345
|
+
yOffset: constraint.yOffset.value,
|
|
1346
|
+
zOffset: constraint.zOffset.value,
|
|
1347
|
+
};
|
|
1348
|
+
}
|
|
1349
|
+
return null;
|
|
1350
|
+
}, refId);
|
|
1351
|
+
},
|
|
1352
|
+
getFastenedOriginConstraint: (refId, constrName) => {
|
|
1353
|
+
return this.resolve(async ([rRefId]) => {
|
|
1354
|
+
const constraint = asmUtils.getFastenedOriginConstraint(drawingId, rRefId, constrName);
|
|
1355
|
+
if (constraint != undefined) {
|
|
1356
|
+
return {
|
|
1357
|
+
constrId: constraint.constrId,
|
|
1358
|
+
mate1: constraint.mate1,
|
|
1359
|
+
xOffset: constraint.xOffset.value,
|
|
1360
|
+
yOffset: constraint.yOffset.value,
|
|
1361
|
+
zOffset: constraint.zOffset.value,
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
return null;
|
|
1365
|
+
}, refId);
|
|
1366
|
+
},
|
|
1367
|
+
getRevoluteConstraint: (refId, constrName) => {
|
|
1368
|
+
return this.resolve(async ([rRefId]) => {
|
|
1369
|
+
const constraint = asmUtils.getRevoluteConstraint(drawingId, rRefId, constrName);
|
|
1370
|
+
if (constraint != undefined) {
|
|
1371
|
+
return {
|
|
1372
|
+
constrId: constraint.constrId,
|
|
1373
|
+
mate1: constraint.mate1,
|
|
1374
|
+
mate2: constraint.mate2,
|
|
1375
|
+
zOffset: constraint.zOffset.value,
|
|
1376
|
+
zRotationLimits: constraint.zRotationLimits,
|
|
1377
|
+
};
|
|
1378
|
+
}
|
|
1379
|
+
return null;
|
|
1380
|
+
}, refId);
|
|
1381
|
+
},
|
|
1382
|
+
getSliderConstraint: (refId, constrName) => {
|
|
1383
|
+
return this.resolve(async ([rRefId]) => {
|
|
1384
|
+
const constraint = asmUtils.getSliderConstraint(drawingId, rRefId, constrName);
|
|
1385
|
+
if (constraint != undefined) {
|
|
1386
|
+
return {
|
|
1387
|
+
constrId: constraint.constrId,
|
|
1388
|
+
mate1: constraint.mate1,
|
|
1389
|
+
mate2: constraint.mate2,
|
|
1390
|
+
xOffset: constraint.xOffset.value,
|
|
1391
|
+
yOffset: constraint.yOffset.value,
|
|
1392
|
+
zOffsetLimits: constraint.zOffsetLimits,
|
|
1393
|
+
};
|
|
1394
|
+
}
|
|
1395
|
+
return null;
|
|
1396
|
+
}, refId);
|
|
1397
|
+
},
|
|
1398
|
+
getPlanarConstraint: (refId, constrName) => {
|
|
1399
|
+
return this.resolve(async ([rRefId]) => {
|
|
1400
|
+
const constraint = asmUtils.getPlanarConstraint(drawingId, rRefId, constrName);
|
|
1401
|
+
if (constraint != undefined) {
|
|
1402
|
+
return {
|
|
1403
|
+
constrId: constraint.constrId,
|
|
1404
|
+
mate1: constraint.mate1,
|
|
1405
|
+
mate2: constraint.mate2,
|
|
1406
|
+
zOffset: constraint.zOffset.value,
|
|
1407
|
+
xOffsetLimits: constraint.xOffsetLimits,
|
|
1408
|
+
yOffsetLimits: constraint.yOffsetLimits,
|
|
1409
|
+
zRotationLimits: constraint.zRotationLimits,
|
|
1410
|
+
};
|
|
1411
|
+
}
|
|
1412
|
+
return null;
|
|
1413
|
+
}, refId);
|
|
1414
|
+
},
|
|
1415
|
+
getParallelConstraint: (refId, constrName) => {
|
|
1416
|
+
return this.resolve(async ([rRefId]) => {
|
|
1417
|
+
const constraint = asmUtils.getParallelConstraint(drawingId, rRefId, constrName);
|
|
1418
|
+
if (constraint != undefined) {
|
|
1419
|
+
return {
|
|
1420
|
+
constrId: constraint.constrId,
|
|
1421
|
+
mate1: constraint.mate1,
|
|
1422
|
+
mate2: constraint.mate2,
|
|
1423
|
+
xOffsetLimits: constraint.xOffsetLimits,
|
|
1424
|
+
yOffsetLimits: constraint.yOffsetLimits,
|
|
1425
|
+
zOffsetLimits: constraint.zOffsetLimits,
|
|
1426
|
+
zRotationLimits: constraint.zRotationLimits,
|
|
1427
|
+
};
|
|
1428
|
+
}
|
|
1429
|
+
return null;
|
|
1430
|
+
}, refId);
|
|
1431
|
+
},
|
|
1432
|
+
getCylindricalConstraint: (refId, constrName) => {
|
|
1433
|
+
return this.resolve(async ([rRefId]) => {
|
|
1434
|
+
const constraint = asmUtils.getCylindricalConstraint(drawingId, rRefId, constrName);
|
|
1435
|
+
if (constraint != undefined) {
|
|
1436
|
+
return {
|
|
1437
|
+
constrId: constraint.constrId,
|
|
1438
|
+
mate1: constraint.mate1,
|
|
1439
|
+
mate2: constraint.mate2,
|
|
1440
|
+
zOffsetLimits: constraint.zOffsetLimits,
|
|
1441
|
+
zRotationLimits: constraint.zRotationLimits,
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
return null;
|
|
1445
|
+
}, refId);
|
|
1446
|
+
},
|
|
990
1447
|
getFeatureByName: (partId, featureName) => {
|
|
991
1448
|
return this.resolve(async ([rProductId]) => {
|
|
992
1449
|
const feature = await featureAPI.getFeatureByName(drawingId, rProductId, featureName);
|
|
@@ -996,18 +1453,9 @@ export default class CAD {
|
|
|
996
1453
|
return null;
|
|
997
1454
|
}, partId);
|
|
998
1455
|
},
|
|
999
|
-
removeNode: (referenceId, ownerId) => {
|
|
1000
|
-
return this.resolve(async ([rReferenceId, rOwnerId]) => {
|
|
1001
|
-
await ccAPI.assemblyBuilder.removeNode(drawingId, rReferenceId, rOwnerId);
|
|
1002
|
-
}, referenceId, ownerId);
|
|
1003
|
-
},
|
|
1004
1456
|
removeNodes: (...nodes) => {
|
|
1005
1457
|
return this.resolve(async ([...rNodes]) => {
|
|
1006
|
-
|
|
1007
|
-
rNodes.forEach(node => {
|
|
1008
|
-
nodesToRemove.push([node.referenceId, node.ownerId]);
|
|
1009
|
-
});
|
|
1010
|
-
return ccAPI.assemblyBuilder.removeNodes(drawingId, nodesToRemove);
|
|
1458
|
+
return assemblyBuilderAPI.removeNodes(drawingId, rNodes);
|
|
1011
1459
|
}, ...nodes);
|
|
1012
1460
|
},
|
|
1013
1461
|
importFeature: (partId, content, format, name) => {
|
|
@@ -1030,7 +1478,7 @@ export default class CAD {
|
|
|
1030
1478
|
await featureAPI.closeFeature(drawingId, sketch);
|
|
1031
1479
|
const tree = getDrawing(drawingId).structure.tree;
|
|
1032
1480
|
const plane = tree[rPlaneId];
|
|
1033
|
-
if (plane &&
|
|
1481
|
+
if (plane && baseUtils.isA(plane.class, CCClasses.CCWorkPlane)) {
|
|
1034
1482
|
await sketcherAPI.setWorkPlane(drawingId, sketch, rPlaneId);
|
|
1035
1483
|
}
|
|
1036
1484
|
else {
|
|
@@ -1048,7 +1496,7 @@ export default class CAD {
|
|
|
1048
1496
|
await featureAPI.closeFeature(drawingId, sketch);
|
|
1049
1497
|
const tree = getDrawing(drawingId).structure.tree;
|
|
1050
1498
|
const plane = tree[rPlaneId];
|
|
1051
|
-
if (plane &&
|
|
1499
|
+
if (plane && baseUtils.isA(plane.class, CCClasses.CCWorkPlane)) {
|
|
1052
1500
|
await sketcherAPI.setWorkPlane(drawingId, sketch, rPlaneId);
|
|
1053
1501
|
}
|
|
1054
1502
|
else {
|
|
@@ -1066,7 +1514,7 @@ export default class CAD {
|
|
|
1066
1514
|
},
|
|
1067
1515
|
transformNode: (referenceId, ownerId, transformation) => {
|
|
1068
1516
|
return this.resolve(async ([rRefId, rOwnerId]) => {
|
|
1069
|
-
await
|
|
1517
|
+
await assemblyBuilderAPI.setNodeTransformation(drawingId, rRefId, rOwnerId, transformation);
|
|
1070
1518
|
}, referenceId, ownerId);
|
|
1071
1519
|
},
|
|
1072
1520
|
translate: (partId, featureIds, references, inverted, distance) => {
|
|
@@ -1143,7 +1591,9 @@ export default class CAD {
|
|
|
1143
1591
|
};
|
|
1144
1592
|
membersToModify.push({ name: mem.name, value: featureAPIParam });
|
|
1145
1593
|
});
|
|
1146
|
-
const success = featureAPI.
|
|
1594
|
+
const success = featureAPI.updateExpressionSets(drawingId, [
|
|
1595
|
+
{ productId: rPartId, toAddMembers: [], toModifyMembers: membersToModify, toDeleteList: [] },
|
|
1596
|
+
]);
|
|
1147
1597
|
return success;
|
|
1148
1598
|
}, partId);
|
|
1149
1599
|
},
|
|
@@ -1173,7 +1623,9 @@ export default class CAD {
|
|
|
1173
1623
|
},
|
|
1174
1624
|
deleteExpressions: (partId, members) => {
|
|
1175
1625
|
return this.resolve(async ([rPartId]) => {
|
|
1176
|
-
const success = featureAPI.
|
|
1626
|
+
const success = featureAPI.updateExpressionSets(drawingId, [
|
|
1627
|
+
{ productId: rPartId, toAddMembers: [], toModifyMembers: [], toDeleteList: members },
|
|
1628
|
+
]);
|
|
1177
1629
|
return success;
|
|
1178
1630
|
}, partId);
|
|
1179
1631
|
},
|
|
@@ -1188,6 +1640,54 @@ export default class CAD {
|
|
|
1188
1640
|
return null;
|
|
1189
1641
|
}, partId, ...references);
|
|
1190
1642
|
},
|
|
1643
|
+
mirror: async (partId, entities, references) => {
|
|
1644
|
+
const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
|
|
1645
|
+
const rEntities = await new Promise(res => this.resolve(ids => res(ids), ...entities));
|
|
1646
|
+
const rReferences = await new Promise(res => this.resolve(paths => res(paths), ...references));
|
|
1647
|
+
const cDrawing = getDrawing(drawingId);
|
|
1648
|
+
const entArray = [];
|
|
1649
|
+
for (const rEntity of rEntities) {
|
|
1650
|
+
const entity = cDrawing.structure.tree[rEntity].children;
|
|
1651
|
+
if (entity != undefined) {
|
|
1652
|
+
entArray.push(entity[0]);
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
const mirrorId = await featureAPI.createFeature(drawingId, rPartId, CCClasses.CCMirror, 'Mirror');
|
|
1656
|
+
if (mirrorId != null) {
|
|
1657
|
+
await featureAPI.updateMirror(drawingId, mirrorId, entArray, rReferences);
|
|
1658
|
+
return mirrorId;
|
|
1659
|
+
}
|
|
1660
|
+
return null;
|
|
1661
|
+
},
|
|
1662
|
+
removeOperations: async (operations, toOperation) => {
|
|
1663
|
+
const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
|
|
1664
|
+
const [rToOperation] = await new Promise(res => this.resolve(paths => res(paths), toOperation));
|
|
1665
|
+
if (operations && operations.length > 0) {
|
|
1666
|
+
await baseModelerAPI.deleteObjects(drawingId, rOperations);
|
|
1667
|
+
}
|
|
1668
|
+
else if (rToOperation) {
|
|
1669
|
+
const toRemoveOps = [];
|
|
1670
|
+
const cDrawing = getDrawing(drawingId);
|
|
1671
|
+
const tree = cDrawing.structure.tree;
|
|
1672
|
+
const opSeq = cDrawing.api.structure.filterTree(tree, obj => obj.name === 'OperationSequence').pop();
|
|
1673
|
+
const opRefs = opSeq && baseUtils.getChildren(opSeq.id, CCClasses.CCObjectReference, tree);
|
|
1674
|
+
const filteredOps = opRefs === null || opRefs === void 0 ? void 0 : opRefs.map(opRef => { var _a, _b; return (_b = (_a = tree[opRef].members) === null || _a === void 0 ? void 0 : _a.refObj) === null || _b === void 0 ? void 0 : _b.value; });
|
|
1675
|
+
if (filteredOps) {
|
|
1676
|
+
let opNotFound = true;
|
|
1677
|
+
let index = filteredOps.length - 2; // -2 => Avoid RollBackBar
|
|
1678
|
+
while (opNotFound) {
|
|
1679
|
+
if (filteredOps[index] !== rToOperation) {
|
|
1680
|
+
toRemoveOps.push(filteredOps[index]);
|
|
1681
|
+
}
|
|
1682
|
+
else {
|
|
1683
|
+
opNotFound = false;
|
|
1684
|
+
}
|
|
1685
|
+
index--;
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
await baseModelerAPI.deleteObjects(drawingId, toRemoveOps);
|
|
1689
|
+
}
|
|
1690
|
+
},
|
|
1191
1691
|
};
|
|
1192
1692
|
callback(publicApi);
|
|
1193
1693
|
resolve(drawingId);
|