@buerli.io/headless 1.0.1 → 1.1.0-beta.8
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/README.md +24 -24
- package/build/cjs/history.js +2308 -2308
- package/build/cjs/index.js +36 -36
- package/build/cjs/solid.js +479 -479
- package/build/cjs/utils/meshes.js +24 -24
- package/build/cjs/utils/selection.js +32 -32
- package/build/esm/history.js +2303 -2303
- package/build/esm/index.js +8 -8
- package/build/esm/solid.js +473 -473
- package/build/esm/utils/meshes.js +20 -20
- package/build/esm/utils/selection.js +25 -25
- package/build/types/history.d.ts +1852 -1852
- package/build/types/index.d.ts +29 -29
- package/build/types/solid.d.ts +524 -524
- package/build/types/utils/meshes.d.ts +14 -14
- package/build/types/utils/selection.d.ts +4 -4
- package/package.json +2 -2
package/build/esm/history.js
CHANGED
|
@@ -1,2303 +1,2303 @@
|
|
|
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
|
-
};
|
|
8
|
-
/* eslint-disable max-lines */
|
|
9
|
-
import { createApi, CCClasses, ccUtils, DataType, SVGModusType, BuerliCadFacade, } from '@buerli.io/classcad';
|
|
10
|
-
import { api, getDrawing, MathUtils, BuerliScope, createInfo, Measure, } from '@buerli.io/core';
|
|
11
|
-
import { Group, Matrix4, Mesh, MeshStandardMaterial, Scene } from 'three';
|
|
12
|
-
import { mergeBufferGeometries } from 'three-stdlib';
|
|
13
|
-
import { waitForSelect } from './utils/selection';
|
|
14
|
-
import { getDifferentColoredMeshesFromEntity } from './utils/meshes';
|
|
15
|
-
/**
|
|
16
|
-
* Helps to create the buffer geometry of the given object recursively.
|
|
17
|
-
* @param object object to create the buffergeometry from
|
|
18
|
-
* @param bufferGeomArray array to fill up with buffert geometries
|
|
19
|
-
*/
|
|
20
|
-
const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray) => {
|
|
21
|
-
let cDrawing = getDrawing(drawingId);
|
|
22
|
-
const tree = cDrawing.structure.tree;
|
|
23
|
-
if (object.link || object.solids) {
|
|
24
|
-
// Part
|
|
25
|
-
const baseModeler = createApi(drawingId).v0.baseModeler;
|
|
26
|
-
const solids = object.link ? tree[object.link].solids : object.solids;
|
|
27
|
-
if (solids != undefined) {
|
|
28
|
-
let geometries = [];
|
|
29
|
-
for (const solid of solids) {
|
|
30
|
-
let cachedSolid = cDrawing.geometry.cache[solid];
|
|
31
|
-
if (cachedSolid) {
|
|
32
|
-
// if solid already cached, take it from cache
|
|
33
|
-
geometries = [...geometries, ...cachedSolid.meshes.map(m => m.geometry)];
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
// else get visualisation from classcad
|
|
37
|
-
await baseModeler.requestVisualisationOfEntities([solid]);
|
|
38
|
-
cDrawing = getDrawing(drawingId); // get current drawing state after request
|
|
39
|
-
cachedSolid = cDrawing.geometry.cache[solid];
|
|
40
|
-
if (cachedSolid) {
|
|
41
|
-
geometries = [...geometries, ...cachedSolid.meshes.map(m => m.geometry)];
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
console.warn(`There is no cached entry for ${solid}!`, cDrawing.geometry.cache);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
if (geometries.length > 0) {
|
|
49
|
-
const transformation = cDrawing.api.structure.calculateGlobalTransformation(object.id);
|
|
50
|
-
const bufferGeom = mergeBufferGeometries(geometries);
|
|
51
|
-
bufferGeom.applyMatrix4(transformation);
|
|
52
|
-
bufferGeomArray.push(bufferGeom);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
else if (object.children) {
|
|
57
|
-
// Assembly
|
|
58
|
-
for (const child of object.children) {
|
|
59
|
-
if (ccUtils.base.isA(tree[child].class, CCClasses.IProductReference)) {
|
|
60
|
-
await createRecursiveBufferGeometry(tree[child], drawingId, bufferGeomArray);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
/**
|
|
66
|
-
* We traverse recursively over structure tree, starting with object and create THREE objects
|
|
67
|
-
* for the scene. Each part or assembly will be turned into groups and subgroups. Solids which are children of the
|
|
68
|
-
* parts will be turned into groups as well. Children of solids will be merged to meshes. Faces of a solid with different color
|
|
69
|
-
* or transparency will get its own mesh.
|
|
70
|
-
* @param object root object where we start building the three scene
|
|
71
|
-
* @param drawingId id of the drawing
|
|
72
|
-
* @param root the root of the scene
|
|
73
|
-
* @param result object containing all the current collected nodes, solids, meshes
|
|
74
|
-
* @param options e.g. meshPerGeometry controls if each geometry element gets a own mesh or if they will be combined/merged
|
|
75
|
-
*/
|
|
76
|
-
const createRecursiveScene = async (object, drawingId, root, result, options) => {
|
|
77
|
-
let cDrawing = getDrawing(drawingId);
|
|
78
|
-
const tree = cDrawing.structure.tree;
|
|
79
|
-
if (object.link || object.solids) {
|
|
80
|
-
// Part
|
|
81
|
-
const baseModeler = createApi(drawingId).v0.baseModeler;
|
|
82
|
-
const entities = object.link ? tree[object.link].solids : object.solids;
|
|
83
|
-
if (entities != undefined) {
|
|
84
|
-
const part = new Group();
|
|
85
|
-
const matrix = object.coordinateSystem ? MathUtils.convertToMatrix4(object.coordinateSystem) : new Matrix4();
|
|
86
|
-
matrix.decompose(part.position, part.quaternion, part.scale);
|
|
87
|
-
part.updateMatrix();
|
|
88
|
-
part.userData = { id: object.id }; // instance id
|
|
89
|
-
part.name = object.name; // instance name
|
|
90
|
-
for (const entity of entities) {
|
|
91
|
-
let cachedEntity = cDrawing.geometry.cache[entity];
|
|
92
|
-
if (!cachedEntity) {
|
|
93
|
-
// else get visualisation from classcad
|
|
94
|
-
await baseModeler.requestVisualisationOfEntities([entity]);
|
|
95
|
-
cDrawing = getDrawing(drawingId); // get current drawing state after request
|
|
96
|
-
cachedEntity = cDrawing.geometry.cache[entity];
|
|
97
|
-
}
|
|
98
|
-
if (cachedEntity && cachedEntity.meshes.length > 0) {
|
|
99
|
-
const solidObject = cDrawing.structure.tree[cachedEntity.container.ownerId];
|
|
100
|
-
if (solidObject) {
|
|
101
|
-
const _solid = new Group();
|
|
102
|
-
_solid.name = solidObject.name + '_solid';
|
|
103
|
-
_solid.userData = { id: solidObject.id }; // add solid id to the userData
|
|
104
|
-
if (options === null || options === void 0 ? void 0 : options.meshPerGeometry) {
|
|
105
|
-
// Create a mesh for each geometry element
|
|
106
|
-
cachedEntity.meshes.forEach((m, i) => {
|
|
107
|
-
const mesh = new Mesh();
|
|
108
|
-
mesh.name = solidObject.name + '_' + i;
|
|
109
|
-
mesh.userData = { id: m.graphicId }; // add graphic id to the userData
|
|
110
|
-
if (!(options === null || options === void 0 ? void 0 : options.structureOnly)) {
|
|
111
|
-
mesh.geometry = m.geometry;
|
|
112
|
-
mesh.material = new MeshStandardMaterial({
|
|
113
|
-
color: m.color ? m.color : cachedEntity.color,
|
|
114
|
-
transparent: m.color ? m.opacity < 1 : cachedEntity.opacity < 1,
|
|
115
|
-
opacity: m.color ? m.opacity : cachedEntity.opacity,
|
|
116
|
-
});
|
|
117
|
-
mesh.material.name = mesh.name + '_material';
|
|
118
|
-
result.materials[mesh.material.name] = mesh.material;
|
|
119
|
-
}
|
|
120
|
-
result.nodes[mesh.name] = mesh;
|
|
121
|
-
_solid.add(mesh);
|
|
122
|
-
});
|
|
123
|
-
part.add(_solid);
|
|
124
|
-
result.nodes[_solid.name] = _solid;
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
// Merge all geometries into one mesh, sort them by color
|
|
128
|
-
const colorMeshesMap = getDifferentColoredMeshesFromEntity(cachedEntity);
|
|
129
|
-
const colorMeshes = Object.keys(colorMeshesMap);
|
|
130
|
-
if (colorMeshes.length > 1) {
|
|
131
|
-
// If the solid consists of multiple meshes we must keep the group
|
|
132
|
-
colorMeshes.forEach((key, i) => {
|
|
133
|
-
const mesh = new Mesh();
|
|
134
|
-
mesh.name = solidObject.name + '_' + i;
|
|
135
|
-
mesh.userData = { id: solidObject.id }; // add solid id to the userData
|
|
136
|
-
if (!(options === null || options === void 0 ? void 0 : options.structureOnly)) {
|
|
137
|
-
mesh.geometry = mergeBufferGeometries(colorMeshesMap[key].meshes.map(m => m.geometry));
|
|
138
|
-
mesh.material = new MeshStandardMaterial({
|
|
139
|
-
color: colorMeshesMap[key].color,
|
|
140
|
-
transparent: colorMeshesMap[key].opacity < 1,
|
|
141
|
-
opacity: colorMeshesMap[key].opacity,
|
|
142
|
-
});
|
|
143
|
-
mesh.material.name = mesh.name + '_material';
|
|
144
|
-
result.materials[mesh.material.name] = mesh.material;
|
|
145
|
-
}
|
|
146
|
-
result.nodes[mesh.name] = mesh; // Collect mesh to return result later
|
|
147
|
-
_solid.add(mesh); // Add mesh to solid of the scene
|
|
148
|
-
});
|
|
149
|
-
part.add(_solid);
|
|
150
|
-
result.nodes[_solid.name] = _solid;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
// Otherwise we can use the mesh itself
|
|
154
|
-
const key = colorMeshes[0];
|
|
155
|
-
const mesh = new Mesh();
|
|
156
|
-
mesh.name = solidObject.name;
|
|
157
|
-
mesh.userData = { id: solidObject.id }; // add solid id to the userData
|
|
158
|
-
if (!(options === null || options === void 0 ? void 0 : options.structureOnly)) {
|
|
159
|
-
mesh.geometry = mergeBufferGeometries(colorMeshesMap[key].meshes.map(m => m.geometry));
|
|
160
|
-
mesh.material = new MeshStandardMaterial({
|
|
161
|
-
color: colorMeshesMap[key].color,
|
|
162
|
-
transparent: colorMeshesMap[key].opacity < 1,
|
|
163
|
-
opacity: colorMeshesMap[key].opacity,
|
|
164
|
-
});
|
|
165
|
-
mesh.material.name = mesh.name + '_material';
|
|
166
|
-
result.materials[mesh.material.name] = mesh.material;
|
|
167
|
-
}
|
|
168
|
-
result.nodes[mesh.name] = mesh;
|
|
169
|
-
part.add(mesh);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
root.add(part);
|
|
176
|
-
result.nodes[part.name] = part;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
else if (object.children) {
|
|
180
|
-
// Assembly
|
|
181
|
-
const assembly = new Group();
|
|
182
|
-
const matrix = object.coordinateSystem ? MathUtils.convertToMatrix4(object.coordinateSystem) : new Matrix4();
|
|
183
|
-
matrix.decompose(assembly.position, assembly.quaternion, assembly.scale);
|
|
184
|
-
assembly.updateMatrix();
|
|
185
|
-
assembly.userData = { id: object.id }; // assembly root or instance id
|
|
186
|
-
assembly.name = object.name; // assembly root or instance name
|
|
187
|
-
result.nodes[assembly.name] = assembly;
|
|
188
|
-
root.add(assembly);
|
|
189
|
-
for (const child of object.children) {
|
|
190
|
-
if (ccUtils.base.isA(tree[child].class, CCClasses.IProductReference)) {
|
|
191
|
-
await createRecursiveScene(tree[child], drawingId, assembly, result, options);
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
};
|
|
196
|
-
const resolveVec = (value) => {
|
|
197
|
-
const valueX = Array.isArray(value) ? value[0] : value.x;
|
|
198
|
-
const valueY = Array.isArray(value) ? value[1] : value.y;
|
|
199
|
-
const valueZ = Array.isArray(value) ? value[2] : value.z;
|
|
200
|
-
if (typeof valueX === 'string' || typeof valueY === 'string' || typeof valueZ === 'string') {
|
|
201
|
-
return '{' + valueX + ',' + valueY + ',' + valueZ + '}';
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
return { x: valueX, y: valueY, z: valueZ };
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
export class History {
|
|
208
|
-
constructor() {
|
|
209
|
-
this.drawingId = null;
|
|
210
|
-
this.queue = Promise.resolve(0);
|
|
211
|
-
this.queue = Promise.resolve(0);
|
|
212
|
-
}
|
|
213
|
-
resolve(callback, ...args) {
|
|
214
|
-
return (this.queue = this.queue
|
|
215
|
-
.then(() => Promise.all(args).then(callback))
|
|
216
|
-
.catch(e => {
|
|
217
|
-
// catch is necessary to avoid error promises in the queue
|
|
218
|
-
}));
|
|
219
|
-
}
|
|
220
|
-
init(callback) {
|
|
221
|
-
const promise = new Promise(async (resolve, reject) => {
|
|
222
|
-
const drawingId = await BuerliCadFacade.utils.connect('history');
|
|
223
|
-
if (!drawingId)
|
|
224
|
-
throw new Error('Connection/Drawing could not be created');
|
|
225
|
-
this.drawingId = drawingId;
|
|
226
|
-
const cc = createApi(drawingId);
|
|
227
|
-
const featureAPI = cc.v0.feature;
|
|
228
|
-
const sketcherAPI = cc.v0.sketcher;
|
|
229
|
-
const baseModelerAPI = cc.v0.baseModeler;
|
|
230
|
-
const assemblyBuilderAPI = cc.v0.assemblyBuilder;
|
|
231
|
-
const drawing2DAPI = cc.v0.drawing2D;
|
|
232
|
-
const geometryAPI = cc.v0.geometry;
|
|
233
|
-
const baseUtils = ccUtils.base;
|
|
234
|
-
const asmUtils = ccUtils.assembly;
|
|
235
|
-
const partUtils = ccUtils.part;
|
|
236
|
-
const publicApi = {
|
|
237
|
-
getDrawingId: () => drawingId,
|
|
238
|
-
getDrawing: () => getDrawing(drawingId),
|
|
239
|
-
getState: () => api.getState(),
|
|
240
|
-
setFacetingParameters: (distanceTol, angleTol) => this.resolve(async () => cc.v0.common.setFacetingParameters(distanceTol, angleTol)),
|
|
241
|
-
addInstances: async (...instances) => {
|
|
242
|
-
var e_1, _a;
|
|
243
|
-
const instancesToAdd = [];
|
|
244
|
-
try {
|
|
245
|
-
for (var instances_1 = __asyncValues(instances), instances_1_1; instances_1_1 = await instances_1.next(), !instances_1_1.done;) {
|
|
246
|
-
const instance = instances_1_1.value;
|
|
247
|
-
const [rProductId, rOwnerId] = await new Promise(res => this.resolve(id => res(id), instance.productId, instance.ownerId));
|
|
248
|
-
// Looking for the productId given by an identifier or name
|
|
249
|
-
// Priorities:
|
|
250
|
-
// 1. Look for the identifier then for the name in the part templates
|
|
251
|
-
// 2. Look for the identifier then for the name in the assembly templates
|
|
252
|
-
let product = rProductId;
|
|
253
|
-
if (typeof rProductId === 'string') {
|
|
254
|
-
let products = asmUtils.getPartTemplate(drawingId, rProductId);
|
|
255
|
-
if (products.length > 1) {
|
|
256
|
-
throw 'More than one product has been found for given name or ident: ' + rProductId;
|
|
257
|
-
}
|
|
258
|
-
else if (products.length < 1) {
|
|
259
|
-
products = asmUtils.getAssemblyTemplate(drawingId, rProductId);
|
|
260
|
-
if (products.length < 1) {
|
|
261
|
-
throw 'No product found for given name or ident: ' + rProductId;
|
|
262
|
-
}
|
|
263
|
-
else if (products.length > 1) {
|
|
264
|
-
throw 'More than one product has been found for given name or ident: ' + rProductId;
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
product = products[0];
|
|
268
|
-
}
|
|
269
|
-
let owner = rOwnerId;
|
|
270
|
-
if (typeof rOwnerId === 'string') {
|
|
271
|
-
owner = baseUtils.findObject(drawingId, {
|
|
272
|
-
ident: rOwnerId,
|
|
273
|
-
name: rOwnerId,
|
|
274
|
-
});
|
|
275
|
-
if (!owner) {
|
|
276
|
-
throw 'The owner to add instances on given by name or ident "' + rOwnerId + '" does not exist.';
|
|
277
|
-
}
|
|
278
|
-
const clazz = getDrawing(drawingId).structure.tree[owner].class;
|
|
279
|
-
if (!baseUtils.isA(clazz, CCClasses.IProductReference) && !baseUtils.isA(clazz, CCClasses.CCAssembly)) {
|
|
280
|
-
throw ('The owner to add instances on given by name or ident "' +
|
|
281
|
-
rOwnerId +
|
|
282
|
-
'" is of the wrong type: "' +
|
|
283
|
-
clazz +
|
|
284
|
-
'". Make sure the owner is an instance, a root assembly or an assembly template.');
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
const instanceParam = {
|
|
288
|
-
productId: product,
|
|
289
|
-
ownerId: owner,
|
|
290
|
-
transformation: instance.transformation,
|
|
291
|
-
name: instance.name,
|
|
292
|
-
options: Object.assign(Object.assign({}, instance.options), { isLocal: true }), // in non-interactive mode, the transformation is local to the owner
|
|
293
|
-
};
|
|
294
|
-
instancesToAdd.push(instanceParam);
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
298
|
-
finally {
|
|
299
|
-
try {
|
|
300
|
-
if (instances_1_1 && !instances_1_1.done && (_a = instances_1.return)) await _a.call(instances_1);
|
|
301
|
-
}
|
|
302
|
-
finally { if (e_1) throw e_1.error; }
|
|
303
|
-
}
|
|
304
|
-
return assemblyBuilderAPI.addInstances(instancesToAdd);
|
|
305
|
-
},
|
|
306
|
-
addDimensions: async (...dimensions) => {
|
|
307
|
-
var e_2, _a;
|
|
308
|
-
const dimParamsToAdd = [];
|
|
309
|
-
try {
|
|
310
|
-
for (var dimensions_1 = __asyncValues(dimensions), dimensions_1_1; dimensions_1_1 = await dimensions_1.next(), !dimensions_1_1.done;) {
|
|
311
|
-
const dim = dimensions_1_1.value;
|
|
312
|
-
const [rProductId] = await new Promise(res => this.resolve(id => res(id), dim.productId));
|
|
313
|
-
switch (dim.param.type) {
|
|
314
|
-
case CCClasses.CCLinearDimension:
|
|
315
|
-
const linearDimParam = Object.assign(Object.assign({}, dim), { productId: rProductId, param: Object.assign(Object.assign({}, dim.param), { startPos: resolveVec(dim.param.startPos), endPos: resolveVec(dim.param.endPos), textPos: resolveVec(dim.param.textPos) }) });
|
|
316
|
-
dimParamsToAdd.push(linearDimParam);
|
|
317
|
-
break;
|
|
318
|
-
case CCClasses.CCRadialDimension:
|
|
319
|
-
const radialDimParam = Object.assign(Object.assign({}, dim), { productId: rProductId, param: Object.assign(Object.assign({}, dim.param), { centerPos: resolveVec(dim.param.centerPos), textPos: resolveVec(dim.param.textPos) }) });
|
|
320
|
-
dimParamsToAdd.push(radialDimParam);
|
|
321
|
-
break;
|
|
322
|
-
case CCClasses.CCDiameterDimension:
|
|
323
|
-
const diameterDimParam = Object.assign(Object.assign({}, dim), { productId: rProductId, param: Object.assign(Object.assign({}, dim.param), { centerPos: resolveVec(dim.param.centerPos), textPos: resolveVec(dim.param.textPos) }) });
|
|
324
|
-
dimParamsToAdd.push(diameterDimParam);
|
|
325
|
-
break;
|
|
326
|
-
case CCClasses.CCAngularDimension:
|
|
327
|
-
const angularDimParam = Object.assign(Object.assign({}, dim), { productId: rProductId, param: Object.assign(Object.assign({}, dim.param), { startPos: resolveVec(dim.param.startPos), endPos: resolveVec(dim.param.endPos), cornerPos: resolveVec(dim.param.cornerPos), textPos: resolveVec(dim.param.textPos) }) });
|
|
328
|
-
dimParamsToAdd.push(angularDimParam);
|
|
329
|
-
break;
|
|
330
|
-
default:
|
|
331
|
-
break;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
336
|
-
finally {
|
|
337
|
-
try {
|
|
338
|
-
if (dimensions_1_1 && !dimensions_1_1.done && (_a = dimensions_1.return)) await _a.call(dimensions_1);
|
|
339
|
-
}
|
|
340
|
-
finally { if (e_2) throw e_2.error; }
|
|
341
|
-
}
|
|
342
|
-
return drawing2DAPI.addDimensions(dimParamsToAdd); // TODO v0 typescript error because of DimensionParam
|
|
343
|
-
},
|
|
344
|
-
create2DViews: (productId, viewTypes, viewOptions) => {
|
|
345
|
-
return this.resolve(async ([rProductId]) => {
|
|
346
|
-
const viewIds = await drawing2DAPI.create2DViews(rProductId, viewTypes, viewOptions);
|
|
347
|
-
if (viewIds !== null) {
|
|
348
|
-
await drawing2DAPI.centerAllViews(rProductId, viewTypes);
|
|
349
|
-
return viewIds;
|
|
350
|
-
}
|
|
351
|
-
return null;
|
|
352
|
-
}, productId);
|
|
353
|
-
},
|
|
354
|
-
getBoundaryBoxFromViews: (productId, viewTypes) => {
|
|
355
|
-
return this.resolve(async ([rProductId]) => {
|
|
356
|
-
const bbs = await drawing2DAPI.getBoundaryBoxFromViews(rProductId, viewTypes);
|
|
357
|
-
return bbs;
|
|
358
|
-
}, productId);
|
|
359
|
-
},
|
|
360
|
-
place2DViews: (productId, viewPositions) => {
|
|
361
|
-
return this.resolve(async ([rProductId]) => {
|
|
362
|
-
return drawing2DAPI.place2DViews(rProductId, viewPositions.map(({ viewType, vector }) => ({
|
|
363
|
-
viewType,
|
|
364
|
-
vector: resolveVec(vector),
|
|
365
|
-
})));
|
|
366
|
-
}, productId);
|
|
367
|
-
},
|
|
368
|
-
exportDXF: (productId, dxfTemplateFilename) => {
|
|
369
|
-
return this.resolve(async ([rProductId]) => {
|
|
370
|
-
return drawing2DAPI.exportDXF(rProductId, dxfTemplateFilename);
|
|
371
|
-
}, productId);
|
|
372
|
-
},
|
|
373
|
-
exportSVG: (productId, modus, renderSize, dxfTemplateFilename) => {
|
|
374
|
-
return this.resolve(async ([rProductId]) => {
|
|
375
|
-
modus = modus ? modus : SVGModusType.FIT_WHOLE_DRAWING;
|
|
376
|
-
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;
|
|
377
|
-
return drawing2DAPI.exportSVG(rProductId, modus, renderSizeParam, dxfTemplateFilename);
|
|
378
|
-
}, productId);
|
|
379
|
-
},
|
|
380
|
-
removeDimensions: (dimensionIds) => {
|
|
381
|
-
return this.resolve(async ([...rDimensionIds]) => {
|
|
382
|
-
return drawing2DAPI.removeDimensions(rDimensionIds);
|
|
383
|
-
}, ...dimensionIds);
|
|
384
|
-
},
|
|
385
|
-
linearPattern: (partId, operations, references1, params1, references2, params2) => {
|
|
386
|
-
return this.resolve(async ([rPartId, rOperations, rReferences1, rReferences2]) => {
|
|
387
|
-
const patternId = await featureAPI.createFeature(rPartId, CCClasses.CCLinearPattern, 'LinearPattern');
|
|
388
|
-
if (patternId != null) {
|
|
389
|
-
// entities
|
|
390
|
-
const cDrawing = await getDrawing(drawingId);
|
|
391
|
-
const entArray = [];
|
|
392
|
-
for (const rOperation of rOperations) {
|
|
393
|
-
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
394
|
-
if (entities != undefined) {
|
|
395
|
-
entArray.push(entities[0]);
|
|
396
|
-
}
|
|
397
|
-
}
|
|
398
|
-
const distance1Param = {
|
|
399
|
-
value: params1.distance,
|
|
400
|
-
isExpr: typeof params1.distance === 'string',
|
|
401
|
-
};
|
|
402
|
-
const count1Param = {
|
|
403
|
-
value: params1.count,
|
|
404
|
-
isExpr: typeof params1.count === 'string',
|
|
405
|
-
};
|
|
406
|
-
const params1Param = [
|
|
407
|
-
params1.inverted,
|
|
408
|
-
distance1Param,
|
|
409
|
-
count1Param,
|
|
410
|
-
params1.merged,
|
|
411
|
-
];
|
|
412
|
-
let params2Param = null;
|
|
413
|
-
if (params2) {
|
|
414
|
-
const distance2Param = {
|
|
415
|
-
value: params2.distance,
|
|
416
|
-
isExpr: typeof params2.distance === 'string',
|
|
417
|
-
};
|
|
418
|
-
const count2Param = {
|
|
419
|
-
value: params2.count,
|
|
420
|
-
isExpr: typeof params2.count === 'string',
|
|
421
|
-
};
|
|
422
|
-
params2Param = [params2.inverted, distance2Param, count2Param];
|
|
423
|
-
}
|
|
424
|
-
// resolve references1
|
|
425
|
-
const refs1 = [];
|
|
426
|
-
let refs2 = [];
|
|
427
|
-
for (const rRef1 of rReferences1) {
|
|
428
|
-
refs1.push(await rRef1);
|
|
429
|
-
}
|
|
430
|
-
// resolve references2 if present
|
|
431
|
-
if (rReferences2) {
|
|
432
|
-
for (const rRef2 of rReferences2) {
|
|
433
|
-
refs2.push(await rRef2);
|
|
434
|
-
}
|
|
435
|
-
}
|
|
436
|
-
else {
|
|
437
|
-
refs2 = null;
|
|
438
|
-
}
|
|
439
|
-
await featureAPI.updatePattern(patternId, entArray, refs1, params1Param, refs2, params2Param);
|
|
440
|
-
return patternId;
|
|
441
|
-
}
|
|
442
|
-
return null;
|
|
443
|
-
}, partId, operations, references1, references2);
|
|
444
|
-
},
|
|
445
|
-
circularPattern: (partId, operations, references, params) => {
|
|
446
|
-
return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
|
|
447
|
-
const patternId = await featureAPI.createFeature(rPartId, CCClasses.CCCircularPattern, 'CircularPattern');
|
|
448
|
-
if (patternId != null) {
|
|
449
|
-
// entities
|
|
450
|
-
const cDrawing = await getDrawing(drawingId);
|
|
451
|
-
const entArray = [];
|
|
452
|
-
for (const rOperation of rOperations) {
|
|
453
|
-
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
454
|
-
if (entities != undefined) {
|
|
455
|
-
entArray.push(entities[0]);
|
|
456
|
-
}
|
|
457
|
-
}
|
|
458
|
-
const angleParam = { value: params.angle, isExpr: typeof params.angle === 'string' };
|
|
459
|
-
const countParam = { value: params.count, isExpr: typeof params.count === 'string' };
|
|
460
|
-
const paramsParam = [
|
|
461
|
-
params.inverted,
|
|
462
|
-
angleParam,
|
|
463
|
-
countParam,
|
|
464
|
-
params.merged,
|
|
465
|
-
];
|
|
466
|
-
rReferences = Array.isArray(rReferences) ? rReferences : [rReferences];
|
|
467
|
-
await featureAPI.updatePattern(patternId, entArray, rReferences, paramsParam, null, null);
|
|
468
|
-
return patternId;
|
|
469
|
-
}
|
|
470
|
-
return null;
|
|
471
|
-
}, partId, operations, ...references);
|
|
472
|
-
},
|
|
473
|
-
extrusion: (partId, sketchOrRegionIds, type, limit1, limit2, taperAngle, direction, capEnds) => {
|
|
474
|
-
return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
|
|
475
|
-
const extrusion = await featureAPI.createFeature(rPartId, CCClasses.CCExtrusion, 'Extrusion');
|
|
476
|
-
if (extrusion) {
|
|
477
|
-
const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
|
|
478
|
-
? rSketchOrRegionIds
|
|
479
|
-
: [rSketchOrRegionIds];
|
|
480
|
-
if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
|
|
481
|
-
const limit1Param = { value: limit1, isExpr: typeof limit1 === 'string' };
|
|
482
|
-
const limit2Param = { value: limit2, isExpr: typeof limit2 === 'string' };
|
|
483
|
-
const taperAngleParam = {
|
|
484
|
-
value: taperAngle,
|
|
485
|
-
isExpr: typeof taperAngle === 'string',
|
|
486
|
-
};
|
|
487
|
-
const resDirection = resolveVec(direction);
|
|
488
|
-
const directionParam = {
|
|
489
|
-
value: resDirection,
|
|
490
|
-
isExpr: typeof resDirection === 'string',
|
|
491
|
-
};
|
|
492
|
-
await featureAPI.updateExtrusion(extrusion, resSketchOrRegionIds, type, limit1Param, limit2Param, taperAngleParam, directionParam, capEnds);
|
|
493
|
-
return extrusion;
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}, partId, sketchOrRegionIds);
|
|
497
|
-
},
|
|
498
|
-
revolve: (partId, sketchOrRegionIds, axisIds, angle1, angle2, inverted) => {
|
|
499
|
-
return this.resolve(async ([rPartId, rSketchOrRegionIds, ...rAxisIds]) => {
|
|
500
|
-
const revolve = await featureAPI.createFeature(rPartId, CCClasses.CCRevolve, 'Revolve');
|
|
501
|
-
if (revolve) {
|
|
502
|
-
const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
|
|
503
|
-
? rSketchOrRegionIds
|
|
504
|
-
: [rSketchOrRegionIds];
|
|
505
|
-
if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
|
|
506
|
-
const angle1Param = { value: angle1, isExpr: typeof angle1 === 'string' };
|
|
507
|
-
const angle2Param = { value: angle2, isExpr: typeof angle2 === 'string' };
|
|
508
|
-
await featureAPI.updateRevolve(revolve, resSketchOrRegionIds, rAxisIds, angle1Param, angle2Param, inverted);
|
|
509
|
-
return revolve;
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
}, partId, sketchOrRegionIds, ...axisIds);
|
|
513
|
-
},
|
|
514
|
-
boolean: (partId, type, operations) => {
|
|
515
|
-
return this.resolve(async ([rPartId, rOperations]) => {
|
|
516
|
-
const cDrawing = await getDrawing(drawingId);
|
|
517
|
-
const entArray = [];
|
|
518
|
-
for (const rOperation of rOperations) {
|
|
519
|
-
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
520
|
-
if (entities != undefined) {
|
|
521
|
-
entArray.push(entities[0]);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
const boolId = await featureAPI.createFeature(rPartId, CCClasses.CCUnion, 'Union');
|
|
525
|
-
if (boolId != null) {
|
|
526
|
-
await featureAPI.updateBooleanOperation(boolId, type, entArray);
|
|
527
|
-
return boolId;
|
|
528
|
-
}
|
|
529
|
-
return null;
|
|
530
|
-
}, partId, operations);
|
|
531
|
-
},
|
|
532
|
-
box: (partId, references, width, length, height) => {
|
|
533
|
-
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
534
|
-
const boxId = await featureAPI.createFeature(rPartId, CCClasses.CCBox, 'Box');
|
|
535
|
-
if (boxId != null) {
|
|
536
|
-
const widthParam = { value: width, isExpr: typeof width === 'string' };
|
|
537
|
-
const lengthParam = { value: length, isExpr: typeof length === 'string' };
|
|
538
|
-
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
539
|
-
await featureAPI.updateBox(boxId, rReferences, widthParam, lengthParam, heightParam);
|
|
540
|
-
return boxId;
|
|
541
|
-
}
|
|
542
|
-
return null;
|
|
543
|
-
}, partId, ...references);
|
|
544
|
-
},
|
|
545
|
-
cylinder: (partId, references, diameter, height) => {
|
|
546
|
-
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
547
|
-
const cylId = await featureAPI.createFeature(rPartId, CCClasses.CCCylinder, 'Cylinder');
|
|
548
|
-
if (cylId != null) {
|
|
549
|
-
const diameterParam = { value: diameter, isExpr: typeof diameter === 'string' };
|
|
550
|
-
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
551
|
-
await featureAPI.updateCylinder(cylId, rReferences, diameterParam, heightParam);
|
|
552
|
-
return cylId;
|
|
553
|
-
}
|
|
554
|
-
return null;
|
|
555
|
-
}, partId, ...references);
|
|
556
|
-
},
|
|
557
|
-
chamfer: (partId, type, references, dist1, dist2, angle) => {
|
|
558
|
-
return this.resolve(async ([rPartId, rReferences]) => {
|
|
559
|
-
const dist1Param = { value: dist1, isExpr: typeof dist1 === 'string' };
|
|
560
|
-
const dist2Param = { value: dist2, isExpr: typeof dist2 === 'string' };
|
|
561
|
-
const angleParam = { value: angle, isExpr: typeof angle === 'string' };
|
|
562
|
-
const chamferId = await featureAPI.createFeature(rPartId, CCClasses.CCChamfer, 'Chamfer');
|
|
563
|
-
if (chamferId != null) {
|
|
564
|
-
await featureAPI.updateChamfer(chamferId, type, rReferences, dist1Param, dist2Param, angleParam);
|
|
565
|
-
return chamferId;
|
|
566
|
-
}
|
|
567
|
-
return null;
|
|
568
|
-
}, partId, references);
|
|
569
|
-
},
|
|
570
|
-
cone: (partId, references, bDiameter, tDiameter, height) => {
|
|
571
|
-
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
572
|
-
const coneId = await featureAPI.createFeature(rPartId, CCClasses.CCCone, 'Cone');
|
|
573
|
-
if (coneId != null) {
|
|
574
|
-
const bDiamParam = { value: bDiameter, isExpr: typeof bDiameter === 'string' };
|
|
575
|
-
const tDiamParam = { value: tDiameter, isExpr: typeof tDiameter === 'string' };
|
|
576
|
-
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
577
|
-
await featureAPI.updateCone(coneId, rReferences, bDiamParam, tDiamParam, heightParam);
|
|
578
|
-
return coneId;
|
|
579
|
-
}
|
|
580
|
-
return null;
|
|
581
|
-
}, partId, ...references);
|
|
582
|
-
},
|
|
583
|
-
createFastenedConstraint: async (id, mate1, mate2, xOffset, yOffset, zOffset, name, xRotation, yRotation, zRotation) => {
|
|
584
|
-
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
585
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
586
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
587
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCFastenedConstraint, name);
|
|
588
|
-
if (constraintId != null) {
|
|
589
|
-
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
590
|
-
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
591
|
-
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
592
|
-
const xRotationParam = { value: xRotation || 0, isExpr: typeof xRotation === 'string' };
|
|
593
|
-
const yRotationParam = { value: yRotation || 0, isExpr: typeof yRotation === 'string' };
|
|
594
|
-
const zRotationParam = { value: zRotation || 0, isExpr: typeof zRotation === 'string' };
|
|
595
|
-
await assemblyBuilderAPI.updateFastenedConstraints([
|
|
596
|
-
{
|
|
597
|
-
constrId: constraintId,
|
|
598
|
-
mate1: { matePath: rMatePath1, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented },
|
|
599
|
-
mate2: { matePath: rMatePath2, wcsId: rWcs2, flip: mate2.flip, reoriented: mate2.reoriented },
|
|
600
|
-
xOffset: xOffsetParam,
|
|
601
|
-
yOffset: yOffsetParam,
|
|
602
|
-
zOffset: zOffsetParam,
|
|
603
|
-
xRotation: xRotationParam,
|
|
604
|
-
yRotation: yRotationParam,
|
|
605
|
-
zRotation: zRotationParam,
|
|
606
|
-
},
|
|
607
|
-
]);
|
|
608
|
-
return constraintId;
|
|
609
|
-
}
|
|
610
|
-
return null;
|
|
611
|
-
},
|
|
612
|
-
updateFastenedConstraints: async (...constraints) => {
|
|
613
|
-
var e_3, _a;
|
|
614
|
-
const constrToAdd = [];
|
|
615
|
-
try {
|
|
616
|
-
for (var constraints_1 = __asyncValues(constraints), constraints_1_1; constraints_1_1 = await constraints_1.next(), !constraints_1_1.done;) {
|
|
617
|
-
const constr = constraints_1_1.value;
|
|
618
|
-
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
619
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
620
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
621
|
-
const xOffsetParam = { value: constr.xOffset, isExpr: typeof constr.xOffset === 'string' };
|
|
622
|
-
const yOffsetParam = { value: constr.yOffset, isExpr: typeof constr.yOffset === 'string' };
|
|
623
|
-
const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
|
|
624
|
-
const xRotationParam = {
|
|
625
|
-
value: constr.xRotation || 0,
|
|
626
|
-
isExpr: typeof constr.xRotation === 'string',
|
|
627
|
-
};
|
|
628
|
-
const yRotationParam = {
|
|
629
|
-
value: constr.yRotation || 0,
|
|
630
|
-
isExpr: typeof constr.yRotation === 'string',
|
|
631
|
-
};
|
|
632
|
-
const zRotationParam = {
|
|
633
|
-
value: constr.zRotation || 0,
|
|
634
|
-
isExpr: typeof constr.zRotation === 'string',
|
|
635
|
-
};
|
|
636
|
-
constrToAdd.push({
|
|
637
|
-
constrId: rConstrId,
|
|
638
|
-
mate1: {
|
|
639
|
-
matePath: rMatePath1,
|
|
640
|
-
wcsId: rWcs1,
|
|
641
|
-
flip: constr.mate1.flip,
|
|
642
|
-
reoriented: constr.mate1.reoriented,
|
|
643
|
-
},
|
|
644
|
-
mate2: {
|
|
645
|
-
matePath: rMatePath2,
|
|
646
|
-
wcsId: rWcs2,
|
|
647
|
-
flip: constr.mate2.flip,
|
|
648
|
-
reoriented: constr.mate2.reoriented,
|
|
649
|
-
},
|
|
650
|
-
xOffset: xOffsetParam,
|
|
651
|
-
yOffset: yOffsetParam,
|
|
652
|
-
zOffset: zOffsetParam,
|
|
653
|
-
xRotation: xRotationParam,
|
|
654
|
-
yRotation: yRotationParam,
|
|
655
|
-
zRotation: zRotationParam,
|
|
656
|
-
});
|
|
657
|
-
}
|
|
658
|
-
}
|
|
659
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
660
|
-
finally {
|
|
661
|
-
try {
|
|
662
|
-
if (constraints_1_1 && !constraints_1_1.done && (_a = constraints_1.return)) await _a.call(constraints_1);
|
|
663
|
-
}
|
|
664
|
-
finally { if (e_3) throw e_3.error; }
|
|
665
|
-
}
|
|
666
|
-
await assemblyBuilderAPI.updateFastenedConstraints(constrToAdd);
|
|
667
|
-
},
|
|
668
|
-
createFastenedOriginConstraint: async (id, mate1, xOffset, yOffset, zOffset, name, xRotation, yRotation, zRotation) => {
|
|
669
|
-
const [rId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId));
|
|
670
|
-
const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
671
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCFastenedOriginConstraint, name);
|
|
672
|
-
if (constraintId != null) {
|
|
673
|
-
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
674
|
-
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
675
|
-
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
676
|
-
const xRotationParam = { value: xRotation || 0, isExpr: typeof xRotation === 'string' };
|
|
677
|
-
const yRotationParam = { value: yRotation || 0, isExpr: typeof yRotation === 'string' };
|
|
678
|
-
const zRotationParam = { value: zRotation || 0, isExpr: typeof zRotation === 'string' };
|
|
679
|
-
await assemblyBuilderAPI.updateFastenedOriginConstraints([
|
|
680
|
-
{
|
|
681
|
-
constrId: constraintId,
|
|
682
|
-
mate1: { matePath: rMatePath, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented },
|
|
683
|
-
xOffset: xOffsetParam,
|
|
684
|
-
yOffset: yOffsetParam,
|
|
685
|
-
zOffset: zOffsetParam,
|
|
686
|
-
xRotation: xRotationParam,
|
|
687
|
-
yRotation: yRotationParam,
|
|
688
|
-
zRotation: zRotationParam,
|
|
689
|
-
},
|
|
690
|
-
]);
|
|
691
|
-
return constraintId;
|
|
692
|
-
}
|
|
693
|
-
return null;
|
|
694
|
-
},
|
|
695
|
-
updateFastenedOriginConstraints: async (...constraints) => {
|
|
696
|
-
var e_4, _a;
|
|
697
|
-
const constraintsToAdd = [];
|
|
698
|
-
try {
|
|
699
|
-
for (var constraints_2 = __asyncValues(constraints), constraints_2_1; constraints_2_1 = await constraints_2.next(), !constraints_2_1.done;) {
|
|
700
|
-
const constr = constraints_2_1.value;
|
|
701
|
-
const [rConstrId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId));
|
|
702
|
-
const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
703
|
-
const xOffsetParam = { value: constr.xOffset, isExpr: typeof constr.xOffset === 'string' };
|
|
704
|
-
const yOffsetParam = { value: constr.yOffset, isExpr: typeof constr.yOffset === 'string' };
|
|
705
|
-
const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
|
|
706
|
-
const xRotationParam = {
|
|
707
|
-
value: constr.xRotation || 0,
|
|
708
|
-
isExpr: typeof constr.xRotation === 'string',
|
|
709
|
-
};
|
|
710
|
-
const yRotationParam = {
|
|
711
|
-
value: constr.yRotation || 0,
|
|
712
|
-
isExpr: typeof constr.yRotation === 'string',
|
|
713
|
-
};
|
|
714
|
-
const zRotationParam = {
|
|
715
|
-
value: constr.zRotation || 0,
|
|
716
|
-
isExpr: typeof constr.zRotation === 'string',
|
|
717
|
-
};
|
|
718
|
-
constraintsToAdd.push({
|
|
719
|
-
constrId: rConstrId,
|
|
720
|
-
mate1: {
|
|
721
|
-
matePath: rMatePath,
|
|
722
|
-
wcsId: rWcs1,
|
|
723
|
-
flip: constr.mate1.flip,
|
|
724
|
-
reoriented: constr.mate1.reoriented,
|
|
725
|
-
},
|
|
726
|
-
xOffset: xOffsetParam,
|
|
727
|
-
yOffset: yOffsetParam,
|
|
728
|
-
zOffset: zOffsetParam,
|
|
729
|
-
xRotation: xRotationParam,
|
|
730
|
-
yRotation: yRotationParam,
|
|
731
|
-
zRotation: zRotationParam,
|
|
732
|
-
});
|
|
733
|
-
}
|
|
734
|
-
}
|
|
735
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
736
|
-
finally {
|
|
737
|
-
try {
|
|
738
|
-
if (constraints_2_1 && !constraints_2_1.done && (_a = constraints_2.return)) await _a.call(constraints_2);
|
|
739
|
-
}
|
|
740
|
-
finally { if (e_4) throw e_4.error; }
|
|
741
|
-
}
|
|
742
|
-
await assemblyBuilderAPI.updateFastenedOriginConstraints(constraintsToAdd);
|
|
743
|
-
},
|
|
744
|
-
createCylindricalConstraint: async (id, mate1, mate2, zOffsetLimits, zRotationLimits, name) => {
|
|
745
|
-
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
746
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
747
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
748
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCCylindricalConstraint, name);
|
|
749
|
-
if (constraintId != null) {
|
|
750
|
-
await assemblyBuilderAPI.updateCylindricalConstraints([
|
|
751
|
-
{
|
|
752
|
-
constrId: constraintId,
|
|
753
|
-
mate1: {
|
|
754
|
-
matePath: rMatePath1,
|
|
755
|
-
wcsId: rWcs1,
|
|
756
|
-
flip: mate1.flip,
|
|
757
|
-
reoriented: mate1.reoriented,
|
|
758
|
-
},
|
|
759
|
-
mate2: {
|
|
760
|
-
matePath: rMatePath2,
|
|
761
|
-
wcsId: rWcs2,
|
|
762
|
-
flip: mate2.flip,
|
|
763
|
-
reoriented: mate2.reoriented,
|
|
764
|
-
},
|
|
765
|
-
zOffsetLimits,
|
|
766
|
-
zRotationLimits,
|
|
767
|
-
},
|
|
768
|
-
]);
|
|
769
|
-
return constraintId;
|
|
770
|
-
}
|
|
771
|
-
return null;
|
|
772
|
-
},
|
|
773
|
-
updateCylindricalConstraints: async (...constraints) => {
|
|
774
|
-
var e_5, _a;
|
|
775
|
-
const constrToAdd = [];
|
|
776
|
-
try {
|
|
777
|
-
for (var constraints_3 = __asyncValues(constraints), constraints_3_1; constraints_3_1 = await constraints_3.next(), !constraints_3_1.done;) {
|
|
778
|
-
const constr = constraints_3_1.value;
|
|
779
|
-
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
780
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
781
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
782
|
-
constrToAdd.push({
|
|
783
|
-
constrId: rConstrId,
|
|
784
|
-
mate1: {
|
|
785
|
-
matePath: rMatePath1,
|
|
786
|
-
wcsId: rWcs1,
|
|
787
|
-
flip: constr.mate1.flip,
|
|
788
|
-
reoriented: constr.mate1.reoriented,
|
|
789
|
-
},
|
|
790
|
-
mate2: {
|
|
791
|
-
matePath: rMatePath2,
|
|
792
|
-
wcsId: rWcs2,
|
|
793
|
-
flip: constr.mate2.flip,
|
|
794
|
-
reoriented: constr.mate2.reoriented,
|
|
795
|
-
},
|
|
796
|
-
zOffsetLimits: constr.zOffsetLimits,
|
|
797
|
-
zRotationLimits: constr.zRotationLimits,
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
}
|
|
801
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
802
|
-
finally {
|
|
803
|
-
try {
|
|
804
|
-
if (constraints_3_1 && !constraints_3_1.done && (_a = constraints_3.return)) await _a.call(constraints_3);
|
|
805
|
-
}
|
|
806
|
-
finally { if (e_5) throw e_5.error; }
|
|
807
|
-
}
|
|
808
|
-
await assemblyBuilderAPI.updateCylindricalConstraints(constrToAdd);
|
|
809
|
-
},
|
|
810
|
-
createRevoluteConstraint: async (id, mate1, mate2, zOffset, zRotationLimits, name) => {
|
|
811
|
-
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
812
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
813
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
814
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCRevoluteConstraint, name);
|
|
815
|
-
if (constraintId != null) {
|
|
816
|
-
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
817
|
-
await assemblyBuilderAPI.updateRevoluteConstraints([
|
|
818
|
-
{
|
|
819
|
-
constrId: constraintId,
|
|
820
|
-
mate1: {
|
|
821
|
-
matePath: rMatePath1,
|
|
822
|
-
wcsId: rWcs1,
|
|
823
|
-
flip: mate1.flip,
|
|
824
|
-
reoriented: mate1.reoriented,
|
|
825
|
-
},
|
|
826
|
-
mate2: {
|
|
827
|
-
matePath: rMatePath2,
|
|
828
|
-
wcsId: rWcs2,
|
|
829
|
-
flip: mate2.flip,
|
|
830
|
-
reoriented: mate2.reoriented,
|
|
831
|
-
},
|
|
832
|
-
zOffset: zOffsetParam,
|
|
833
|
-
zRotationLimits,
|
|
834
|
-
},
|
|
835
|
-
]);
|
|
836
|
-
return constraintId;
|
|
837
|
-
}
|
|
838
|
-
return null;
|
|
839
|
-
},
|
|
840
|
-
updateRevoluteConstraints: async (...constraints) => {
|
|
841
|
-
var e_6, _a;
|
|
842
|
-
const constrToAdd = [];
|
|
843
|
-
try {
|
|
844
|
-
for (var constraints_4 = __asyncValues(constraints), constraints_4_1; constraints_4_1 = await constraints_4.next(), !constraints_4_1.done;) {
|
|
845
|
-
const constr = constraints_4_1.value;
|
|
846
|
-
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
847
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
848
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
849
|
-
const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
|
|
850
|
-
constrToAdd.push({
|
|
851
|
-
constrId: rConstrId,
|
|
852
|
-
mate1: {
|
|
853
|
-
matePath: rMatePath1,
|
|
854
|
-
wcsId: rWcs1,
|
|
855
|
-
flip: constr.mate1.flip,
|
|
856
|
-
reoriented: constr.mate1.reoriented,
|
|
857
|
-
},
|
|
858
|
-
mate2: {
|
|
859
|
-
matePath: rMatePath2,
|
|
860
|
-
wcsId: rWcs2,
|
|
861
|
-
flip: constr.mate2.flip,
|
|
862
|
-
reoriented: constr.mate2.reoriented,
|
|
863
|
-
},
|
|
864
|
-
zOffset: zOffsetParam,
|
|
865
|
-
zRotationLimits: constr.zRotationLimits,
|
|
866
|
-
});
|
|
867
|
-
}
|
|
868
|
-
}
|
|
869
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
870
|
-
finally {
|
|
871
|
-
try {
|
|
872
|
-
if (constraints_4_1 && !constraints_4_1.done && (_a = constraints_4.return)) await _a.call(constraints_4);
|
|
873
|
-
}
|
|
874
|
-
finally { if (e_6) throw e_6.error; }
|
|
875
|
-
}
|
|
876
|
-
await assemblyBuilderAPI.updateRevoluteConstraints(constrToAdd);
|
|
877
|
-
},
|
|
878
|
-
createSliderConstraint: async (id, mate1, mate2, xOffset, yOffset, zOffsetLimits, name) => {
|
|
879
|
-
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
880
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
881
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
882
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCSliderConstraint, name);
|
|
883
|
-
if (constraintId != null) {
|
|
884
|
-
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
885
|
-
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
886
|
-
await assemblyBuilderAPI.updateSliderConstraints([
|
|
887
|
-
{
|
|
888
|
-
constrId: constraintId,
|
|
889
|
-
mate1: {
|
|
890
|
-
matePath: rMatePath1,
|
|
891
|
-
wcsId: rWcs1,
|
|
892
|
-
flip: mate1.flip,
|
|
893
|
-
reoriented: mate1.reoriented,
|
|
894
|
-
},
|
|
895
|
-
mate2: {
|
|
896
|
-
matePath: rMatePath2,
|
|
897
|
-
wcsId: rWcs2,
|
|
898
|
-
flip: mate2.flip,
|
|
899
|
-
reoriented: mate2.reoriented,
|
|
900
|
-
},
|
|
901
|
-
xOffset: xOffsetParam,
|
|
902
|
-
yOffset: yOffsetParam,
|
|
903
|
-
zOffsetLimits,
|
|
904
|
-
},
|
|
905
|
-
]);
|
|
906
|
-
return constraintId;
|
|
907
|
-
}
|
|
908
|
-
return null;
|
|
909
|
-
},
|
|
910
|
-
updateSliderConstraints: async (...constraints) => {
|
|
911
|
-
var e_7, _a;
|
|
912
|
-
const constrToAdd = [];
|
|
913
|
-
try {
|
|
914
|
-
for (var constraints_5 = __asyncValues(constraints), constraints_5_1; constraints_5_1 = await constraints_5.next(), !constraints_5_1.done;) {
|
|
915
|
-
const constr = constraints_5_1.value;
|
|
916
|
-
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
917
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
918
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
919
|
-
const xOffsetParam = { value: constr.xOffset, isExpr: typeof constr.xOffset === 'string' };
|
|
920
|
-
const yOffsetParam = { value: constr.yOffset, isExpr: typeof constr.yOffset === 'string' };
|
|
921
|
-
constrToAdd.push({
|
|
922
|
-
constrId: rConstrId,
|
|
923
|
-
mate1: {
|
|
924
|
-
matePath: rMatePath1,
|
|
925
|
-
wcsId: rWcs1,
|
|
926
|
-
flip: constr.mate1.flip,
|
|
927
|
-
reoriented: constr.mate1.reoriented,
|
|
928
|
-
},
|
|
929
|
-
mate2: {
|
|
930
|
-
matePath: rMatePath2,
|
|
931
|
-
wcsId: rWcs2,
|
|
932
|
-
flip: constr.mate2.flip,
|
|
933
|
-
reoriented: constr.mate2.reoriented,
|
|
934
|
-
},
|
|
935
|
-
xOffset: xOffsetParam,
|
|
936
|
-
yOffset: yOffsetParam,
|
|
937
|
-
zOffsetLimits: constr.zOffsetLimits,
|
|
938
|
-
});
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
942
|
-
finally {
|
|
943
|
-
try {
|
|
944
|
-
if (constraints_5_1 && !constraints_5_1.done && (_a = constraints_5.return)) await _a.call(constraints_5);
|
|
945
|
-
}
|
|
946
|
-
finally { if (e_7) throw e_7.error; }
|
|
947
|
-
}
|
|
948
|
-
await assemblyBuilderAPI.updateSliderConstraints(constrToAdd);
|
|
949
|
-
},
|
|
950
|
-
createPlanarConstraint: async (id, mate1, mate2, zOffset, xOffsetLimits, yOffsetLimits, zRotationLimits, name) => {
|
|
951
|
-
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
952
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
953
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
954
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCPlanarConstraint, name);
|
|
955
|
-
if (constraintId != null) {
|
|
956
|
-
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
957
|
-
await assemblyBuilderAPI.updatePlanarConstraints([
|
|
958
|
-
{
|
|
959
|
-
constrId: constraintId,
|
|
960
|
-
mate1: {
|
|
961
|
-
matePath: rMatePath1,
|
|
962
|
-
wcsId: rWcs1,
|
|
963
|
-
flip: mate1.flip,
|
|
964
|
-
reoriented: mate1.reoriented,
|
|
965
|
-
},
|
|
966
|
-
mate2: {
|
|
967
|
-
matePath: rMatePath2,
|
|
968
|
-
wcsId: rWcs2,
|
|
969
|
-
flip: mate2.flip,
|
|
970
|
-
reoriented: mate2.reoriented,
|
|
971
|
-
},
|
|
972
|
-
zOffset: zOffsetParam,
|
|
973
|
-
xOffsetLimits,
|
|
974
|
-
yOffsetLimits,
|
|
975
|
-
zRotationLimits,
|
|
976
|
-
},
|
|
977
|
-
]);
|
|
978
|
-
return constraintId;
|
|
979
|
-
}
|
|
980
|
-
return null;
|
|
981
|
-
},
|
|
982
|
-
updatePlanarConstraints: async (...constraints) => {
|
|
983
|
-
var e_8, _a;
|
|
984
|
-
const constrToAdd = [];
|
|
985
|
-
try {
|
|
986
|
-
for (var constraints_6 = __asyncValues(constraints), constraints_6_1; constraints_6_1 = await constraints_6.next(), !constraints_6_1.done;) {
|
|
987
|
-
const constr = constraints_6_1.value;
|
|
988
|
-
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
989
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
990
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
991
|
-
const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
|
|
992
|
-
constrToAdd.push({
|
|
993
|
-
constrId: rConstrId,
|
|
994
|
-
mate1: {
|
|
995
|
-
matePath: rMatePath1,
|
|
996
|
-
wcsId: rWcs1,
|
|
997
|
-
flip: constr.mate1.flip,
|
|
998
|
-
reoriented: constr.mate1.reoriented,
|
|
999
|
-
},
|
|
1000
|
-
mate2: {
|
|
1001
|
-
matePath: rMatePath2,
|
|
1002
|
-
wcsId: rWcs2,
|
|
1003
|
-
flip: constr.mate2.flip,
|
|
1004
|
-
reoriented: constr.mate2.reoriented,
|
|
1005
|
-
},
|
|
1006
|
-
zOffset: zOffsetParam,
|
|
1007
|
-
xOffsetLimits: constr.xOffsetLimits,
|
|
1008
|
-
yOffsetLimits: constr.yOffsetLimits,
|
|
1009
|
-
zRotationLimits: constr.zRotationLimits,
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
1014
|
-
finally {
|
|
1015
|
-
try {
|
|
1016
|
-
if (constraints_6_1 && !constraints_6_1.done && (_a = constraints_6.return)) await _a.call(constraints_6);
|
|
1017
|
-
}
|
|
1018
|
-
finally { if (e_8) throw e_8.error; }
|
|
1019
|
-
}
|
|
1020
|
-
await assemblyBuilderAPI.updatePlanarConstraints(constrToAdd);
|
|
1021
|
-
},
|
|
1022
|
-
createParallelConstraint: async (id, mate1, mate2, xOffsetLimits, yOffsetLimits, zOffsetLimits, zRotationLimits, name) => {
|
|
1023
|
-
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
1024
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
1025
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
1026
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCParallelConstraint, name);
|
|
1027
|
-
if (constraintId != null) {
|
|
1028
|
-
await assemblyBuilderAPI.updateParallelConstraints([
|
|
1029
|
-
{
|
|
1030
|
-
constrId: constraintId,
|
|
1031
|
-
mate1: {
|
|
1032
|
-
matePath: rMatePath1,
|
|
1033
|
-
wcsId: rWcs1,
|
|
1034
|
-
flip: mate1.flip,
|
|
1035
|
-
reoriented: mate1.reoriented,
|
|
1036
|
-
},
|
|
1037
|
-
mate2: {
|
|
1038
|
-
matePath: rMatePath2,
|
|
1039
|
-
wcsId: rWcs2,
|
|
1040
|
-
flip: mate2.flip,
|
|
1041
|
-
reoriented: mate2.reoriented,
|
|
1042
|
-
},
|
|
1043
|
-
xOffsetLimits,
|
|
1044
|
-
yOffsetLimits,
|
|
1045
|
-
zOffsetLimits,
|
|
1046
|
-
zRotationLimits,
|
|
1047
|
-
},
|
|
1048
|
-
]);
|
|
1049
|
-
return constraintId;
|
|
1050
|
-
}
|
|
1051
|
-
return null;
|
|
1052
|
-
},
|
|
1053
|
-
updateParallelConstraints: async (...constraints) => {
|
|
1054
|
-
var e_9, _a;
|
|
1055
|
-
const constrToAdd = [];
|
|
1056
|
-
try {
|
|
1057
|
-
for (var constraints_7 = __asyncValues(constraints), constraints_7_1; constraints_7_1 = await constraints_7.next(), !constraints_7_1.done;) {
|
|
1058
|
-
const constr = constraints_7_1.value;
|
|
1059
|
-
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
1060
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
1061
|
-
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
1062
|
-
constrToAdd.push({
|
|
1063
|
-
constrId: rConstrId,
|
|
1064
|
-
mate1: {
|
|
1065
|
-
matePath: rMatePath1,
|
|
1066
|
-
wcsId: rWcs1,
|
|
1067
|
-
flip: constr.mate1.flip,
|
|
1068
|
-
reoriented: constr.mate1.reoriented,
|
|
1069
|
-
},
|
|
1070
|
-
mate2: {
|
|
1071
|
-
matePath: rMatePath2,
|
|
1072
|
-
wcsId: rWcs2,
|
|
1073
|
-
flip: constr.mate2.flip,
|
|
1074
|
-
reoriented: constr.mate2.reoriented,
|
|
1075
|
-
},
|
|
1076
|
-
xOffsetLimits: constr.xOffsetLimits,
|
|
1077
|
-
yOffsetLimits: constr.yOffsetLimits,
|
|
1078
|
-
zOffsetLimits: constr.zOffsetLimits,
|
|
1079
|
-
zRotationLimits: constr.zRotationLimits,
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
1084
|
-
finally {
|
|
1085
|
-
try {
|
|
1086
|
-
if (constraints_7_1 && !constraints_7_1.done && (_a = constraints_7.return)) await _a.call(constraints_7);
|
|
1087
|
-
}
|
|
1088
|
-
finally { if (e_9) throw e_9.error; }
|
|
1089
|
-
}
|
|
1090
|
-
await assemblyBuilderAPI.updateParallelConstraints(constrToAdd);
|
|
1091
|
-
},
|
|
1092
|
-
createGroupConstraint: async (id, instanceIds, name) => {
|
|
1093
|
-
const [rId] = await new Promise(res => this.resolve(ids => res(ids), id));
|
|
1094
|
-
const rInstanceIds = await new Promise(res => this.resolve(paths => res(paths), ...instanceIds));
|
|
1095
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCGroupConstraint, name);
|
|
1096
|
-
if (constraintId != null) {
|
|
1097
|
-
await assemblyBuilderAPI.updateGroupConstraints([
|
|
1098
|
-
{
|
|
1099
|
-
constrId: constraintId,
|
|
1100
|
-
instanceIds: rInstanceIds,
|
|
1101
|
-
},
|
|
1102
|
-
]);
|
|
1103
|
-
return constraintId;
|
|
1104
|
-
}
|
|
1105
|
-
return null;
|
|
1106
|
-
},
|
|
1107
|
-
updateGroupConstraints: async (...constraints) => {
|
|
1108
|
-
var e_10, _a;
|
|
1109
|
-
const constrToAdd = [];
|
|
1110
|
-
try {
|
|
1111
|
-
for (var constraints_8 = __asyncValues(constraints), constraints_8_1; constraints_8_1 = await constraints_8.next(), !constraints_8_1.done;) {
|
|
1112
|
-
const constr = constraints_8_1.value;
|
|
1113
|
-
const [rConstrId] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId));
|
|
1114
|
-
const rInstanceIds = await new Promise(res => this.resolve(paths => res(paths), ...constr.instanceIds));
|
|
1115
|
-
constrToAdd.push({
|
|
1116
|
-
constrId: rConstrId,
|
|
1117
|
-
instanceIds: rInstanceIds,
|
|
1118
|
-
});
|
|
1119
|
-
}
|
|
1120
|
-
}
|
|
1121
|
-
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
1122
|
-
finally {
|
|
1123
|
-
try {
|
|
1124
|
-
if (constraints_8_1 && !constraints_8_1.done && (_a = constraints_8.return)) await _a.call(constraints_8);
|
|
1125
|
-
}
|
|
1126
|
-
finally { if (e_10) throw e_10.error; }
|
|
1127
|
-
}
|
|
1128
|
-
await assemblyBuilderAPI.updateGroupConstraints(constrToAdd);
|
|
1129
|
-
},
|
|
1130
|
-
createLinearPatternConstraint: async (id, instanceId, mate1, firstDirInstanceCount, firstDirDistance, name, mate2, secondDirInstanceCount, secondDirDistance) => {
|
|
1131
|
-
const [rId, rInstanceId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, instanceId, mate1.wcsId, mate2 === null || mate2 === void 0 ? void 0 : mate2.wcsId));
|
|
1132
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
1133
|
-
let rMatePath2;
|
|
1134
|
-
if (mate2) {
|
|
1135
|
-
rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
1136
|
-
}
|
|
1137
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCLinearPatternConstraint, name);
|
|
1138
|
-
if (constraintId != null) {
|
|
1139
|
-
const firstDirInstanceCountParam = {
|
|
1140
|
-
value: firstDirInstanceCount,
|
|
1141
|
-
isExpr: typeof firstDirInstanceCount === 'string',
|
|
1142
|
-
};
|
|
1143
|
-
const firstDirDistanceParam = {
|
|
1144
|
-
value: firstDirDistance,
|
|
1145
|
-
isExpr: typeof firstDirDistance === 'string',
|
|
1146
|
-
};
|
|
1147
|
-
const secondDirInstanceCountParam = secondDirInstanceCount !== undefined
|
|
1148
|
-
? {
|
|
1149
|
-
value: secondDirInstanceCount,
|
|
1150
|
-
isExpr: typeof secondDirInstanceCount === 'string',
|
|
1151
|
-
}
|
|
1152
|
-
: undefined;
|
|
1153
|
-
const secondDirDistanceParam = secondDirDistance !== undefined
|
|
1154
|
-
? {
|
|
1155
|
-
value: secondDirDistance,
|
|
1156
|
-
isExpr: typeof secondDirDistance === 'string',
|
|
1157
|
-
}
|
|
1158
|
-
: undefined;
|
|
1159
|
-
await assemblyBuilderAPI.updateLinearPatternConstraints([
|
|
1160
|
-
{
|
|
1161
|
-
constrId: constraintId,
|
|
1162
|
-
instanceId: rInstanceId,
|
|
1163
|
-
mate1: {
|
|
1164
|
-
matePath: rMatePath1,
|
|
1165
|
-
wcsId: rWcs1,
|
|
1166
|
-
flip: mate1.flip,
|
|
1167
|
-
reoriented: mate1.reoriented,
|
|
1168
|
-
},
|
|
1169
|
-
firstDirInstanceCount: firstDirInstanceCountParam,
|
|
1170
|
-
firstDirDistance: firstDirDistanceParam,
|
|
1171
|
-
mate2: mate2
|
|
1172
|
-
? {
|
|
1173
|
-
matePath: rMatePath2,
|
|
1174
|
-
wcsId: rWcs2,
|
|
1175
|
-
flip: mate2.flip,
|
|
1176
|
-
reoriented: mate2.reoriented,
|
|
1177
|
-
}
|
|
1178
|
-
: undefined,
|
|
1179
|
-
secondDirInstanceCount: secondDirInstanceCountParam,
|
|
1180
|
-
secondDirDistance: secondDirDistanceParam,
|
|
1181
|
-
},
|
|
1182
|
-
]);
|
|
1183
|
-
return constraintId;
|
|
1184
|
-
}
|
|
1185
|
-
return null;
|
|
1186
|
-
},
|
|
1187
|
-
updateLinearPatternConstraints: async (...constraints) => {
|
|
1188
|
-
var e_11, _a;
|
|
1189
|
-
const constrToAdd = [];
|
|
1190
|
-
try {
|
|
1191
|
-
for (var constraints_9 = __asyncValues(constraints), constraints_9_1; constraints_9_1 = await constraints_9.next(), !constraints_9_1.done;) {
|
|
1192
|
-
const constr = constraints_9_1.value;
|
|
1193
|
-
const [rConstrId, rInstanceId, rWcs1, rWcs2] = await new Promise(res => {
|
|
1194
|
-
var _a;
|
|
1195
|
-
return this.resolve(ids => res(ids), constr.constrId, constr.instanceId, constr.mate1.wcsId, (_a = constr.mate2) === null || _a === void 0 ? void 0 : _a.wcsId);
|
|
1196
|
-
});
|
|
1197
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
1198
|
-
let rMatePath2;
|
|
1199
|
-
if (constr.mate2) {
|
|
1200
|
-
rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
1201
|
-
}
|
|
1202
|
-
const firstDirInstanceCountParam = {
|
|
1203
|
-
value: constr.firstDirInstanceCount,
|
|
1204
|
-
isExpr: typeof constr.firstDirInstanceCount === 'string',
|
|
1205
|
-
};
|
|
1206
|
-
const firstDirDistanceParam = {
|
|
1207
|
-
value: constr.firstDirDistance,
|
|
1208
|
-
isExpr: typeof constr.firstDirDistance === 'string',
|
|
1209
|
-
};
|
|
1210
|
-
const secondDirInstanceCountParam = constr.secondDirInstanceCount !== undefined
|
|
1211
|
-
? {
|
|
1212
|
-
value: constr.secondDirInstanceCount,
|
|
1213
|
-
isExpr: typeof constr.secondDirInstanceCount === 'string',
|
|
1214
|
-
}
|
|
1215
|
-
: undefined;
|
|
1216
|
-
const secondDirDistanceParam = constr.secondDirDistance !== undefined
|
|
1217
|
-
? {
|
|
1218
|
-
value: constr.secondDirDistance,
|
|
1219
|
-
isExpr: typeof constr.secondDirDistance === 'string',
|
|
1220
|
-
}
|
|
1221
|
-
: undefined;
|
|
1222
|
-
constrToAdd.push({
|
|
1223
|
-
constrId: rConstrId,
|
|
1224
|
-
instanceId: rInstanceId,
|
|
1225
|
-
mate1: {
|
|
1226
|
-
matePath: rMatePath1,
|
|
1227
|
-
wcsId: rWcs1,
|
|
1228
|
-
flip: constr.mate1.flip,
|
|
1229
|
-
reoriented: constr.mate1.reoriented,
|
|
1230
|
-
},
|
|
1231
|
-
firstDirInstanceCount: firstDirInstanceCountParam,
|
|
1232
|
-
firstDirDistance: firstDirDistanceParam,
|
|
1233
|
-
mate2: constr.mate2
|
|
1234
|
-
? {
|
|
1235
|
-
matePath: rMatePath2,
|
|
1236
|
-
wcsId: rWcs2,
|
|
1237
|
-
flip: constr.mate2.flip,
|
|
1238
|
-
reoriented: constr.mate2.reoriented,
|
|
1239
|
-
}
|
|
1240
|
-
: undefined,
|
|
1241
|
-
secondDirInstanceCount: secondDirInstanceCountParam,
|
|
1242
|
-
secondDirDistance: secondDirDistanceParam,
|
|
1243
|
-
});
|
|
1244
|
-
}
|
|
1245
|
-
}
|
|
1246
|
-
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
1247
|
-
finally {
|
|
1248
|
-
try {
|
|
1249
|
-
if (constraints_9_1 && !constraints_9_1.done && (_a = constraints_9.return)) await _a.call(constraints_9);
|
|
1250
|
-
}
|
|
1251
|
-
finally { if (e_11) throw e_11.error; }
|
|
1252
|
-
}
|
|
1253
|
-
await assemblyBuilderAPI.updateLinearPatternConstraints(constrToAdd);
|
|
1254
|
-
},
|
|
1255
|
-
createCircularPatternConstraint: async (id, instanceId, mate1, instanceCount, angle, offset, name) => {
|
|
1256
|
-
const [rId, rInstanceId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), id, instanceId, mate1.wcsId));
|
|
1257
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
1258
|
-
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCCircularPatternConstraint, name);
|
|
1259
|
-
if (constraintId != null) {
|
|
1260
|
-
const instanceCountParam = {
|
|
1261
|
-
value: instanceCount,
|
|
1262
|
-
isExpr: typeof instanceCount === 'string',
|
|
1263
|
-
};
|
|
1264
|
-
const angleParam = { value: angle, isExpr: typeof angle === 'string' };
|
|
1265
|
-
const offsetParam = { value: offset, isExpr: typeof offset === 'string' };
|
|
1266
|
-
await assemblyBuilderAPI.updateCircularPatternConstraints([
|
|
1267
|
-
{
|
|
1268
|
-
constrId: constraintId,
|
|
1269
|
-
instanceId: rInstanceId,
|
|
1270
|
-
mate1: {
|
|
1271
|
-
matePath: rMatePath1,
|
|
1272
|
-
wcsId: rWcs1,
|
|
1273
|
-
flip: mate1.flip,
|
|
1274
|
-
reoriented: mate1.reoriented,
|
|
1275
|
-
},
|
|
1276
|
-
instanceCount: instanceCountParam,
|
|
1277
|
-
angle: angleParam,
|
|
1278
|
-
offset: offsetParam,
|
|
1279
|
-
},
|
|
1280
|
-
]);
|
|
1281
|
-
return constraintId;
|
|
1282
|
-
}
|
|
1283
|
-
return null;
|
|
1284
|
-
},
|
|
1285
|
-
updateCircularPatternConstraints: async (...constraints) => {
|
|
1286
|
-
var e_12, _a;
|
|
1287
|
-
const constrToAdd = [];
|
|
1288
|
-
try {
|
|
1289
|
-
for (var constraints_10 = __asyncValues(constraints), constraints_10_1; constraints_10_1 = await constraints_10.next(), !constraints_10_1.done;) {
|
|
1290
|
-
const constr = constraints_10_1.value;
|
|
1291
|
-
const [rConstrId, rInstanceId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.instanceId, constr.mate1.wcsId));
|
|
1292
|
-
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
1293
|
-
const instanceCountParam = {
|
|
1294
|
-
value: constr.instanceCount,
|
|
1295
|
-
isExpr: typeof constr.instanceCount === 'string',
|
|
1296
|
-
};
|
|
1297
|
-
const angleParam = { value: constr.angle, isExpr: typeof constr.angle === 'string' };
|
|
1298
|
-
const offsetParam = { value: constr.offset, isExpr: typeof constr.offset === 'string' };
|
|
1299
|
-
constrToAdd.push({
|
|
1300
|
-
constrId: rConstrId,
|
|
1301
|
-
instanceId: rInstanceId,
|
|
1302
|
-
mate1: {
|
|
1303
|
-
matePath: rMatePath1,
|
|
1304
|
-
wcsId: rWcs1,
|
|
1305
|
-
flip: constr.mate1.flip,
|
|
1306
|
-
reoriented: constr.mate1.reoriented,
|
|
1307
|
-
},
|
|
1308
|
-
instanceCount: instanceCountParam,
|
|
1309
|
-
angle: angleParam,
|
|
1310
|
-
offset: offsetParam,
|
|
1311
|
-
});
|
|
1312
|
-
}
|
|
1313
|
-
}
|
|
1314
|
-
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
1315
|
-
finally {
|
|
1316
|
-
try {
|
|
1317
|
-
if (constraints_10_1 && !constraints_10_1.done && (_a = constraints_10.return)) await _a.call(constraints_10);
|
|
1318
|
-
}
|
|
1319
|
-
finally { if (e_12) throw e_12.error; }
|
|
1320
|
-
}
|
|
1321
|
-
await assemblyBuilderAPI.updateCircularPatternConstraints(constrToAdd);
|
|
1322
|
-
},
|
|
1323
|
-
update3dConstraintValues: async (...constrValues) => {
|
|
1324
|
-
var e_13, _a;
|
|
1325
|
-
const constrValueParams = [];
|
|
1326
|
-
try {
|
|
1327
|
-
for (var constrValues_1 = __asyncValues(constrValues), constrValues_1_1; constrValues_1_1 = await constrValues_1.next(), !constrValues_1_1.done;) {
|
|
1328
|
-
const constrVal = constrValues_1_1.value;
|
|
1329
|
-
const [rConstrId] = await new Promise(res => this.resolve(ids => res(ids), constrVal.constrId));
|
|
1330
|
-
constrValueParams.push({
|
|
1331
|
-
constrId: rConstrId,
|
|
1332
|
-
paramName: constrVal.paramName,
|
|
1333
|
-
value: constrVal.value,
|
|
1334
|
-
});
|
|
1335
|
-
}
|
|
1336
|
-
}
|
|
1337
|
-
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
1338
|
-
finally {
|
|
1339
|
-
try {
|
|
1340
|
-
if (constrValues_1_1 && !constrValues_1_1.done && (_a = constrValues_1.return)) await _a.call(constrValues_1);
|
|
1341
|
-
}
|
|
1342
|
-
finally { if (e_13) throw e_13.error; }
|
|
1343
|
-
}
|
|
1344
|
-
await assemblyBuilderAPI.update3DConstraintValues(constrValueParams);
|
|
1345
|
-
},
|
|
1346
|
-
createBufferGeometry: async (objectId) => {
|
|
1347
|
-
await this.queue;
|
|
1348
|
-
this.queue = Promise.resolve(0);
|
|
1349
|
-
const rObjectId = await objectId;
|
|
1350
|
-
const cDrawing = getDrawing(drawingId);
|
|
1351
|
-
const structureTree = cDrawing.structure.tree;
|
|
1352
|
-
const bufferGeomArray = [];
|
|
1353
|
-
if (rObjectId != null) {
|
|
1354
|
-
const rootObj = structureTree[rObjectId];
|
|
1355
|
-
await createRecursiveBufferGeometry(rootObj, drawingId, bufferGeomArray);
|
|
1356
|
-
if (bufferGeomArray.length > 0) {
|
|
1357
|
-
return bufferGeomArray;
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
return undefined;
|
|
1361
|
-
},
|
|
1362
|
-
createScene: async (objectId, options) => {
|
|
1363
|
-
await this.queue;
|
|
1364
|
-
this.queue = Promise.resolve(0);
|
|
1365
|
-
const cDrawing = getDrawing(drawingId);
|
|
1366
|
-
const structureTree = cDrawing.structure.tree;
|
|
1367
|
-
const rObjectId = objectId ? await objectId : cDrawing.structure.root;
|
|
1368
|
-
const scene = new Scene();
|
|
1369
|
-
const result = {
|
|
1370
|
-
nodes: {},
|
|
1371
|
-
materials: {},
|
|
1372
|
-
};
|
|
1373
|
-
if (rObjectId != null) {
|
|
1374
|
-
const rootObj = structureTree[rObjectId];
|
|
1375
|
-
if (rootObj) {
|
|
1376
|
-
await createRecursiveScene(rootObj, drawingId, scene, result, options);
|
|
1377
|
-
}
|
|
1378
|
-
else {
|
|
1379
|
-
throw new Error('Root object does not exist!');
|
|
1380
|
-
}
|
|
1381
|
-
}
|
|
1382
|
-
return Object.assign({ scene }, result);
|
|
1383
|
-
},
|
|
1384
|
-
createExpressions: (partId, ...members) => {
|
|
1385
|
-
return this.resolve(async ([rPartId]) => {
|
|
1386
|
-
const membersToAdd = [];
|
|
1387
|
-
members.forEach(mem => {
|
|
1388
|
-
const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen STrings
|
|
1389
|
-
const dataType = DataType.REAL; // TODO: Aktuell nur Real Werte als Expression
|
|
1390
|
-
const featureAPIParam = {
|
|
1391
|
-
value: mem.value,
|
|
1392
|
-
isExpr: isExpr,
|
|
1393
|
-
};
|
|
1394
|
-
membersToAdd.push({ name: mem.name, value: featureAPIParam, dataType });
|
|
1395
|
-
});
|
|
1396
|
-
const success = featureAPI.updateExpressions([
|
|
1397
|
-
{ productId: rPartId, toAddMembers: membersToAdd, toModifyMembers: [], toDeleteList: [] },
|
|
1398
|
-
]);
|
|
1399
|
-
return success;
|
|
1400
|
-
}, partId);
|
|
1401
|
-
},
|
|
1402
|
-
createAssemblyAsTemplate: (name) => {
|
|
1403
|
-
return this.resolve(async ([]) => {
|
|
1404
|
-
return await assemblyBuilderAPI.createAssemblyAsTemplate(name);
|
|
1405
|
-
});
|
|
1406
|
-
},
|
|
1407
|
-
createRootAssembly: (name, options) => {
|
|
1408
|
-
return this.resolve(async ([]) => {
|
|
1409
|
-
return await assemblyBuilderAPI.createRootAssembly(name, options);
|
|
1410
|
-
});
|
|
1411
|
-
},
|
|
1412
|
-
createPart: (name) => {
|
|
1413
|
-
return this.resolve(async ([]) => {
|
|
1414
|
-
const partName = name ? name : 'Part';
|
|
1415
|
-
return await featureAPI.newPart(partName);
|
|
1416
|
-
});
|
|
1417
|
-
},
|
|
1418
|
-
createPartAsTemplate: (name) => {
|
|
1419
|
-
return this.resolve(async ([]) => {
|
|
1420
|
-
const partName = name ? name : 'Part';
|
|
1421
|
-
return await assemblyBuilderAPI.createPartAsTemplate(partName);
|
|
1422
|
-
});
|
|
1423
|
-
},
|
|
1424
|
-
createWorkAxis: (partId, type, references, position, direction, local, name) => {
|
|
1425
|
-
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1426
|
-
const wAName = name ? name : 'WorkAxis';
|
|
1427
|
-
const wAId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkAxis, wAName);
|
|
1428
|
-
if (wAId != null) {
|
|
1429
|
-
const resPosition = resolveVec(position);
|
|
1430
|
-
const positionParam = {
|
|
1431
|
-
value: resPosition,
|
|
1432
|
-
isExpr: typeof resPosition === 'string',
|
|
1433
|
-
};
|
|
1434
|
-
const resDirection = resolveVec(direction);
|
|
1435
|
-
const directionParam = {
|
|
1436
|
-
value: resDirection,
|
|
1437
|
-
isExpr: typeof resDirection === 'string',
|
|
1438
|
-
};
|
|
1439
|
-
await featureAPI.updateWorkAxis(wAId, type, rReferences, positionParam, directionParam, local);
|
|
1440
|
-
return wAId;
|
|
1441
|
-
}
|
|
1442
|
-
return null;
|
|
1443
|
-
}, partId, ...references);
|
|
1444
|
-
},
|
|
1445
|
-
createWorkCoordSystem: (partId, type, references, offset, rotation, inverted = false, name) => {
|
|
1446
|
-
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1447
|
-
const wCSName = name ? name : 'WorkCoordSystem';
|
|
1448
|
-
const wCSId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkCSys, wCSName);
|
|
1449
|
-
if (wCSId != null) {
|
|
1450
|
-
const resOffset = resolveVec(offset);
|
|
1451
|
-
const offsetParam = {
|
|
1452
|
-
value: resOffset,
|
|
1453
|
-
isExpr: typeof resOffset === 'string',
|
|
1454
|
-
};
|
|
1455
|
-
const resRotation = resolveVec(rotation);
|
|
1456
|
-
const rotationParam = {
|
|
1457
|
-
value: resRotation,
|
|
1458
|
-
isExpr: typeof resRotation === 'string',
|
|
1459
|
-
};
|
|
1460
|
-
await featureAPI.updateWorkCSys(wCSId, type, rReferences, offsetParam, rotationParam, inverted ? 1 : 0);
|
|
1461
|
-
return wCSId;
|
|
1462
|
-
}
|
|
1463
|
-
return null;
|
|
1464
|
-
}, partId, ...references);
|
|
1465
|
-
},
|
|
1466
|
-
createWorkPlane: (partId, type, references, offset, angle, position, normal, local, name) => {
|
|
1467
|
-
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1468
|
-
const wPName = name ? name : 'WorkPlane';
|
|
1469
|
-
const wPId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkPlane, wPName);
|
|
1470
|
-
if (wPId != undefined) {
|
|
1471
|
-
const offsetParam = { value: offset, isExpr: typeof offset === 'string' };
|
|
1472
|
-
const angleParam = { value: angle, isExpr: typeof angle === 'string' };
|
|
1473
|
-
const resPosition = resolveVec(position);
|
|
1474
|
-
const positionParam = {
|
|
1475
|
-
value: resPosition,
|
|
1476
|
-
isExpr: typeof resPosition === 'string',
|
|
1477
|
-
};
|
|
1478
|
-
const resNormal = resolveVec(normal);
|
|
1479
|
-
const normalParam = {
|
|
1480
|
-
value: resNormal,
|
|
1481
|
-
isExpr: typeof resNormal === 'string',
|
|
1482
|
-
};
|
|
1483
|
-
await featureAPI.updateWorkPlane(wPId, type, rReferences, offsetParam, angleParam, positionParam, normalParam, local);
|
|
1484
|
-
return wPId;
|
|
1485
|
-
}
|
|
1486
|
-
return null;
|
|
1487
|
-
}, partId, ...references);
|
|
1488
|
-
},
|
|
1489
|
-
createWorkPoint: (partId, type, references, position, local, name) => {
|
|
1490
|
-
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1491
|
-
const wPTName = name ? name : 'WorkPoint';
|
|
1492
|
-
const wPTId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkPoint, wPTName);
|
|
1493
|
-
if (wPTId != undefined) {
|
|
1494
|
-
const resPosition = resolveVec(position);
|
|
1495
|
-
const positionParam = {
|
|
1496
|
-
value: resPosition,
|
|
1497
|
-
isExpr: typeof resPosition === 'string',
|
|
1498
|
-
};
|
|
1499
|
-
await featureAPI.updateWorkPoint(wPTId, type, rReferences, positionParam, local);
|
|
1500
|
-
return wPTId;
|
|
1501
|
-
}
|
|
1502
|
-
return null;
|
|
1503
|
-
}, partId, ...references);
|
|
1504
|
-
},
|
|
1505
|
-
fillet: (partId, references, radius) => {
|
|
1506
|
-
return this.resolve(async ([rPartId, rReferences]) => {
|
|
1507
|
-
const radiusParam = { value: radius, isExpr: typeof radius === 'string' };
|
|
1508
|
-
const filletId = await featureAPI.createFeature(rPartId, CCClasses.CCConstantRadiusFillet, 'Fillet');
|
|
1509
|
-
if (filletId != null) {
|
|
1510
|
-
await featureAPI.updateFillet(filletId, rReferences, radiusParam);
|
|
1511
|
-
return filletId;
|
|
1512
|
-
}
|
|
1513
|
-
return null;
|
|
1514
|
-
}, partId, references);
|
|
1515
|
-
},
|
|
1516
|
-
selectGeometry: (types, count) => {
|
|
1517
|
-
const drId = this.drawingId;
|
|
1518
|
-
return this.resolve(async ([]) => {
|
|
1519
|
-
const filter = (scope, data) => scope === BuerliScope && types.some(type => type === data);
|
|
1520
|
-
// Check count param. If not set use by default 1, else check if not < 1
|
|
1521
|
-
const lCount = count ? (count < 1 ? 1 : count) : 1;
|
|
1522
|
-
const selections = (await waitForSelect(lCount, filter, (resolveSelection, items, diff) => {
|
|
1523
|
-
if (items.length > lCount - 1) {
|
|
1524
|
-
resolveSelection(items);
|
|
1525
|
-
}
|
|
1526
|
-
}));
|
|
1527
|
-
const interactionInfos = [];
|
|
1528
|
-
for (const selection of selections) {
|
|
1529
|
-
// Get matching points from selected geometry and add to userData. TODO: Only if in part mode useful?
|
|
1530
|
-
const points = await geometryAPI.getPointsByGeometries([selection.data.graphicId]);
|
|
1531
|
-
const matrix = getDrawing(drId).api.structure.calculateGlobalTransformation(selection.data.productId);
|
|
1532
|
-
const clone = selection.data.geometry.clone().applyMatrix4(matrix);
|
|
1533
|
-
// TODO: Should the transform code be moved to something else than Measure? It's helpful for more cases than just measuring.
|
|
1534
|
-
const transformedData = Measure.transform([selection.data], drId)[0];
|
|
1535
|
-
const interactionInfo = createInfo({
|
|
1536
|
-
objectId: selection.data.container.ownerId,
|
|
1537
|
-
prodRefId: selection.data.productId,
|
|
1538
|
-
containerId: selection.data.container.id,
|
|
1539
|
-
graphicId: selection.data.graphicId,
|
|
1540
|
-
// objectPath: ?, TODO: Add path to the root in expanded tree, as soon as available
|
|
1541
|
-
userData: Object.assign(Object.assign({}, transformedData), { geometry: clone, matchingPoints: points }),
|
|
1542
|
-
});
|
|
1543
|
-
interactionInfos.push(interactionInfo);
|
|
1544
|
-
}
|
|
1545
|
-
return interactionInfos;
|
|
1546
|
-
});
|
|
1547
|
-
},
|
|
1548
|
-
findGeometry: (partId, type, positions) => {
|
|
1549
|
-
return this.resolve(async ([rPartId]) => {
|
|
1550
|
-
const geoms = await geometryAPI.findGeometriesByPoints(rPartId, type, positions.map(pos => pos.map(p => resolveVec(p))));
|
|
1551
|
-
return geoms;
|
|
1552
|
-
}, partId);
|
|
1553
|
-
},
|
|
1554
|
-
getAssemblyTemplate: (asmName) => {
|
|
1555
|
-
return this.resolve(async ([]) => {
|
|
1556
|
-
const asmIds = asmUtils.getAssemblyTemplate(drawingId, asmName);
|
|
1557
|
-
if (asmIds != undefined) {
|
|
1558
|
-
return Array.isArray(asmIds) ? asmIds : [asmIds];
|
|
1559
|
-
}
|
|
1560
|
-
return null;
|
|
1561
|
-
});
|
|
1562
|
-
},
|
|
1563
|
-
getInstance: (id, instanceName) => {
|
|
1564
|
-
return this.resolve(async ([rId]) => {
|
|
1565
|
-
const instances = asmUtils.getInstance(drawingId, rId, instanceName);
|
|
1566
|
-
if (instances != undefined) {
|
|
1567
|
-
return Array.isArray(instances) ? instances : [instances];
|
|
1568
|
-
}
|
|
1569
|
-
return null;
|
|
1570
|
-
}, id);
|
|
1571
|
-
},
|
|
1572
|
-
findInstance: (options) => {
|
|
1573
|
-
return this.resolve(async () => {
|
|
1574
|
-
const instance = baseUtils.findObject(drawingId, {
|
|
1575
|
-
ident: options.instanceIdent,
|
|
1576
|
-
name: options.instanceName,
|
|
1577
|
-
});
|
|
1578
|
-
if (!instance) {
|
|
1579
|
-
return null;
|
|
1580
|
-
}
|
|
1581
|
-
const clazz = getDrawing(drawingId).structure.tree[instance].class;
|
|
1582
|
-
if (!baseUtils.isA(clazz, CCClasses.IProductReference)) {
|
|
1583
|
-
return null;
|
|
1584
|
-
}
|
|
1585
|
-
else {
|
|
1586
|
-
return instance;
|
|
1587
|
-
}
|
|
1588
|
-
});
|
|
1589
|
-
},
|
|
1590
|
-
getProductsOfInstances: (instanceIds) => {
|
|
1591
|
-
return this.resolve(async ([rInstanceIds]) => {
|
|
1592
|
-
const drawing = getDrawing(drawingId);
|
|
1593
|
-
const tree = drawing.structure.tree;
|
|
1594
|
-
const products = [];
|
|
1595
|
-
for (const rInstanceId of rInstanceIds) {
|
|
1596
|
-
const product = asmUtils.findProduct(rInstanceId, tree);
|
|
1597
|
-
products.push(product);
|
|
1598
|
-
}
|
|
1599
|
-
return products;
|
|
1600
|
-
}, instanceIds);
|
|
1601
|
-
},
|
|
1602
|
-
setCurrentInstance: (id) => {
|
|
1603
|
-
return this.resolve(async ([rId]) => {
|
|
1604
|
-
await assemblyBuilderAPI.setCurrentInstance(rId);
|
|
1605
|
-
}, id);
|
|
1606
|
-
},
|
|
1607
|
-
getCurrentInstance: () => {
|
|
1608
|
-
return this.resolve(async () => {
|
|
1609
|
-
const drw = getDrawing(drawingId);
|
|
1610
|
-
return drw.structure.currentInstance;
|
|
1611
|
-
});
|
|
1612
|
-
},
|
|
1613
|
-
getTransformation: (id) => {
|
|
1614
|
-
return this.resolve(async ([rId]) => {
|
|
1615
|
-
const coordSys = asmUtils.getTransformation(drawingId, rId);
|
|
1616
|
-
if (coordSys != undefined) {
|
|
1617
|
-
return coordSys;
|
|
1618
|
-
}
|
|
1619
|
-
return null;
|
|
1620
|
-
}, id);
|
|
1621
|
-
},
|
|
1622
|
-
setCurrentProduct: (productId) => {
|
|
1623
|
-
return this.resolve(async ([rProductId]) => {
|
|
1624
|
-
await baseModelerAPI.setCurrentProduct(rProductId);
|
|
1625
|
-
}, productId);
|
|
1626
|
-
},
|
|
1627
|
-
getCurrentProduct: () => {
|
|
1628
|
-
return this.resolve(async () => {
|
|
1629
|
-
const drw = getDrawing(drawingId);
|
|
1630
|
-
return drw.structure.currentProduct;
|
|
1631
|
-
});
|
|
1632
|
-
},
|
|
1633
|
-
getPartTemplate: (partName) => {
|
|
1634
|
-
return this.resolve(async ([]) => {
|
|
1635
|
-
const partIds = asmUtils.getPartTemplate(drawingId, partName);
|
|
1636
|
-
if (partIds != undefined) {
|
|
1637
|
-
return Array.isArray(partIds) ? partIds : [partIds];
|
|
1638
|
-
}
|
|
1639
|
-
return null;
|
|
1640
|
-
});
|
|
1641
|
-
},
|
|
1642
|
-
getWorkCoordSystem: (id, wcsName) => {
|
|
1643
|
-
return this.resolve(async ([rId]) => {
|
|
1644
|
-
console.warn('Warning: getWorkCoordSystem() is deprecated, use getWorkGeometry() instead, getWorkCoordSystem() will be removed in a future release.');
|
|
1645
|
-
const wcsIds = asmUtils.getWorkCoordSystem(drawingId, rId, wcsName);
|
|
1646
|
-
if (wcsIds != undefined) {
|
|
1647
|
-
return Array.isArray(wcsIds) ? wcsIds : [wcsIds];
|
|
1648
|
-
}
|
|
1649
|
-
return null;
|
|
1650
|
-
}, id);
|
|
1651
|
-
},
|
|
1652
|
-
getSketchRegion: (id, sketchRegionName) => {
|
|
1653
|
-
return this.resolve(async ([rId]) => {
|
|
1654
|
-
const sRIds = partUtils.getSketchRegion(drawingId, rId, sketchRegionName);
|
|
1655
|
-
if (sRIds != undefined) {
|
|
1656
|
-
return Array.isArray(sRIds) ? sRIds : [sRIds];
|
|
1657
|
-
}
|
|
1658
|
-
return null;
|
|
1659
|
-
}, id);
|
|
1660
|
-
},
|
|
1661
|
-
getSketch: (id, sketchName) => {
|
|
1662
|
-
return this.resolve(async ([rId]) => {
|
|
1663
|
-
const sIds = partUtils.getSketch(drawingId, rId, sketchName);
|
|
1664
|
-
if (sIds != undefined) {
|
|
1665
|
-
return Array.isArray(sIds) ? sIds : [sIds];
|
|
1666
|
-
}
|
|
1667
|
-
return null;
|
|
1668
|
-
}, id);
|
|
1669
|
-
},
|
|
1670
|
-
getWorkGeometry: (refId, type, wgName) => {
|
|
1671
|
-
return this.resolve(async ([rRefId]) => {
|
|
1672
|
-
const wgIds = asmUtils.getWorkGeometry(drawingId, rRefId, type, wgName);
|
|
1673
|
-
if (wgIds != undefined) {
|
|
1674
|
-
return Array.isArray(wgIds) ? wgIds : [wgIds];
|
|
1675
|
-
}
|
|
1676
|
-
return null;
|
|
1677
|
-
}, refId);
|
|
1678
|
-
},
|
|
1679
|
-
getConstraint: (refId, constrName) => {
|
|
1680
|
-
return this.resolve(async ([rRefId]) => {
|
|
1681
|
-
console.warn('Warning: getConstraint() is deprecated, use specific methods e.g. getFastenedConstraint() instead, getConstraint() will be removed in a future release.');
|
|
1682
|
-
const constrIds = asmUtils.getConstraint(drawingId, rRefId, constrName);
|
|
1683
|
-
if (constrIds != undefined) {
|
|
1684
|
-
return Array.isArray(constrIds) ? constrIds : [constrIds];
|
|
1685
|
-
}
|
|
1686
|
-
return null;
|
|
1687
|
-
}, refId);
|
|
1688
|
-
},
|
|
1689
|
-
getFastenedConstraint: (id, constrName) => {
|
|
1690
|
-
return this.resolve(async ([rId]) => {
|
|
1691
|
-
const constraint = asmUtils.getFastenedConstraint(drawingId, rId, constrName);
|
|
1692
|
-
if (constraint != undefined) {
|
|
1693
|
-
return {
|
|
1694
|
-
constrId: constraint.constrId,
|
|
1695
|
-
mate1: constraint.mate1,
|
|
1696
|
-
mate2: constraint.mate2,
|
|
1697
|
-
xOffset: constraint.xOffset.value,
|
|
1698
|
-
yOffset: constraint.yOffset.value,
|
|
1699
|
-
zOffset: constraint.zOffset.value,
|
|
1700
|
-
xRotation: constraint.xRotation.value,
|
|
1701
|
-
yRotation: constraint.yRotation.value,
|
|
1702
|
-
zRotation: constraint.zRotation.value,
|
|
1703
|
-
};
|
|
1704
|
-
}
|
|
1705
|
-
return null;
|
|
1706
|
-
}, id);
|
|
1707
|
-
},
|
|
1708
|
-
getFastenedOriginConstraint: (id, constrName) => {
|
|
1709
|
-
return this.resolve(async ([rId]) => {
|
|
1710
|
-
const constraint = asmUtils.getFastenedOriginConstraint(drawingId, rId, constrName);
|
|
1711
|
-
if (constraint != undefined) {
|
|
1712
|
-
return {
|
|
1713
|
-
constrId: constraint.constrId,
|
|
1714
|
-
mate1: constraint.mate1,
|
|
1715
|
-
xOffset: constraint.xOffset.value,
|
|
1716
|
-
yOffset: constraint.yOffset.value,
|
|
1717
|
-
zOffset: constraint.zOffset.value,
|
|
1718
|
-
xRotation: constraint.xRotation.value,
|
|
1719
|
-
yRotation: constraint.yRotation.value,
|
|
1720
|
-
zRotation: constraint.zRotation.value,
|
|
1721
|
-
};
|
|
1722
|
-
}
|
|
1723
|
-
return null;
|
|
1724
|
-
}, id);
|
|
1725
|
-
},
|
|
1726
|
-
getRevoluteConstraint: (id, constrName) => {
|
|
1727
|
-
return this.resolve(async ([rId]) => {
|
|
1728
|
-
const constraint = asmUtils.getRevoluteConstraint(drawingId, rId, constrName);
|
|
1729
|
-
if (constraint != undefined) {
|
|
1730
|
-
return {
|
|
1731
|
-
constrId: constraint.constrId,
|
|
1732
|
-
mate1: constraint.mate1,
|
|
1733
|
-
mate2: constraint.mate2,
|
|
1734
|
-
zOffset: constraint.zOffset.value,
|
|
1735
|
-
zRotationLimits: constraint.zRotationLimits,
|
|
1736
|
-
};
|
|
1737
|
-
}
|
|
1738
|
-
return null;
|
|
1739
|
-
}, id);
|
|
1740
|
-
},
|
|
1741
|
-
getSliderConstraint: (id, constrName) => {
|
|
1742
|
-
return this.resolve(async ([rId]) => {
|
|
1743
|
-
const constraint = asmUtils.getSliderConstraint(drawingId, rId, constrName);
|
|
1744
|
-
if (constraint != undefined) {
|
|
1745
|
-
return {
|
|
1746
|
-
constrId: constraint.constrId,
|
|
1747
|
-
mate1: constraint.mate1,
|
|
1748
|
-
mate2: constraint.mate2,
|
|
1749
|
-
xOffset: constraint.xOffset.value,
|
|
1750
|
-
yOffset: constraint.yOffset.value,
|
|
1751
|
-
zOffsetLimits: constraint.zOffsetLimits,
|
|
1752
|
-
};
|
|
1753
|
-
}
|
|
1754
|
-
return null;
|
|
1755
|
-
}, id);
|
|
1756
|
-
},
|
|
1757
|
-
getPlanarConstraint: (id, constrName) => {
|
|
1758
|
-
return this.resolve(async ([rId]) => {
|
|
1759
|
-
const constraint = asmUtils.getPlanarConstraint(drawingId, rId, constrName);
|
|
1760
|
-
if (constraint != undefined) {
|
|
1761
|
-
return {
|
|
1762
|
-
constrId: constraint.constrId,
|
|
1763
|
-
mate1: constraint.mate1,
|
|
1764
|
-
mate2: constraint.mate2,
|
|
1765
|
-
zOffset: constraint.zOffset.value,
|
|
1766
|
-
xOffsetLimits: constraint.xOffsetLimits,
|
|
1767
|
-
yOffsetLimits: constraint.yOffsetLimits,
|
|
1768
|
-
zRotationLimits: constraint.zRotationLimits,
|
|
1769
|
-
};
|
|
1770
|
-
}
|
|
1771
|
-
return null;
|
|
1772
|
-
}, id);
|
|
1773
|
-
},
|
|
1774
|
-
getParallelConstraint: (id, constrName) => {
|
|
1775
|
-
return this.resolve(async ([rId]) => {
|
|
1776
|
-
const constraint = asmUtils.getParallelConstraint(drawingId, rId, constrName);
|
|
1777
|
-
if (constraint != undefined) {
|
|
1778
|
-
return {
|
|
1779
|
-
constrId: constraint.constrId,
|
|
1780
|
-
mate1: constraint.mate1,
|
|
1781
|
-
mate2: constraint.mate2,
|
|
1782
|
-
xOffsetLimits: constraint.xOffsetLimits,
|
|
1783
|
-
yOffsetLimits: constraint.yOffsetLimits,
|
|
1784
|
-
zOffsetLimits: constraint.zOffsetLimits,
|
|
1785
|
-
zRotationLimits: constraint.zRotationLimits,
|
|
1786
|
-
};
|
|
1787
|
-
}
|
|
1788
|
-
return null;
|
|
1789
|
-
}, id);
|
|
1790
|
-
},
|
|
1791
|
-
getCylindricalConstraint: (id, constrName) => {
|
|
1792
|
-
return this.resolve(async ([rId]) => {
|
|
1793
|
-
const constraint = asmUtils.getCylindricalConstraint(drawingId, rId, constrName);
|
|
1794
|
-
if (constraint != undefined) {
|
|
1795
|
-
return {
|
|
1796
|
-
constrId: constraint.constrId,
|
|
1797
|
-
mate1: constraint.mate1,
|
|
1798
|
-
mate2: constraint.mate2,
|
|
1799
|
-
zOffsetLimits: constraint.zOffsetLimits,
|
|
1800
|
-
zRotationLimits: constraint.zRotationLimits,
|
|
1801
|
-
};
|
|
1802
|
-
}
|
|
1803
|
-
return null;
|
|
1804
|
-
}, id);
|
|
1805
|
-
},
|
|
1806
|
-
getGroupConstraint: (id, constrName) => {
|
|
1807
|
-
return this.resolve(async ([rId]) => {
|
|
1808
|
-
const constraint = asmUtils.getGroupConstraint(drawingId, rId, constrName);
|
|
1809
|
-
if (constraint != undefined) {
|
|
1810
|
-
return {
|
|
1811
|
-
constrId: constraint.constrId,
|
|
1812
|
-
instanceIds: constraint.instanceIds,
|
|
1813
|
-
};
|
|
1814
|
-
}
|
|
1815
|
-
return null;
|
|
1816
|
-
}, id);
|
|
1817
|
-
},
|
|
1818
|
-
getLinearPatternConstraint: (id, constrName) => {
|
|
1819
|
-
return this.resolve(async ([rId]) => {
|
|
1820
|
-
var _a, _b;
|
|
1821
|
-
const constraint = asmUtils.getLinearPatternConstraint(drawingId, rId, constrName);
|
|
1822
|
-
if (constraint != undefined) {
|
|
1823
|
-
return {
|
|
1824
|
-
constrId: constraint.constrId,
|
|
1825
|
-
instanceId: constraint.instanceId,
|
|
1826
|
-
mate1: constraint.mate1,
|
|
1827
|
-
firstDirInstanceCount: constraint.firstDirInstanceCount.value,
|
|
1828
|
-
firstDirDistance: constraint.firstDirDistance.value,
|
|
1829
|
-
mate2: constraint.mate2,
|
|
1830
|
-
secondDirInstanceCount: (_a = constraint === null || constraint === void 0 ? void 0 : constraint.secondDirInstanceCount) === null || _a === void 0 ? void 0 : _a.value,
|
|
1831
|
-
secondDirDistance: (_b = constraint === null || constraint === void 0 ? void 0 : constraint.secondDirDistance) === null || _b === void 0 ? void 0 : _b.value,
|
|
1832
|
-
};
|
|
1833
|
-
}
|
|
1834
|
-
return null;
|
|
1835
|
-
}, id);
|
|
1836
|
-
},
|
|
1837
|
-
getCircularPatternConstraint: (id, constrName) => {
|
|
1838
|
-
return this.resolve(async ([rId]) => {
|
|
1839
|
-
const constraint = asmUtils.getCircularPatternConstraint(drawingId, rId, constrName);
|
|
1840
|
-
if (constraint != undefined) {
|
|
1841
|
-
return {
|
|
1842
|
-
constrId: constraint.constrId,
|
|
1843
|
-
instanceId: constraint.instanceId,
|
|
1844
|
-
mate1: constraint.mate1,
|
|
1845
|
-
instanceCount: constraint.instanceCount.value,
|
|
1846
|
-
angle: constraint.angle.value,
|
|
1847
|
-
offset: constraint.offset.value,
|
|
1848
|
-
};
|
|
1849
|
-
}
|
|
1850
|
-
return null;
|
|
1851
|
-
}, id);
|
|
1852
|
-
},
|
|
1853
|
-
getFeatureByName: (partId, featureName) => {
|
|
1854
|
-
return this.resolve(async ([rProductId]) => {
|
|
1855
|
-
const feature = await featureAPI.getFeatureByName(rProductId, featureName);
|
|
1856
|
-
if (feature !== null) {
|
|
1857
|
-
return feature;
|
|
1858
|
-
}
|
|
1859
|
-
return null;
|
|
1860
|
-
}, partId);
|
|
1861
|
-
},
|
|
1862
|
-
getGeometryInformation: (id) => {
|
|
1863
|
-
return this.resolve(async ([rId]) => {
|
|
1864
|
-
const values = await baseModelerAPI.getGeometryInformation(rId);
|
|
1865
|
-
if (values !== null) {
|
|
1866
|
-
return { centerOfGravity: values[0], volume: values[1] };
|
|
1867
|
-
}
|
|
1868
|
-
return null;
|
|
1869
|
-
}, id);
|
|
1870
|
-
},
|
|
1871
|
-
removeInstances: async (...instances) => {
|
|
1872
|
-
var e_14, _a;
|
|
1873
|
-
const instancesToRemove = [];
|
|
1874
|
-
try {
|
|
1875
|
-
for (var instances_2 = __asyncValues(instances), instances_2_1; instances_2_1 = await instances_2.next(), !instances_2_1.done;) {
|
|
1876
|
-
const instance = instances_2_1.value;
|
|
1877
|
-
const [rInstanceId] = await new Promise(res => this.resolve(id => res(id), instance.id));
|
|
1878
|
-
let instanceId = rInstanceId;
|
|
1879
|
-
if (typeof rInstanceId === 'string') {
|
|
1880
|
-
instanceId = baseUtils.findObject(drawingId, {
|
|
1881
|
-
ident: rInstanceId,
|
|
1882
|
-
name: rInstanceId,
|
|
1883
|
-
});
|
|
1884
|
-
if (!instanceId) {
|
|
1885
|
-
throw 'The instance to remove given by name or ident "' + rInstanceId + '" does not exist.';
|
|
1886
|
-
}
|
|
1887
|
-
const clazz = getDrawing(drawingId).structure.tree[instanceId].class;
|
|
1888
|
-
if (!baseUtils.isA(clazz, CCClasses.IProductReference)) {
|
|
1889
|
-
throw ('The instance to remove given by name or ident "' +
|
|
1890
|
-
rInstanceId +
|
|
1891
|
-
'" is of the wrong type "' +
|
|
1892
|
-
clazz +
|
|
1893
|
-
'". Make sure the object is an instance.');
|
|
1894
|
-
}
|
|
1895
|
-
}
|
|
1896
|
-
const instanceParam = { id: instanceId };
|
|
1897
|
-
instancesToRemove.push(instanceParam);
|
|
1898
|
-
}
|
|
1899
|
-
}
|
|
1900
|
-
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
1901
|
-
finally {
|
|
1902
|
-
try {
|
|
1903
|
-
if (instances_2_1 && !instances_2_1.done && (_a = instances_2.return)) await _a.call(instances_2);
|
|
1904
|
-
}
|
|
1905
|
-
finally { if (e_14) throw e_14.error; }
|
|
1906
|
-
}
|
|
1907
|
-
return assemblyBuilderAPI.removeInstances(instancesToRemove);
|
|
1908
|
-
},
|
|
1909
|
-
importFeature: (partId, content, format, name) => {
|
|
1910
|
-
return this.resolve(async ([rPartId]) => {
|
|
1911
|
-
const featureName = name ? name : 'Import';
|
|
1912
|
-
const importFeatureId = await featureAPI.createFeature(rPartId, CCClasses.CCImport, featureName);
|
|
1913
|
-
if (importFeatureId !== null) {
|
|
1914
|
-
const solids = await featureAPI.updateImport(importFeatureId, content, format.toUpperCase(), featureName);
|
|
1915
|
-
if (solids !== null) {
|
|
1916
|
-
return importFeatureId;
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
1919
|
-
return null;
|
|
1920
|
-
}, partId);
|
|
1921
|
-
},
|
|
1922
|
-
loadSketch: (partId, stream, planeId, name) => {
|
|
1923
|
-
return this.resolve(async ([rPartId, rPlaneId]) => {
|
|
1924
|
-
const sketch = await sketcherAPI.createSketch(rPartId);
|
|
1925
|
-
if (sketch) {
|
|
1926
|
-
await featureAPI.closeFeature(sketch);
|
|
1927
|
-
const tree = getDrawing(drawingId).structure.tree;
|
|
1928
|
-
const plane = tree[rPlaneId];
|
|
1929
|
-
if (plane && baseUtils.isA(plane.class, CCClasses.CCWorkPlane)) {
|
|
1930
|
-
await sketcherAPI.setWorkPlane(sketch, rPlaneId);
|
|
1931
|
-
}
|
|
1932
|
-
else {
|
|
1933
|
-
await sketcherAPI.createAndSetWorkPlane(sketch, rPlaneId);
|
|
1934
|
-
}
|
|
1935
|
-
await sketcherAPI.loadSketch(rPartId, sketch, stream, name);
|
|
1936
|
-
return sketch;
|
|
1937
|
-
}
|
|
1938
|
-
}, partId, planeId);
|
|
1939
|
-
},
|
|
1940
|
-
copySketch: (partId, sketchId, planeId) => {
|
|
1941
|
-
return this.resolve(async ([rPartId, rPlaneId, rSketchId]) => {
|
|
1942
|
-
const sketch = await sketcherAPI.createSketch(rPartId);
|
|
1943
|
-
if (sketch) {
|
|
1944
|
-
await featureAPI.closeFeature(sketch);
|
|
1945
|
-
const tree = getDrawing(drawingId).structure.tree;
|
|
1946
|
-
const plane = tree[rPlaneId];
|
|
1947
|
-
if (plane && baseUtils.isA(plane.class, CCClasses.CCWorkPlane)) {
|
|
1948
|
-
await sketcherAPI.setWorkPlane(sketch, rPlaneId);
|
|
1949
|
-
}
|
|
1950
|
-
else {
|
|
1951
|
-
await sketcherAPI.createAndSetWorkPlane(sketch, rPlaneId);
|
|
1952
|
-
}
|
|
1953
|
-
await sketcherAPI.copySketch(sketch, rSketchId);
|
|
1954
|
-
return sketch;
|
|
1955
|
-
}
|
|
1956
|
-
}, partId, planeId, sketchId);
|
|
1957
|
-
},
|
|
1958
|
-
placeSketch: (sketchId, planeId, invertPlane, axisId, isXAxis, invertAxis, originId) => {
|
|
1959
|
-
return this.resolve(async ([rSketchId, rPlaneId, rAxisId, rOriginId]) => {
|
|
1960
|
-
await sketcherAPI.setSketchRefs(rSketchId, rPlaneId, invertPlane, rAxisId, isXAxis, invertAxis, rOriginId);
|
|
1961
|
-
}, sketchId, planeId, axisId, originId);
|
|
1962
|
-
},
|
|
1963
|
-
transformInstances: async (...instances) => {
|
|
1964
|
-
var e_15, _a;
|
|
1965
|
-
const instancesToTransform = [];
|
|
1966
|
-
try {
|
|
1967
|
-
for (var instances_3 = __asyncValues(instances), instances_3_1; instances_3_1 = await instances_3.next(), !instances_3_1.done;) {
|
|
1968
|
-
const instance = instances_3_1.value;
|
|
1969
|
-
const [rInstanceId] = await new Promise(res => this.resolve(id => res(id), instance.id));
|
|
1970
|
-
let instanceId = rInstanceId;
|
|
1971
|
-
if (typeof rInstanceId === 'string') {
|
|
1972
|
-
instanceId = baseUtils.findObject(drawingId, {
|
|
1973
|
-
ident: rInstanceId,
|
|
1974
|
-
name: rInstanceId,
|
|
1975
|
-
});
|
|
1976
|
-
if (!instanceId) {
|
|
1977
|
-
throw 'The instance to transform given by name or ident "' + rInstanceId + '" does not exist.';
|
|
1978
|
-
}
|
|
1979
|
-
const clazz = getDrawing(drawingId).structure.tree[instanceId].class;
|
|
1980
|
-
if (!baseUtils.isA(clazz, CCClasses.IProductReference)) {
|
|
1981
|
-
throw ('The instance to transform given by name or ident "' +
|
|
1982
|
-
rInstanceId +
|
|
1983
|
-
'" is of the wrong type "' +
|
|
1984
|
-
clazz +
|
|
1985
|
-
'". Make sure the object is an instance.');
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
const instanceParam = {
|
|
1989
|
-
id: instanceId,
|
|
1990
|
-
transformation: instance.transformation,
|
|
1991
|
-
options: { isLocal: true }, // in non-interactive mode, the transformation is local to the owner
|
|
1992
|
-
};
|
|
1993
|
-
instancesToTransform.push(instanceParam);
|
|
1994
|
-
}
|
|
1995
|
-
}
|
|
1996
|
-
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
1997
|
-
finally {
|
|
1998
|
-
try {
|
|
1999
|
-
if (instances_3_1 && !instances_3_1.done && (_a = instances_3.return)) await _a.call(instances_3);
|
|
2000
|
-
}
|
|
2001
|
-
finally { if (e_15) throw e_15.error; }
|
|
2002
|
-
}
|
|
2003
|
-
return assemblyBuilderAPI.transformInstances(instancesToTransform);
|
|
2004
|
-
},
|
|
2005
|
-
translate: (partId, operations, references, inverted, distance) => {
|
|
2006
|
-
return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
|
|
2007
|
-
const translationId = await featureAPI.createFeature(rPartId, CCClasses.CCTranslation, 'Translate');
|
|
2008
|
-
if (translationId !== null) {
|
|
2009
|
-
const cDrawing = await getDrawing(drawingId);
|
|
2010
|
-
const entArray = [];
|
|
2011
|
-
for (const rOperation of rOperations) {
|
|
2012
|
-
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
2013
|
-
if (entities != undefined) {
|
|
2014
|
-
entArray.push(entities[0]);
|
|
2015
|
-
}
|
|
2016
|
-
}
|
|
2017
|
-
const dist = { value: distance, isExpr: typeof distance === 'string' };
|
|
2018
|
-
await featureAPI.updateTransformation(translationId, entArray, rReferences, inverted, dist);
|
|
2019
|
-
return translationId;
|
|
2020
|
-
}
|
|
2021
|
-
return null;
|
|
2022
|
-
}, partId, operations, ...references);
|
|
2023
|
-
},
|
|
2024
|
-
// TODO: Remove this method. Is it necessary?
|
|
2025
|
-
updateTranslate: (translationId, distance) => {
|
|
2026
|
-
return this.resolve(async ([rTranslationId]) => {
|
|
2027
|
-
const cDrawing = await getDrawing(drawingId);
|
|
2028
|
-
const members = cDrawing.structure.tree[rTranslationId].members;
|
|
2029
|
-
if (members !== null && members !== undefined) {
|
|
2030
|
-
const entArray = members['bodiesToTransform'].members.map(m => m.value);
|
|
2031
|
-
const references = members['references'].members.map(m => m.value);
|
|
2032
|
-
const inverted = members['inverted'].value;
|
|
2033
|
-
const dist = distance !== null ? distance : members['translationDistance'].value;
|
|
2034
|
-
const distParam = { value: dist, isExpr: typeof distance === 'string' };
|
|
2035
|
-
await featureAPI.openFeature(rTranslationId);
|
|
2036
|
-
await featureAPI.updateTransformation(rTranslationId, entArray, references, inverted, distParam);
|
|
2037
|
-
await featureAPI.closeFeature(rTranslationId);
|
|
2038
|
-
}
|
|
2039
|
-
}, translationId);
|
|
2040
|
-
},
|
|
2041
|
-
save: (type) => {
|
|
2042
|
-
return baseModelerAPI.save(type);
|
|
2043
|
-
},
|
|
2044
|
-
saveToUrl: (url, filetype) => {
|
|
2045
|
-
return baseModelerAPI.saveToUrl(url, filetype);
|
|
2046
|
-
},
|
|
2047
|
-
load: (content, type, options) => {
|
|
2048
|
-
return baseModelerAPI.load(content, type, '', options);
|
|
2049
|
-
},
|
|
2050
|
-
loadFromUrl: (url, filetype, options) => {
|
|
2051
|
-
return baseModelerAPI.loadFromUrl(url, filetype, true, options);
|
|
2052
|
-
},
|
|
2053
|
-
loadProduct: (content, type, options) => {
|
|
2054
|
-
return assemblyBuilderAPI.loadProduct(content, type, options);
|
|
2055
|
-
},
|
|
2056
|
-
loadProductFromUrl: (url, filetype, options) => {
|
|
2057
|
-
return assemblyBuilderAPI.loadProductFromUrl(url, filetype, options);
|
|
2058
|
-
},
|
|
2059
|
-
pick: (partId, type, points) => {
|
|
2060
|
-
return this.resolve(async ([rPartId]) => {
|
|
2061
|
-
console.warn('Warning: pick() is deprecated, use findGeometry() instead, pick() will be removed in a future release.');
|
|
2062
|
-
const refs = await featureAPI.pick(rPartId, type, points.map(p => resolveVec(p)));
|
|
2063
|
-
if (refs != undefined) {
|
|
2064
|
-
return Array.isArray(refs) ? refs : [refs];
|
|
2065
|
-
}
|
|
2066
|
-
return null;
|
|
2067
|
-
}, partId);
|
|
2068
|
-
},
|
|
2069
|
-
setExpressions: async (...expressions) => {
|
|
2070
|
-
var e_16, _a;
|
|
2071
|
-
const expressionsToSet = [];
|
|
2072
|
-
try {
|
|
2073
|
-
for (var expressions_1 = __asyncValues(expressions), expressions_1_1; expressions_1_1 = await expressions_1.next(), !expressions_1_1.done;) {
|
|
2074
|
-
const expr = expressions_1_1.value;
|
|
2075
|
-
const [rPartId] = await new Promise(res => this.resolve(id => res(id), expr.partId));
|
|
2076
|
-
const membersToModify = [];
|
|
2077
|
-
expr.members.forEach((mem) => {
|
|
2078
|
-
const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen Strings
|
|
2079
|
-
const featureAPIParam = {
|
|
2080
|
-
value: mem.value,
|
|
2081
|
-
isExpr,
|
|
2082
|
-
};
|
|
2083
|
-
membersToModify.push({ name: mem.name, value: featureAPIParam });
|
|
2084
|
-
});
|
|
2085
|
-
// Looking for the partId given by an identifier or name
|
|
2086
|
-
let part = rPartId;
|
|
2087
|
-
if (typeof part === 'string') {
|
|
2088
|
-
const foundPart = baseUtils.findObject(drawingId, { ident: part, name: part });
|
|
2089
|
-
if (!foundPart) {
|
|
2090
|
-
throw 'No part found to set expressions on for given name or ident: ' + part;
|
|
2091
|
-
}
|
|
2092
|
-
const clazz = getDrawing(drawingId).structure.tree[foundPart].class;
|
|
2093
|
-
if (!baseUtils.isA(clazz, CCClasses.CCPart)) {
|
|
2094
|
-
throw ('The part to set expressions on given by name or ident "' +
|
|
2095
|
-
part +
|
|
2096
|
-
'" is of the wrong type "' +
|
|
2097
|
-
clazz +
|
|
2098
|
-
'". Make sure the object is a part.');
|
|
2099
|
-
}
|
|
2100
|
-
else {
|
|
2101
|
-
part = foundPart;
|
|
2102
|
-
}
|
|
2103
|
-
}
|
|
2104
|
-
expressionsToSet.push({
|
|
2105
|
-
productId: part,
|
|
2106
|
-
toAddMembers: [],
|
|
2107
|
-
toModifyMembers: membersToModify,
|
|
2108
|
-
toDeleteList: [],
|
|
2109
|
-
});
|
|
2110
|
-
}
|
|
2111
|
-
}
|
|
2112
|
-
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
2113
|
-
finally {
|
|
2114
|
-
try {
|
|
2115
|
-
if (expressions_1_1 && !expressions_1_1.done && (_a = expressions_1.return)) await _a.call(expressions_1);
|
|
2116
|
-
}
|
|
2117
|
-
finally { if (e_16) throw e_16.error; }
|
|
2118
|
-
}
|
|
2119
|
-
const success = await featureAPI.updateExpressions(expressionsToSet);
|
|
2120
|
-
return success;
|
|
2121
|
-
},
|
|
2122
|
-
renameExpressions: (partId, members) => {
|
|
2123
|
-
return this.resolve(async ([rPartId]) => {
|
|
2124
|
-
const success = featureAPI.updateExpressions([
|
|
2125
|
-
{ productId: rPartId, toAddMembers: [], toModifyMembers: [], toRenameMembers: members, toDeleteList: [] },
|
|
2126
|
-
]);
|
|
2127
|
-
return success;
|
|
2128
|
-
}, partId);
|
|
2129
|
-
},
|
|
2130
|
-
deleteExpressions: (partId, members) => {
|
|
2131
|
-
return this.resolve(async ([rPartId]) => {
|
|
2132
|
-
const success = featureAPI.updateExpressions([
|
|
2133
|
-
{ productId: rPartId, toAddMembers: [], toModifyMembers: [], toDeleteList: members },
|
|
2134
|
-
]);
|
|
2135
|
-
return success;
|
|
2136
|
-
}, partId);
|
|
2137
|
-
},
|
|
2138
|
-
sphere: (partId, references, radius) => {
|
|
2139
|
-
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
2140
|
-
const sphereId = await featureAPI.createFeature(rPartId, CCClasses.CCSphere, 'Sphere');
|
|
2141
|
-
if (sphereId != null) {
|
|
2142
|
-
const radiusParam = { value: radius, isExpr: typeof radius === 'string' };
|
|
2143
|
-
await featureAPI.updateSphere(sphereId, rReferences, radiusParam);
|
|
2144
|
-
return sphereId;
|
|
2145
|
-
}
|
|
2146
|
-
return null;
|
|
2147
|
-
}, partId, ...references);
|
|
2148
|
-
},
|
|
2149
|
-
mirror: async (partId, operations, references) => {
|
|
2150
|
-
const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
|
|
2151
|
-
const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
|
|
2152
|
-
const rReferences = await new Promise(res => this.resolve(paths => res(paths), ...references));
|
|
2153
|
-
const cDrawing = getDrawing(drawingId);
|
|
2154
|
-
const entArray = [];
|
|
2155
|
-
for (const rOperation of rOperations) {
|
|
2156
|
-
const entities = cDrawing.structure.tree[rOperation].children;
|
|
2157
|
-
if (entities != undefined) {
|
|
2158
|
-
entArray.push(entities[0]);
|
|
2159
|
-
}
|
|
2160
|
-
}
|
|
2161
|
-
const mirrorId = await featureAPI.createFeature(rPartId, CCClasses.CCMirror, 'Mirror');
|
|
2162
|
-
if (mirrorId != null) {
|
|
2163
|
-
await featureAPI.updateMirror(mirrorId, entArray, rReferences);
|
|
2164
|
-
return mirrorId;
|
|
2165
|
-
}
|
|
2166
|
-
return null;
|
|
2167
|
-
},
|
|
2168
|
-
removeOperations: async (operations, toOperation) => {
|
|
2169
|
-
const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
|
|
2170
|
-
const [rToOperation] = await new Promise(res => this.resolve(paths => res(paths), toOperation));
|
|
2171
|
-
if (operations && operations.length > 0) {
|
|
2172
|
-
await baseModelerAPI.deleteObjects(rOperations);
|
|
2173
|
-
}
|
|
2174
|
-
else if (rToOperation) {
|
|
2175
|
-
const toRemoveOps = [];
|
|
2176
|
-
const cDrawing = getDrawing(drawingId);
|
|
2177
|
-
const tree = cDrawing.structure.tree;
|
|
2178
|
-
const opSeq = cDrawing.api.structure.filterTree(tree, obj => obj.name === 'OperationSequence').pop();
|
|
2179
|
-
const opRefs = opSeq && baseUtils.getChildren(opSeq.id, CCClasses.CCObjectReference, tree);
|
|
2180
|
-
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; });
|
|
2181
|
-
if (filteredOps) {
|
|
2182
|
-
let opNotFound = true;
|
|
2183
|
-
let index = filteredOps.length - 2; // -2 => Avoid RollBackBar
|
|
2184
|
-
while (opNotFound) {
|
|
2185
|
-
if (filteredOps[index] !== rToOperation) {
|
|
2186
|
-
toRemoveOps.push(filteredOps[index]);
|
|
2187
|
-
}
|
|
2188
|
-
else {
|
|
2189
|
-
opNotFound = false;
|
|
2190
|
-
}
|
|
2191
|
-
index--;
|
|
2192
|
-
}
|
|
2193
|
-
}
|
|
2194
|
-
await baseModelerAPI.deleteObjects(toRemoveOps);
|
|
2195
|
-
}
|
|
2196
|
-
},
|
|
2197
|
-
getMatePath: async (refId) => {
|
|
2198
|
-
return this.resolve(async ([rRefId]) => {
|
|
2199
|
-
return asmUtils.getMatePath(drawingId, rRefId);
|
|
2200
|
-
}, refId);
|
|
2201
|
-
},
|
|
2202
|
-
slice: async (partId, operations, reference, sideFlag) => {
|
|
2203
|
-
const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
|
|
2204
|
-
const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
|
|
2205
|
-
const [rReference] = await new Promise(res => this.resolve(paths => res(paths), reference));
|
|
2206
|
-
const cDrawing = getDrawing(drawingId);
|
|
2207
|
-
const entArray = [];
|
|
2208
|
-
for (const rOperation of rOperations) {
|
|
2209
|
-
const entities = cDrawing.structure.tree[rOperation].children;
|
|
2210
|
-
if (entities != undefined && entities.length > 0) {
|
|
2211
|
-
entArray.push(entities[0]); // use first entity of operation
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
const sliceId = await featureAPI.createFeature(rPartId, CCClasses.CCSlice, 'Slice');
|
|
2215
|
-
if (sliceId != null) {
|
|
2216
|
-
await featureAPI.openFeature(sliceId);
|
|
2217
|
-
if (entArray.length > 0) {
|
|
2218
|
-
await featureAPI.updateSlice(sliceId, entArray, rReference, sideFlag ? 1 : 0);
|
|
2219
|
-
await featureAPI.closeFeature(sliceId);
|
|
2220
|
-
return sliceId;
|
|
2221
|
-
}
|
|
2222
|
-
await featureAPI.closeFeature(sliceId);
|
|
2223
|
-
await baseModelerAPI.deleteObjects([sliceId]);
|
|
2224
|
-
}
|
|
2225
|
-
return null;
|
|
2226
|
-
},
|
|
2227
|
-
sliceBySheet: async (partId, operationToSlice, operationOfSheet, sideFlag) => {
|
|
2228
|
-
const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
|
|
2229
|
-
const [rOperationToSlice] = await new Promise(res => this.resolve(ids => res(ids), operationToSlice));
|
|
2230
|
-
const [rOperationOfSheet] = await new Promise(res => this.resolve(ids => res(ids), operationOfSheet));
|
|
2231
|
-
const entityToSlice = getDrawing(drawingId).structure.tree[rOperationToSlice].children;
|
|
2232
|
-
const entityOfSheet = getDrawing(drawingId).structure.tree[rOperationOfSheet].children;
|
|
2233
|
-
const sliceBySheetId = await featureAPI.createFeature(rPartId, CCClasses.CCSliceBySheet, 'SliceBySheet');
|
|
2234
|
-
if (sliceBySheetId != null) {
|
|
2235
|
-
await featureAPI.openFeature(sliceBySheetId);
|
|
2236
|
-
if (entityToSlice && entityToSlice.length > 0 && entityOfSheet && entityOfSheet.length > 0) {
|
|
2237
|
-
await featureAPI.updateSliceBySheet(sliceBySheetId, entityToSlice[0], entityOfSheet[0], sideFlag ? 1 : 0);
|
|
2238
|
-
await featureAPI.closeFeature(sliceBySheetId);
|
|
2239
|
-
return sliceBySheetId;
|
|
2240
|
-
}
|
|
2241
|
-
await featureAPI.closeFeature(sliceBySheetId);
|
|
2242
|
-
await baseModelerAPI.deleteObjects([sliceBySheetId]);
|
|
2243
|
-
}
|
|
2244
|
-
return null;
|
|
2245
|
-
},
|
|
2246
|
-
twist: async (param) => {
|
|
2247
|
-
return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
|
|
2248
|
-
const twist = await featureAPI.createFeature(rPartId, CCClasses.CCTwist, 'Twist');
|
|
2249
|
-
if (twist) {
|
|
2250
|
-
const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
|
|
2251
|
-
? rSketchOrRegionIds
|
|
2252
|
-
: [rSketchOrRegionIds];
|
|
2253
|
-
if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
|
|
2254
|
-
const limit1Param = {
|
|
2255
|
-
value: param.limit1,
|
|
2256
|
-
isExpr: typeof param.limit1 === 'string',
|
|
2257
|
-
};
|
|
2258
|
-
const limit2Param = {
|
|
2259
|
-
value: param.limit2,
|
|
2260
|
-
isExpr: typeof param.limit2 === 'string',
|
|
2261
|
-
};
|
|
2262
|
-
const twistAngleParam = {
|
|
2263
|
-
value: param.twistAngle,
|
|
2264
|
-
isExpr: typeof param.twistAngle === 'string',
|
|
2265
|
-
};
|
|
2266
|
-
if (!param.direction) {
|
|
2267
|
-
param.direction = { x: 0, y: 0, z: 1 };
|
|
2268
|
-
}
|
|
2269
|
-
if (!param.twistCenter) {
|
|
2270
|
-
param.twistCenter = { x: 0, y: 0, z: 0 };
|
|
2271
|
-
}
|
|
2272
|
-
const resDirection = resolveVec(param.direction);
|
|
2273
|
-
const directionParam = {
|
|
2274
|
-
value: resDirection,
|
|
2275
|
-
isExpr: typeof resDirection === 'string',
|
|
2276
|
-
};
|
|
2277
|
-
const resTwistCenter = resolveVec(param.twistCenter);
|
|
2278
|
-
const twistCenterParam = {
|
|
2279
|
-
value: resTwistCenter,
|
|
2280
|
-
isExpr: typeof resTwistCenter === 'string',
|
|
2281
|
-
};
|
|
2282
|
-
await featureAPI.updateTwist(twist, resSketchOrRegionIds, param.type, limit1Param, limit2Param, directionParam, twistAngleParam, twistCenterParam, param.capEnds);
|
|
2283
|
-
return twist;
|
|
2284
|
-
}
|
|
2285
|
-
}
|
|
2286
|
-
}, param.partId, param.sketchOrRegionIds);
|
|
2287
|
-
},
|
|
2288
|
-
};
|
|
2289
|
-
callback(publicApi);
|
|
2290
|
-
resolve(drawingId);
|
|
2291
|
-
});
|
|
2292
|
-
return () => promise.then(drawingId => api.getState().api.removeDrawing(drawingId));
|
|
2293
|
-
}
|
|
2294
|
-
destroy() {
|
|
2295
|
-
this.drawingId && api.getState().api.removeDrawing(this.drawingId);
|
|
2296
|
-
}
|
|
2297
|
-
}
|
|
2298
|
-
export class history extends History {
|
|
2299
|
-
constructor() {
|
|
2300
|
-
super();
|
|
2301
|
-
console.warn("Warning: 'history' is deprecated, use 'History' instead, 'history' will be removed in a future release.");
|
|
2302
|
-
}
|
|
2303
|
-
}
|
|
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
|
+
};
|
|
8
|
+
/* eslint-disable max-lines */
|
|
9
|
+
import { createApi, CCClasses, ccUtils, DataType, SVGModusType, BuerliCadFacade, } from '@buerli.io/classcad';
|
|
10
|
+
import { api, getDrawing, MathUtils, BuerliScope, createInfo, Measure, } from '@buerli.io/core';
|
|
11
|
+
import { Group, Matrix4, Mesh, MeshStandardMaterial, Scene } from 'three';
|
|
12
|
+
import { mergeBufferGeometries } from 'three-stdlib';
|
|
13
|
+
import { waitForSelect } from './utils/selection';
|
|
14
|
+
import { getDifferentColoredMeshesFromEntity } from './utils/meshes';
|
|
15
|
+
/**
|
|
16
|
+
* Helps to create the buffer geometry of the given object recursively.
|
|
17
|
+
* @param object object to create the buffergeometry from
|
|
18
|
+
* @param bufferGeomArray array to fill up with buffert geometries
|
|
19
|
+
*/
|
|
20
|
+
const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray) => {
|
|
21
|
+
let cDrawing = getDrawing(drawingId);
|
|
22
|
+
const tree = cDrawing.structure.tree;
|
|
23
|
+
if (object.link || object.solids) {
|
|
24
|
+
// Part
|
|
25
|
+
const baseModeler = createApi(drawingId).v0.baseModeler;
|
|
26
|
+
const solids = object.link ? tree[object.link].solids : object.solids;
|
|
27
|
+
if (solids != undefined) {
|
|
28
|
+
let geometries = [];
|
|
29
|
+
for (const solid of solids) {
|
|
30
|
+
let cachedSolid = cDrawing.geometry.cache[solid];
|
|
31
|
+
if (cachedSolid) {
|
|
32
|
+
// if solid already cached, take it from cache
|
|
33
|
+
geometries = [...geometries, ...cachedSolid.meshes.map(m => m.geometry)];
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
// else get visualisation from classcad
|
|
37
|
+
await baseModeler.requestVisualisationOfEntities([solid]);
|
|
38
|
+
cDrawing = getDrawing(drawingId); // get current drawing state after request
|
|
39
|
+
cachedSolid = cDrawing.geometry.cache[solid];
|
|
40
|
+
if (cachedSolid) {
|
|
41
|
+
geometries = [...geometries, ...cachedSolid.meshes.map(m => m.geometry)];
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
console.warn(`There is no cached entry for ${solid}!`, cDrawing.geometry.cache);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
if (geometries.length > 0) {
|
|
49
|
+
const transformation = cDrawing.api.structure.calculateGlobalTransformation(object.id);
|
|
50
|
+
const bufferGeom = mergeBufferGeometries(geometries);
|
|
51
|
+
bufferGeom.applyMatrix4(transformation);
|
|
52
|
+
bufferGeomArray.push(bufferGeom);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
else if (object.children) {
|
|
57
|
+
// Assembly
|
|
58
|
+
for (const child of object.children) {
|
|
59
|
+
if (ccUtils.base.isA(tree[child].class, CCClasses.IProductReference)) {
|
|
60
|
+
await createRecursiveBufferGeometry(tree[child], drawingId, bufferGeomArray);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* We traverse recursively over structure tree, starting with object and create THREE objects
|
|
67
|
+
* for the scene. Each part or assembly will be turned into groups and subgroups. Solids which are children of the
|
|
68
|
+
* parts will be turned into groups as well. Children of solids will be merged to meshes. Faces of a solid with different color
|
|
69
|
+
* or transparency will get its own mesh.
|
|
70
|
+
* @param object root object where we start building the three scene
|
|
71
|
+
* @param drawingId id of the drawing
|
|
72
|
+
* @param root the root of the scene
|
|
73
|
+
* @param result object containing all the current collected nodes, solids, meshes
|
|
74
|
+
* @param options e.g. meshPerGeometry controls if each geometry element gets a own mesh or if they will be combined/merged
|
|
75
|
+
*/
|
|
76
|
+
const createRecursiveScene = async (object, drawingId, root, result, options) => {
|
|
77
|
+
let cDrawing = getDrawing(drawingId);
|
|
78
|
+
const tree = cDrawing.structure.tree;
|
|
79
|
+
if (object.link || object.solids) {
|
|
80
|
+
// Part
|
|
81
|
+
const baseModeler = createApi(drawingId).v0.baseModeler;
|
|
82
|
+
const entities = object.link ? tree[object.link].solids : object.solids;
|
|
83
|
+
if (entities != undefined) {
|
|
84
|
+
const part = new Group();
|
|
85
|
+
const matrix = object.coordinateSystem ? MathUtils.convertToMatrix4(object.coordinateSystem) : new Matrix4();
|
|
86
|
+
matrix.decompose(part.position, part.quaternion, part.scale);
|
|
87
|
+
part.updateMatrix();
|
|
88
|
+
part.userData = { id: object.id }; // instance id
|
|
89
|
+
part.name = object.name; // instance name
|
|
90
|
+
for (const entity of entities) {
|
|
91
|
+
let cachedEntity = cDrawing.geometry.cache[entity];
|
|
92
|
+
if (!cachedEntity) {
|
|
93
|
+
// else get visualisation from classcad
|
|
94
|
+
await baseModeler.requestVisualisationOfEntities([entity]);
|
|
95
|
+
cDrawing = getDrawing(drawingId); // get current drawing state after request
|
|
96
|
+
cachedEntity = cDrawing.geometry.cache[entity];
|
|
97
|
+
}
|
|
98
|
+
if (cachedEntity && cachedEntity.meshes.length > 0) {
|
|
99
|
+
const solidObject = cDrawing.structure.tree[cachedEntity.container.ownerId];
|
|
100
|
+
if (solidObject) {
|
|
101
|
+
const _solid = new Group();
|
|
102
|
+
_solid.name = solidObject.name + '_solid';
|
|
103
|
+
_solid.userData = { id: solidObject.id }; // add solid id to the userData
|
|
104
|
+
if (options === null || options === void 0 ? void 0 : options.meshPerGeometry) {
|
|
105
|
+
// Create a mesh for each geometry element
|
|
106
|
+
cachedEntity.meshes.forEach((m, i) => {
|
|
107
|
+
const mesh = new Mesh();
|
|
108
|
+
mesh.name = solidObject.name + '_' + i;
|
|
109
|
+
mesh.userData = { id: m.graphicId }; // add graphic id to the userData
|
|
110
|
+
if (!(options === null || options === void 0 ? void 0 : options.structureOnly)) {
|
|
111
|
+
mesh.geometry = m.geometry;
|
|
112
|
+
mesh.material = new MeshStandardMaterial({
|
|
113
|
+
color: m.color ? m.color : cachedEntity.color,
|
|
114
|
+
transparent: m.color ? m.opacity < 1 : cachedEntity.opacity < 1,
|
|
115
|
+
opacity: m.color ? m.opacity : cachedEntity.opacity,
|
|
116
|
+
});
|
|
117
|
+
mesh.material.name = mesh.name + '_material';
|
|
118
|
+
result.materials[mesh.material.name] = mesh.material;
|
|
119
|
+
}
|
|
120
|
+
result.nodes[mesh.name] = mesh;
|
|
121
|
+
_solid.add(mesh);
|
|
122
|
+
});
|
|
123
|
+
part.add(_solid);
|
|
124
|
+
result.nodes[_solid.name] = _solid;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
// Merge all geometries into one mesh, sort them by color
|
|
128
|
+
const colorMeshesMap = getDifferentColoredMeshesFromEntity(cachedEntity);
|
|
129
|
+
const colorMeshes = Object.keys(colorMeshesMap);
|
|
130
|
+
if (colorMeshes.length > 1) {
|
|
131
|
+
// If the solid consists of multiple meshes we must keep the group
|
|
132
|
+
colorMeshes.forEach((key, i) => {
|
|
133
|
+
const mesh = new Mesh();
|
|
134
|
+
mesh.name = solidObject.name + '_' + i;
|
|
135
|
+
mesh.userData = { id: solidObject.id }; // add solid id to the userData
|
|
136
|
+
if (!(options === null || options === void 0 ? void 0 : options.structureOnly)) {
|
|
137
|
+
mesh.geometry = mergeBufferGeometries(colorMeshesMap[key].meshes.map(m => m.geometry));
|
|
138
|
+
mesh.material = new MeshStandardMaterial({
|
|
139
|
+
color: colorMeshesMap[key].color,
|
|
140
|
+
transparent: colorMeshesMap[key].opacity < 1,
|
|
141
|
+
opacity: colorMeshesMap[key].opacity,
|
|
142
|
+
});
|
|
143
|
+
mesh.material.name = mesh.name + '_material';
|
|
144
|
+
result.materials[mesh.material.name] = mesh.material;
|
|
145
|
+
}
|
|
146
|
+
result.nodes[mesh.name] = mesh; // Collect mesh to return result later
|
|
147
|
+
_solid.add(mesh); // Add mesh to solid of the scene
|
|
148
|
+
});
|
|
149
|
+
part.add(_solid);
|
|
150
|
+
result.nodes[_solid.name] = _solid;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
// Otherwise we can use the mesh itself
|
|
154
|
+
const key = colorMeshes[0];
|
|
155
|
+
const mesh = new Mesh();
|
|
156
|
+
mesh.name = solidObject.name;
|
|
157
|
+
mesh.userData = { id: solidObject.id }; // add solid id to the userData
|
|
158
|
+
if (!(options === null || options === void 0 ? void 0 : options.structureOnly)) {
|
|
159
|
+
mesh.geometry = mergeBufferGeometries(colorMeshesMap[key].meshes.map(m => m.geometry));
|
|
160
|
+
mesh.material = new MeshStandardMaterial({
|
|
161
|
+
color: colorMeshesMap[key].color,
|
|
162
|
+
transparent: colorMeshesMap[key].opacity < 1,
|
|
163
|
+
opacity: colorMeshesMap[key].opacity,
|
|
164
|
+
});
|
|
165
|
+
mesh.material.name = mesh.name + '_material';
|
|
166
|
+
result.materials[mesh.material.name] = mesh.material;
|
|
167
|
+
}
|
|
168
|
+
result.nodes[mesh.name] = mesh;
|
|
169
|
+
part.add(mesh);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
root.add(part);
|
|
176
|
+
result.nodes[part.name] = part;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
else if (object.children) {
|
|
180
|
+
// Assembly
|
|
181
|
+
const assembly = new Group();
|
|
182
|
+
const matrix = object.coordinateSystem ? MathUtils.convertToMatrix4(object.coordinateSystem) : new Matrix4();
|
|
183
|
+
matrix.decompose(assembly.position, assembly.quaternion, assembly.scale);
|
|
184
|
+
assembly.updateMatrix();
|
|
185
|
+
assembly.userData = { id: object.id }; // assembly root or instance id
|
|
186
|
+
assembly.name = object.name; // assembly root or instance name
|
|
187
|
+
result.nodes[assembly.name] = assembly;
|
|
188
|
+
root.add(assembly);
|
|
189
|
+
for (const child of object.children) {
|
|
190
|
+
if (ccUtils.base.isA(tree[child].class, CCClasses.IProductReference)) {
|
|
191
|
+
await createRecursiveScene(tree[child], drawingId, assembly, result, options);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
const resolveVec = (value) => {
|
|
197
|
+
const valueX = Array.isArray(value) ? value[0] : value.x;
|
|
198
|
+
const valueY = Array.isArray(value) ? value[1] : value.y;
|
|
199
|
+
const valueZ = Array.isArray(value) ? value[2] : value.z;
|
|
200
|
+
if (typeof valueX === 'string' || typeof valueY === 'string' || typeof valueZ === 'string') {
|
|
201
|
+
return '{' + valueX + ',' + valueY + ',' + valueZ + '}';
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
return { x: valueX, y: valueY, z: valueZ };
|
|
205
|
+
}
|
|
206
|
+
};
|
|
207
|
+
export class History {
|
|
208
|
+
constructor() {
|
|
209
|
+
this.drawingId = null;
|
|
210
|
+
this.queue = Promise.resolve(0);
|
|
211
|
+
this.queue = Promise.resolve(0);
|
|
212
|
+
}
|
|
213
|
+
resolve(callback, ...args) {
|
|
214
|
+
return (this.queue = this.queue
|
|
215
|
+
.then(() => Promise.all(args).then(callback))
|
|
216
|
+
.catch(e => {
|
|
217
|
+
// catch is necessary to avoid error promises in the queue
|
|
218
|
+
}));
|
|
219
|
+
}
|
|
220
|
+
init(callback) {
|
|
221
|
+
const promise = new Promise(async (resolve, reject) => {
|
|
222
|
+
const drawingId = await BuerliCadFacade.utils.connect('history');
|
|
223
|
+
if (!drawingId)
|
|
224
|
+
throw new Error('Connection/Drawing could not be created');
|
|
225
|
+
this.drawingId = drawingId;
|
|
226
|
+
const cc = createApi(drawingId);
|
|
227
|
+
const featureAPI = cc.v0.feature;
|
|
228
|
+
const sketcherAPI = cc.v0.sketcher;
|
|
229
|
+
const baseModelerAPI = cc.v0.baseModeler;
|
|
230
|
+
const assemblyBuilderAPI = cc.v0.assemblyBuilder;
|
|
231
|
+
const drawing2DAPI = cc.v0.drawing2D;
|
|
232
|
+
const geometryAPI = cc.v0.geometry;
|
|
233
|
+
const baseUtils = ccUtils.base;
|
|
234
|
+
const asmUtils = ccUtils.assembly;
|
|
235
|
+
const partUtils = ccUtils.part;
|
|
236
|
+
const publicApi = {
|
|
237
|
+
getDrawingId: () => drawingId,
|
|
238
|
+
getDrawing: () => getDrawing(drawingId),
|
|
239
|
+
getState: () => api.getState(),
|
|
240
|
+
setFacetingParameters: (distanceTol, angleTol) => this.resolve(async () => cc.v0.common.setFacetingParameters(distanceTol, angleTol)),
|
|
241
|
+
addInstances: async (...instances) => {
|
|
242
|
+
var e_1, _a;
|
|
243
|
+
const instancesToAdd = [];
|
|
244
|
+
try {
|
|
245
|
+
for (var instances_1 = __asyncValues(instances), instances_1_1; instances_1_1 = await instances_1.next(), !instances_1_1.done;) {
|
|
246
|
+
const instance = instances_1_1.value;
|
|
247
|
+
const [rProductId, rOwnerId] = await new Promise(res => this.resolve(id => res(id), instance.productId, instance.ownerId));
|
|
248
|
+
// Looking for the productId given by an identifier or name
|
|
249
|
+
// Priorities:
|
|
250
|
+
// 1. Look for the identifier then for the name in the part templates
|
|
251
|
+
// 2. Look for the identifier then for the name in the assembly templates
|
|
252
|
+
let product = rProductId;
|
|
253
|
+
if (typeof rProductId === 'string') {
|
|
254
|
+
let products = asmUtils.getPartTemplate(drawingId, rProductId);
|
|
255
|
+
if (products.length > 1) {
|
|
256
|
+
throw 'More than one product has been found for given name or ident: ' + rProductId;
|
|
257
|
+
}
|
|
258
|
+
else if (products.length < 1) {
|
|
259
|
+
products = asmUtils.getAssemblyTemplate(drawingId, rProductId);
|
|
260
|
+
if (products.length < 1) {
|
|
261
|
+
throw 'No product found for given name or ident: ' + rProductId;
|
|
262
|
+
}
|
|
263
|
+
else if (products.length > 1) {
|
|
264
|
+
throw 'More than one product has been found for given name or ident: ' + rProductId;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
product = products[0];
|
|
268
|
+
}
|
|
269
|
+
let owner = rOwnerId;
|
|
270
|
+
if (typeof rOwnerId === 'string') {
|
|
271
|
+
owner = baseUtils.findObject(drawingId, {
|
|
272
|
+
ident: rOwnerId,
|
|
273
|
+
name: rOwnerId,
|
|
274
|
+
});
|
|
275
|
+
if (!owner) {
|
|
276
|
+
throw 'The owner to add instances on given by name or ident "' + rOwnerId + '" does not exist.';
|
|
277
|
+
}
|
|
278
|
+
const clazz = getDrawing(drawingId).structure.tree[owner].class;
|
|
279
|
+
if (!baseUtils.isA(clazz, CCClasses.IProductReference) && !baseUtils.isA(clazz, CCClasses.CCAssembly)) {
|
|
280
|
+
throw ('The owner to add instances on given by name or ident "' +
|
|
281
|
+
rOwnerId +
|
|
282
|
+
'" is of the wrong type: "' +
|
|
283
|
+
clazz +
|
|
284
|
+
'". Make sure the owner is an instance, a root assembly or an assembly template.');
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const instanceParam = {
|
|
288
|
+
productId: product,
|
|
289
|
+
ownerId: owner,
|
|
290
|
+
transformation: instance.transformation,
|
|
291
|
+
name: instance.name,
|
|
292
|
+
options: Object.assign(Object.assign({}, instance.options), { isLocal: true }), // in non-interactive mode, the transformation is local to the owner
|
|
293
|
+
};
|
|
294
|
+
instancesToAdd.push(instanceParam);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
298
|
+
finally {
|
|
299
|
+
try {
|
|
300
|
+
if (instances_1_1 && !instances_1_1.done && (_a = instances_1.return)) await _a.call(instances_1);
|
|
301
|
+
}
|
|
302
|
+
finally { if (e_1) throw e_1.error; }
|
|
303
|
+
}
|
|
304
|
+
return assemblyBuilderAPI.addInstances(instancesToAdd);
|
|
305
|
+
},
|
|
306
|
+
addDimensions: async (...dimensions) => {
|
|
307
|
+
var e_2, _a;
|
|
308
|
+
const dimParamsToAdd = [];
|
|
309
|
+
try {
|
|
310
|
+
for (var dimensions_1 = __asyncValues(dimensions), dimensions_1_1; dimensions_1_1 = await dimensions_1.next(), !dimensions_1_1.done;) {
|
|
311
|
+
const dim = dimensions_1_1.value;
|
|
312
|
+
const [rProductId] = await new Promise(res => this.resolve(id => res(id), dim.productId));
|
|
313
|
+
switch (dim.param.type) {
|
|
314
|
+
case CCClasses.CCLinearDimension:
|
|
315
|
+
const linearDimParam = Object.assign(Object.assign({}, dim), { productId: rProductId, param: Object.assign(Object.assign({}, dim.param), { startPos: resolveVec(dim.param.startPos), endPos: resolveVec(dim.param.endPos), textPos: resolveVec(dim.param.textPos) }) });
|
|
316
|
+
dimParamsToAdd.push(linearDimParam);
|
|
317
|
+
break;
|
|
318
|
+
case CCClasses.CCRadialDimension:
|
|
319
|
+
const radialDimParam = Object.assign(Object.assign({}, dim), { productId: rProductId, param: Object.assign(Object.assign({}, dim.param), { centerPos: resolveVec(dim.param.centerPos), textPos: resolveVec(dim.param.textPos) }) });
|
|
320
|
+
dimParamsToAdd.push(radialDimParam);
|
|
321
|
+
break;
|
|
322
|
+
case CCClasses.CCDiameterDimension:
|
|
323
|
+
const diameterDimParam = Object.assign(Object.assign({}, dim), { productId: rProductId, param: Object.assign(Object.assign({}, dim.param), { centerPos: resolveVec(dim.param.centerPos), textPos: resolveVec(dim.param.textPos) }) });
|
|
324
|
+
dimParamsToAdd.push(diameterDimParam);
|
|
325
|
+
break;
|
|
326
|
+
case CCClasses.CCAngularDimension:
|
|
327
|
+
const angularDimParam = Object.assign(Object.assign({}, dim), { productId: rProductId, param: Object.assign(Object.assign({}, dim.param), { startPos: resolveVec(dim.param.startPos), endPos: resolveVec(dim.param.endPos), cornerPos: resolveVec(dim.param.cornerPos), textPos: resolveVec(dim.param.textPos) }) });
|
|
328
|
+
dimParamsToAdd.push(angularDimParam);
|
|
329
|
+
break;
|
|
330
|
+
default:
|
|
331
|
+
break;
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
336
|
+
finally {
|
|
337
|
+
try {
|
|
338
|
+
if (dimensions_1_1 && !dimensions_1_1.done && (_a = dimensions_1.return)) await _a.call(dimensions_1);
|
|
339
|
+
}
|
|
340
|
+
finally { if (e_2) throw e_2.error; }
|
|
341
|
+
}
|
|
342
|
+
return drawing2DAPI.addDimensions(dimParamsToAdd); // TODO v0 typescript error because of DimensionParam
|
|
343
|
+
},
|
|
344
|
+
create2DViews: (productId, viewTypes, viewOptions) => {
|
|
345
|
+
return this.resolve(async ([rProductId]) => {
|
|
346
|
+
const viewIds = await drawing2DAPI.create2DViews(rProductId, viewTypes, viewOptions);
|
|
347
|
+
if (viewIds !== null) {
|
|
348
|
+
await drawing2DAPI.centerAllViews(rProductId, viewTypes);
|
|
349
|
+
return viewIds;
|
|
350
|
+
}
|
|
351
|
+
return null;
|
|
352
|
+
}, productId);
|
|
353
|
+
},
|
|
354
|
+
getBoundaryBoxFromViews: (productId, viewTypes) => {
|
|
355
|
+
return this.resolve(async ([rProductId]) => {
|
|
356
|
+
const bbs = await drawing2DAPI.getBoundaryBoxFromViews(rProductId, viewTypes);
|
|
357
|
+
return bbs;
|
|
358
|
+
}, productId);
|
|
359
|
+
},
|
|
360
|
+
place2DViews: (productId, viewPositions) => {
|
|
361
|
+
return this.resolve(async ([rProductId]) => {
|
|
362
|
+
return drawing2DAPI.place2DViews(rProductId, viewPositions.map(({ viewType, vector }) => ({
|
|
363
|
+
viewType,
|
|
364
|
+
vector: resolveVec(vector),
|
|
365
|
+
})));
|
|
366
|
+
}, productId);
|
|
367
|
+
},
|
|
368
|
+
exportDXF: (productId, dxfTemplateFilename) => {
|
|
369
|
+
return this.resolve(async ([rProductId]) => {
|
|
370
|
+
return drawing2DAPI.exportDXF(rProductId, dxfTemplateFilename);
|
|
371
|
+
}, productId);
|
|
372
|
+
},
|
|
373
|
+
exportSVG: (productId, modus, renderSize, dxfTemplateFilename) => {
|
|
374
|
+
return this.resolve(async ([rProductId]) => {
|
|
375
|
+
modus = modus ? modus : SVGModusType.FIT_WHOLE_DRAWING;
|
|
376
|
+
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;
|
|
377
|
+
return drawing2DAPI.exportSVG(rProductId, modus, renderSizeParam, dxfTemplateFilename);
|
|
378
|
+
}, productId);
|
|
379
|
+
},
|
|
380
|
+
removeDimensions: (dimensionIds) => {
|
|
381
|
+
return this.resolve(async ([...rDimensionIds]) => {
|
|
382
|
+
return drawing2DAPI.removeDimensions(rDimensionIds);
|
|
383
|
+
}, ...dimensionIds);
|
|
384
|
+
},
|
|
385
|
+
linearPattern: (partId, operations, references1, params1, references2, params2) => {
|
|
386
|
+
return this.resolve(async ([rPartId, rOperations, rReferences1, rReferences2]) => {
|
|
387
|
+
const patternId = await featureAPI.createFeature(rPartId, CCClasses.CCLinearPattern, 'LinearPattern');
|
|
388
|
+
if (patternId != null) {
|
|
389
|
+
// entities
|
|
390
|
+
const cDrawing = await getDrawing(drawingId);
|
|
391
|
+
const entArray = [];
|
|
392
|
+
for (const rOperation of rOperations) {
|
|
393
|
+
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
394
|
+
if (entities != undefined) {
|
|
395
|
+
entArray.push(entities[0]);
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
const distance1Param = {
|
|
399
|
+
value: params1.distance,
|
|
400
|
+
isExpr: typeof params1.distance === 'string',
|
|
401
|
+
};
|
|
402
|
+
const count1Param = {
|
|
403
|
+
value: params1.count,
|
|
404
|
+
isExpr: typeof params1.count === 'string',
|
|
405
|
+
};
|
|
406
|
+
const params1Param = [
|
|
407
|
+
params1.inverted,
|
|
408
|
+
distance1Param,
|
|
409
|
+
count1Param,
|
|
410
|
+
params1.merged,
|
|
411
|
+
];
|
|
412
|
+
let params2Param = null;
|
|
413
|
+
if (params2) {
|
|
414
|
+
const distance2Param = {
|
|
415
|
+
value: params2.distance,
|
|
416
|
+
isExpr: typeof params2.distance === 'string',
|
|
417
|
+
};
|
|
418
|
+
const count2Param = {
|
|
419
|
+
value: params2.count,
|
|
420
|
+
isExpr: typeof params2.count === 'string',
|
|
421
|
+
};
|
|
422
|
+
params2Param = [params2.inverted, distance2Param, count2Param];
|
|
423
|
+
}
|
|
424
|
+
// resolve references1
|
|
425
|
+
const refs1 = [];
|
|
426
|
+
let refs2 = [];
|
|
427
|
+
for (const rRef1 of rReferences1) {
|
|
428
|
+
refs1.push(await rRef1);
|
|
429
|
+
}
|
|
430
|
+
// resolve references2 if present
|
|
431
|
+
if (rReferences2) {
|
|
432
|
+
for (const rRef2 of rReferences2) {
|
|
433
|
+
refs2.push(await rRef2);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
else {
|
|
437
|
+
refs2 = null;
|
|
438
|
+
}
|
|
439
|
+
await featureAPI.updatePattern(patternId, entArray, refs1, params1Param, refs2, params2Param);
|
|
440
|
+
return patternId;
|
|
441
|
+
}
|
|
442
|
+
return null;
|
|
443
|
+
}, partId, operations, references1, references2);
|
|
444
|
+
},
|
|
445
|
+
circularPattern: (partId, operations, references, params) => {
|
|
446
|
+
return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
|
|
447
|
+
const patternId = await featureAPI.createFeature(rPartId, CCClasses.CCCircularPattern, 'CircularPattern');
|
|
448
|
+
if (patternId != null) {
|
|
449
|
+
// entities
|
|
450
|
+
const cDrawing = await getDrawing(drawingId);
|
|
451
|
+
const entArray = [];
|
|
452
|
+
for (const rOperation of rOperations) {
|
|
453
|
+
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
454
|
+
if (entities != undefined) {
|
|
455
|
+
entArray.push(entities[0]);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
const angleParam = { value: params.angle, isExpr: typeof params.angle === 'string' };
|
|
459
|
+
const countParam = { value: params.count, isExpr: typeof params.count === 'string' };
|
|
460
|
+
const paramsParam = [
|
|
461
|
+
params.inverted,
|
|
462
|
+
angleParam,
|
|
463
|
+
countParam,
|
|
464
|
+
params.merged,
|
|
465
|
+
];
|
|
466
|
+
rReferences = Array.isArray(rReferences) ? rReferences : [rReferences];
|
|
467
|
+
await featureAPI.updatePattern(patternId, entArray, rReferences, paramsParam, null, null);
|
|
468
|
+
return patternId;
|
|
469
|
+
}
|
|
470
|
+
return null;
|
|
471
|
+
}, partId, operations, ...references);
|
|
472
|
+
},
|
|
473
|
+
extrusion: (partId, sketchOrRegionIds, type, limit1, limit2, taperAngle, direction, capEnds) => {
|
|
474
|
+
return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
|
|
475
|
+
const extrusion = await featureAPI.createFeature(rPartId, CCClasses.CCExtrusion, 'Extrusion');
|
|
476
|
+
if (extrusion) {
|
|
477
|
+
const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
|
|
478
|
+
? rSketchOrRegionIds
|
|
479
|
+
: [rSketchOrRegionIds];
|
|
480
|
+
if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
|
|
481
|
+
const limit1Param = { value: limit1, isExpr: typeof limit1 === 'string' };
|
|
482
|
+
const limit2Param = { value: limit2, isExpr: typeof limit2 === 'string' };
|
|
483
|
+
const taperAngleParam = {
|
|
484
|
+
value: taperAngle,
|
|
485
|
+
isExpr: typeof taperAngle === 'string',
|
|
486
|
+
};
|
|
487
|
+
const resDirection = resolveVec(direction);
|
|
488
|
+
const directionParam = {
|
|
489
|
+
value: resDirection,
|
|
490
|
+
isExpr: typeof resDirection === 'string',
|
|
491
|
+
};
|
|
492
|
+
await featureAPI.updateExtrusion(extrusion, resSketchOrRegionIds, type, limit1Param, limit2Param, taperAngleParam, directionParam, capEnds);
|
|
493
|
+
return extrusion;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}, partId, sketchOrRegionIds);
|
|
497
|
+
},
|
|
498
|
+
revolve: (partId, sketchOrRegionIds, axisIds, angle1, angle2, inverted) => {
|
|
499
|
+
return this.resolve(async ([rPartId, rSketchOrRegionIds, ...rAxisIds]) => {
|
|
500
|
+
const revolve = await featureAPI.createFeature(rPartId, CCClasses.CCRevolve, 'Revolve');
|
|
501
|
+
if (revolve) {
|
|
502
|
+
const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
|
|
503
|
+
? rSketchOrRegionIds
|
|
504
|
+
: [rSketchOrRegionIds];
|
|
505
|
+
if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
|
|
506
|
+
const angle1Param = { value: angle1, isExpr: typeof angle1 === 'string' };
|
|
507
|
+
const angle2Param = { value: angle2, isExpr: typeof angle2 === 'string' };
|
|
508
|
+
await featureAPI.updateRevolve(revolve, resSketchOrRegionIds, rAxisIds, angle1Param, angle2Param, inverted);
|
|
509
|
+
return revolve;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}, partId, sketchOrRegionIds, ...axisIds);
|
|
513
|
+
},
|
|
514
|
+
boolean: (partId, type, operations) => {
|
|
515
|
+
return this.resolve(async ([rPartId, rOperations]) => {
|
|
516
|
+
const cDrawing = await getDrawing(drawingId);
|
|
517
|
+
const entArray = [];
|
|
518
|
+
for (const rOperation of rOperations) {
|
|
519
|
+
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
520
|
+
if (entities != undefined) {
|
|
521
|
+
entArray.push(entities[0]);
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
const boolId = await featureAPI.createFeature(rPartId, CCClasses.CCUnion, 'Union');
|
|
525
|
+
if (boolId != null) {
|
|
526
|
+
await featureAPI.updateBooleanOperation(boolId, type, entArray);
|
|
527
|
+
return boolId;
|
|
528
|
+
}
|
|
529
|
+
return null;
|
|
530
|
+
}, partId, operations);
|
|
531
|
+
},
|
|
532
|
+
box: (partId, references, width, length, height) => {
|
|
533
|
+
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
534
|
+
const boxId = await featureAPI.createFeature(rPartId, CCClasses.CCBox, 'Box');
|
|
535
|
+
if (boxId != null) {
|
|
536
|
+
const widthParam = { value: width, isExpr: typeof width === 'string' };
|
|
537
|
+
const lengthParam = { value: length, isExpr: typeof length === 'string' };
|
|
538
|
+
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
539
|
+
await featureAPI.updateBox(boxId, rReferences, widthParam, lengthParam, heightParam);
|
|
540
|
+
return boxId;
|
|
541
|
+
}
|
|
542
|
+
return null;
|
|
543
|
+
}, partId, ...references);
|
|
544
|
+
},
|
|
545
|
+
cylinder: (partId, references, diameter, height) => {
|
|
546
|
+
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
547
|
+
const cylId = await featureAPI.createFeature(rPartId, CCClasses.CCCylinder, 'Cylinder');
|
|
548
|
+
if (cylId != null) {
|
|
549
|
+
const diameterParam = { value: diameter, isExpr: typeof diameter === 'string' };
|
|
550
|
+
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
551
|
+
await featureAPI.updateCylinder(cylId, rReferences, diameterParam, heightParam);
|
|
552
|
+
return cylId;
|
|
553
|
+
}
|
|
554
|
+
return null;
|
|
555
|
+
}, partId, ...references);
|
|
556
|
+
},
|
|
557
|
+
chamfer: (partId, type, references, dist1, dist2, angle) => {
|
|
558
|
+
return this.resolve(async ([rPartId, rReferences]) => {
|
|
559
|
+
const dist1Param = { value: dist1, isExpr: typeof dist1 === 'string' };
|
|
560
|
+
const dist2Param = { value: dist2, isExpr: typeof dist2 === 'string' };
|
|
561
|
+
const angleParam = { value: angle, isExpr: typeof angle === 'string' };
|
|
562
|
+
const chamferId = await featureAPI.createFeature(rPartId, CCClasses.CCChamfer, 'Chamfer');
|
|
563
|
+
if (chamferId != null) {
|
|
564
|
+
await featureAPI.updateChamfer(chamferId, type, rReferences, dist1Param, dist2Param, angleParam);
|
|
565
|
+
return chamferId;
|
|
566
|
+
}
|
|
567
|
+
return null;
|
|
568
|
+
}, partId, references);
|
|
569
|
+
},
|
|
570
|
+
cone: (partId, references, bDiameter, tDiameter, height) => {
|
|
571
|
+
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
572
|
+
const coneId = await featureAPI.createFeature(rPartId, CCClasses.CCCone, 'Cone');
|
|
573
|
+
if (coneId != null) {
|
|
574
|
+
const bDiamParam = { value: bDiameter, isExpr: typeof bDiameter === 'string' };
|
|
575
|
+
const tDiamParam = { value: tDiameter, isExpr: typeof tDiameter === 'string' };
|
|
576
|
+
const heightParam = { value: height, isExpr: typeof height === 'string' };
|
|
577
|
+
await featureAPI.updateCone(coneId, rReferences, bDiamParam, tDiamParam, heightParam);
|
|
578
|
+
return coneId;
|
|
579
|
+
}
|
|
580
|
+
return null;
|
|
581
|
+
}, partId, ...references);
|
|
582
|
+
},
|
|
583
|
+
createFastenedConstraint: async (id, mate1, mate2, xOffset, yOffset, zOffset, name, xRotation, yRotation, zRotation) => {
|
|
584
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
585
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
586
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
587
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCFastenedConstraint, name);
|
|
588
|
+
if (constraintId != null) {
|
|
589
|
+
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
590
|
+
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
591
|
+
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
592
|
+
const xRotationParam = { value: xRotation || 0, isExpr: typeof xRotation === 'string' };
|
|
593
|
+
const yRotationParam = { value: yRotation || 0, isExpr: typeof yRotation === 'string' };
|
|
594
|
+
const zRotationParam = { value: zRotation || 0, isExpr: typeof zRotation === 'string' };
|
|
595
|
+
await assemblyBuilderAPI.updateFastenedConstraints([
|
|
596
|
+
{
|
|
597
|
+
constrId: constraintId,
|
|
598
|
+
mate1: { matePath: rMatePath1, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented },
|
|
599
|
+
mate2: { matePath: rMatePath2, wcsId: rWcs2, flip: mate2.flip, reoriented: mate2.reoriented },
|
|
600
|
+
xOffset: xOffsetParam,
|
|
601
|
+
yOffset: yOffsetParam,
|
|
602
|
+
zOffset: zOffsetParam,
|
|
603
|
+
xRotation: xRotationParam,
|
|
604
|
+
yRotation: yRotationParam,
|
|
605
|
+
zRotation: zRotationParam,
|
|
606
|
+
},
|
|
607
|
+
]);
|
|
608
|
+
return constraintId;
|
|
609
|
+
}
|
|
610
|
+
return null;
|
|
611
|
+
},
|
|
612
|
+
updateFastenedConstraints: async (...constraints) => {
|
|
613
|
+
var e_3, _a;
|
|
614
|
+
const constrToAdd = [];
|
|
615
|
+
try {
|
|
616
|
+
for (var constraints_1 = __asyncValues(constraints), constraints_1_1; constraints_1_1 = await constraints_1.next(), !constraints_1_1.done;) {
|
|
617
|
+
const constr = constraints_1_1.value;
|
|
618
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
619
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
620
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
621
|
+
const xOffsetParam = { value: constr.xOffset, isExpr: typeof constr.xOffset === 'string' };
|
|
622
|
+
const yOffsetParam = { value: constr.yOffset, isExpr: typeof constr.yOffset === 'string' };
|
|
623
|
+
const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
|
|
624
|
+
const xRotationParam = {
|
|
625
|
+
value: constr.xRotation || 0,
|
|
626
|
+
isExpr: typeof constr.xRotation === 'string',
|
|
627
|
+
};
|
|
628
|
+
const yRotationParam = {
|
|
629
|
+
value: constr.yRotation || 0,
|
|
630
|
+
isExpr: typeof constr.yRotation === 'string',
|
|
631
|
+
};
|
|
632
|
+
const zRotationParam = {
|
|
633
|
+
value: constr.zRotation || 0,
|
|
634
|
+
isExpr: typeof constr.zRotation === 'string',
|
|
635
|
+
};
|
|
636
|
+
constrToAdd.push({
|
|
637
|
+
constrId: rConstrId,
|
|
638
|
+
mate1: {
|
|
639
|
+
matePath: rMatePath1,
|
|
640
|
+
wcsId: rWcs1,
|
|
641
|
+
flip: constr.mate1.flip,
|
|
642
|
+
reoriented: constr.mate1.reoriented,
|
|
643
|
+
},
|
|
644
|
+
mate2: {
|
|
645
|
+
matePath: rMatePath2,
|
|
646
|
+
wcsId: rWcs2,
|
|
647
|
+
flip: constr.mate2.flip,
|
|
648
|
+
reoriented: constr.mate2.reoriented,
|
|
649
|
+
},
|
|
650
|
+
xOffset: xOffsetParam,
|
|
651
|
+
yOffset: yOffsetParam,
|
|
652
|
+
zOffset: zOffsetParam,
|
|
653
|
+
xRotation: xRotationParam,
|
|
654
|
+
yRotation: yRotationParam,
|
|
655
|
+
zRotation: zRotationParam,
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
660
|
+
finally {
|
|
661
|
+
try {
|
|
662
|
+
if (constraints_1_1 && !constraints_1_1.done && (_a = constraints_1.return)) await _a.call(constraints_1);
|
|
663
|
+
}
|
|
664
|
+
finally { if (e_3) throw e_3.error; }
|
|
665
|
+
}
|
|
666
|
+
await assemblyBuilderAPI.updateFastenedConstraints(constrToAdd);
|
|
667
|
+
},
|
|
668
|
+
createFastenedOriginConstraint: async (id, mate1, xOffset, yOffset, zOffset, name, xRotation, yRotation, zRotation) => {
|
|
669
|
+
const [rId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId));
|
|
670
|
+
const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
671
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCFastenedOriginConstraint, name);
|
|
672
|
+
if (constraintId != null) {
|
|
673
|
+
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
674
|
+
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
675
|
+
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
676
|
+
const xRotationParam = { value: xRotation || 0, isExpr: typeof xRotation === 'string' };
|
|
677
|
+
const yRotationParam = { value: yRotation || 0, isExpr: typeof yRotation === 'string' };
|
|
678
|
+
const zRotationParam = { value: zRotation || 0, isExpr: typeof zRotation === 'string' };
|
|
679
|
+
await assemblyBuilderAPI.updateFastenedOriginConstraints([
|
|
680
|
+
{
|
|
681
|
+
constrId: constraintId,
|
|
682
|
+
mate1: { matePath: rMatePath, wcsId: rWcs1, flip: mate1.flip, reoriented: mate1.reoriented },
|
|
683
|
+
xOffset: xOffsetParam,
|
|
684
|
+
yOffset: yOffsetParam,
|
|
685
|
+
zOffset: zOffsetParam,
|
|
686
|
+
xRotation: xRotationParam,
|
|
687
|
+
yRotation: yRotationParam,
|
|
688
|
+
zRotation: zRotationParam,
|
|
689
|
+
},
|
|
690
|
+
]);
|
|
691
|
+
return constraintId;
|
|
692
|
+
}
|
|
693
|
+
return null;
|
|
694
|
+
},
|
|
695
|
+
updateFastenedOriginConstraints: async (...constraints) => {
|
|
696
|
+
var e_4, _a;
|
|
697
|
+
const constraintsToAdd = [];
|
|
698
|
+
try {
|
|
699
|
+
for (var constraints_2 = __asyncValues(constraints), constraints_2_1; constraints_2_1 = await constraints_2.next(), !constraints_2_1.done;) {
|
|
700
|
+
const constr = constraints_2_1.value;
|
|
701
|
+
const [rConstrId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId));
|
|
702
|
+
const rMatePath = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
703
|
+
const xOffsetParam = { value: constr.xOffset, isExpr: typeof constr.xOffset === 'string' };
|
|
704
|
+
const yOffsetParam = { value: constr.yOffset, isExpr: typeof constr.yOffset === 'string' };
|
|
705
|
+
const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
|
|
706
|
+
const xRotationParam = {
|
|
707
|
+
value: constr.xRotation || 0,
|
|
708
|
+
isExpr: typeof constr.xRotation === 'string',
|
|
709
|
+
};
|
|
710
|
+
const yRotationParam = {
|
|
711
|
+
value: constr.yRotation || 0,
|
|
712
|
+
isExpr: typeof constr.yRotation === 'string',
|
|
713
|
+
};
|
|
714
|
+
const zRotationParam = {
|
|
715
|
+
value: constr.zRotation || 0,
|
|
716
|
+
isExpr: typeof constr.zRotation === 'string',
|
|
717
|
+
};
|
|
718
|
+
constraintsToAdd.push({
|
|
719
|
+
constrId: rConstrId,
|
|
720
|
+
mate1: {
|
|
721
|
+
matePath: rMatePath,
|
|
722
|
+
wcsId: rWcs1,
|
|
723
|
+
flip: constr.mate1.flip,
|
|
724
|
+
reoriented: constr.mate1.reoriented,
|
|
725
|
+
},
|
|
726
|
+
xOffset: xOffsetParam,
|
|
727
|
+
yOffset: yOffsetParam,
|
|
728
|
+
zOffset: zOffsetParam,
|
|
729
|
+
xRotation: xRotationParam,
|
|
730
|
+
yRotation: yRotationParam,
|
|
731
|
+
zRotation: zRotationParam,
|
|
732
|
+
});
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
736
|
+
finally {
|
|
737
|
+
try {
|
|
738
|
+
if (constraints_2_1 && !constraints_2_1.done && (_a = constraints_2.return)) await _a.call(constraints_2);
|
|
739
|
+
}
|
|
740
|
+
finally { if (e_4) throw e_4.error; }
|
|
741
|
+
}
|
|
742
|
+
await assemblyBuilderAPI.updateFastenedOriginConstraints(constraintsToAdd);
|
|
743
|
+
},
|
|
744
|
+
createCylindricalConstraint: async (id, mate1, mate2, zOffsetLimits, zRotationLimits, name) => {
|
|
745
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
746
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
747
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
748
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCCylindricalConstraint, name);
|
|
749
|
+
if (constraintId != null) {
|
|
750
|
+
await assemblyBuilderAPI.updateCylindricalConstraints([
|
|
751
|
+
{
|
|
752
|
+
constrId: constraintId,
|
|
753
|
+
mate1: {
|
|
754
|
+
matePath: rMatePath1,
|
|
755
|
+
wcsId: rWcs1,
|
|
756
|
+
flip: mate1.flip,
|
|
757
|
+
reoriented: mate1.reoriented,
|
|
758
|
+
},
|
|
759
|
+
mate2: {
|
|
760
|
+
matePath: rMatePath2,
|
|
761
|
+
wcsId: rWcs2,
|
|
762
|
+
flip: mate2.flip,
|
|
763
|
+
reoriented: mate2.reoriented,
|
|
764
|
+
},
|
|
765
|
+
zOffsetLimits,
|
|
766
|
+
zRotationLimits,
|
|
767
|
+
},
|
|
768
|
+
]);
|
|
769
|
+
return constraintId;
|
|
770
|
+
}
|
|
771
|
+
return null;
|
|
772
|
+
},
|
|
773
|
+
updateCylindricalConstraints: async (...constraints) => {
|
|
774
|
+
var e_5, _a;
|
|
775
|
+
const constrToAdd = [];
|
|
776
|
+
try {
|
|
777
|
+
for (var constraints_3 = __asyncValues(constraints), constraints_3_1; constraints_3_1 = await constraints_3.next(), !constraints_3_1.done;) {
|
|
778
|
+
const constr = constraints_3_1.value;
|
|
779
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
780
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
781
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
782
|
+
constrToAdd.push({
|
|
783
|
+
constrId: rConstrId,
|
|
784
|
+
mate1: {
|
|
785
|
+
matePath: rMatePath1,
|
|
786
|
+
wcsId: rWcs1,
|
|
787
|
+
flip: constr.mate1.flip,
|
|
788
|
+
reoriented: constr.mate1.reoriented,
|
|
789
|
+
},
|
|
790
|
+
mate2: {
|
|
791
|
+
matePath: rMatePath2,
|
|
792
|
+
wcsId: rWcs2,
|
|
793
|
+
flip: constr.mate2.flip,
|
|
794
|
+
reoriented: constr.mate2.reoriented,
|
|
795
|
+
},
|
|
796
|
+
zOffsetLimits: constr.zOffsetLimits,
|
|
797
|
+
zRotationLimits: constr.zRotationLimits,
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
802
|
+
finally {
|
|
803
|
+
try {
|
|
804
|
+
if (constraints_3_1 && !constraints_3_1.done && (_a = constraints_3.return)) await _a.call(constraints_3);
|
|
805
|
+
}
|
|
806
|
+
finally { if (e_5) throw e_5.error; }
|
|
807
|
+
}
|
|
808
|
+
await assemblyBuilderAPI.updateCylindricalConstraints(constrToAdd);
|
|
809
|
+
},
|
|
810
|
+
createRevoluteConstraint: async (id, mate1, mate2, zOffset, zRotationLimits, name) => {
|
|
811
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
812
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
813
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
814
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCRevoluteConstraint, name);
|
|
815
|
+
if (constraintId != null) {
|
|
816
|
+
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
817
|
+
await assemblyBuilderAPI.updateRevoluteConstraints([
|
|
818
|
+
{
|
|
819
|
+
constrId: constraintId,
|
|
820
|
+
mate1: {
|
|
821
|
+
matePath: rMatePath1,
|
|
822
|
+
wcsId: rWcs1,
|
|
823
|
+
flip: mate1.flip,
|
|
824
|
+
reoriented: mate1.reoriented,
|
|
825
|
+
},
|
|
826
|
+
mate2: {
|
|
827
|
+
matePath: rMatePath2,
|
|
828
|
+
wcsId: rWcs2,
|
|
829
|
+
flip: mate2.flip,
|
|
830
|
+
reoriented: mate2.reoriented,
|
|
831
|
+
},
|
|
832
|
+
zOffset: zOffsetParam,
|
|
833
|
+
zRotationLimits,
|
|
834
|
+
},
|
|
835
|
+
]);
|
|
836
|
+
return constraintId;
|
|
837
|
+
}
|
|
838
|
+
return null;
|
|
839
|
+
},
|
|
840
|
+
updateRevoluteConstraints: async (...constraints) => {
|
|
841
|
+
var e_6, _a;
|
|
842
|
+
const constrToAdd = [];
|
|
843
|
+
try {
|
|
844
|
+
for (var constraints_4 = __asyncValues(constraints), constraints_4_1; constraints_4_1 = await constraints_4.next(), !constraints_4_1.done;) {
|
|
845
|
+
const constr = constraints_4_1.value;
|
|
846
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
847
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
848
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
849
|
+
const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
|
|
850
|
+
constrToAdd.push({
|
|
851
|
+
constrId: rConstrId,
|
|
852
|
+
mate1: {
|
|
853
|
+
matePath: rMatePath1,
|
|
854
|
+
wcsId: rWcs1,
|
|
855
|
+
flip: constr.mate1.flip,
|
|
856
|
+
reoriented: constr.mate1.reoriented,
|
|
857
|
+
},
|
|
858
|
+
mate2: {
|
|
859
|
+
matePath: rMatePath2,
|
|
860
|
+
wcsId: rWcs2,
|
|
861
|
+
flip: constr.mate2.flip,
|
|
862
|
+
reoriented: constr.mate2.reoriented,
|
|
863
|
+
},
|
|
864
|
+
zOffset: zOffsetParam,
|
|
865
|
+
zRotationLimits: constr.zRotationLimits,
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
}
|
|
869
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
870
|
+
finally {
|
|
871
|
+
try {
|
|
872
|
+
if (constraints_4_1 && !constraints_4_1.done && (_a = constraints_4.return)) await _a.call(constraints_4);
|
|
873
|
+
}
|
|
874
|
+
finally { if (e_6) throw e_6.error; }
|
|
875
|
+
}
|
|
876
|
+
await assemblyBuilderAPI.updateRevoluteConstraints(constrToAdd);
|
|
877
|
+
},
|
|
878
|
+
createSliderConstraint: async (id, mate1, mate2, xOffset, yOffset, zOffsetLimits, name) => {
|
|
879
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
880
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
881
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
882
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCSliderConstraint, name);
|
|
883
|
+
if (constraintId != null) {
|
|
884
|
+
const xOffsetParam = { value: xOffset, isExpr: typeof xOffset === 'string' };
|
|
885
|
+
const yOffsetParam = { value: yOffset, isExpr: typeof yOffset === 'string' };
|
|
886
|
+
await assemblyBuilderAPI.updateSliderConstraints([
|
|
887
|
+
{
|
|
888
|
+
constrId: constraintId,
|
|
889
|
+
mate1: {
|
|
890
|
+
matePath: rMatePath1,
|
|
891
|
+
wcsId: rWcs1,
|
|
892
|
+
flip: mate1.flip,
|
|
893
|
+
reoriented: mate1.reoriented,
|
|
894
|
+
},
|
|
895
|
+
mate2: {
|
|
896
|
+
matePath: rMatePath2,
|
|
897
|
+
wcsId: rWcs2,
|
|
898
|
+
flip: mate2.flip,
|
|
899
|
+
reoriented: mate2.reoriented,
|
|
900
|
+
},
|
|
901
|
+
xOffset: xOffsetParam,
|
|
902
|
+
yOffset: yOffsetParam,
|
|
903
|
+
zOffsetLimits,
|
|
904
|
+
},
|
|
905
|
+
]);
|
|
906
|
+
return constraintId;
|
|
907
|
+
}
|
|
908
|
+
return null;
|
|
909
|
+
},
|
|
910
|
+
updateSliderConstraints: async (...constraints) => {
|
|
911
|
+
var e_7, _a;
|
|
912
|
+
const constrToAdd = [];
|
|
913
|
+
try {
|
|
914
|
+
for (var constraints_5 = __asyncValues(constraints), constraints_5_1; constraints_5_1 = await constraints_5.next(), !constraints_5_1.done;) {
|
|
915
|
+
const constr = constraints_5_1.value;
|
|
916
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
917
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
918
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
919
|
+
const xOffsetParam = { value: constr.xOffset, isExpr: typeof constr.xOffset === 'string' };
|
|
920
|
+
const yOffsetParam = { value: constr.yOffset, isExpr: typeof constr.yOffset === 'string' };
|
|
921
|
+
constrToAdd.push({
|
|
922
|
+
constrId: rConstrId,
|
|
923
|
+
mate1: {
|
|
924
|
+
matePath: rMatePath1,
|
|
925
|
+
wcsId: rWcs1,
|
|
926
|
+
flip: constr.mate1.flip,
|
|
927
|
+
reoriented: constr.mate1.reoriented,
|
|
928
|
+
},
|
|
929
|
+
mate2: {
|
|
930
|
+
matePath: rMatePath2,
|
|
931
|
+
wcsId: rWcs2,
|
|
932
|
+
flip: constr.mate2.flip,
|
|
933
|
+
reoriented: constr.mate2.reoriented,
|
|
934
|
+
},
|
|
935
|
+
xOffset: xOffsetParam,
|
|
936
|
+
yOffset: yOffsetParam,
|
|
937
|
+
zOffsetLimits: constr.zOffsetLimits,
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
942
|
+
finally {
|
|
943
|
+
try {
|
|
944
|
+
if (constraints_5_1 && !constraints_5_1.done && (_a = constraints_5.return)) await _a.call(constraints_5);
|
|
945
|
+
}
|
|
946
|
+
finally { if (e_7) throw e_7.error; }
|
|
947
|
+
}
|
|
948
|
+
await assemblyBuilderAPI.updateSliderConstraints(constrToAdd);
|
|
949
|
+
},
|
|
950
|
+
createPlanarConstraint: async (id, mate1, mate2, zOffset, xOffsetLimits, yOffsetLimits, zRotationLimits, name) => {
|
|
951
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
952
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
953
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
954
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCPlanarConstraint, name);
|
|
955
|
+
if (constraintId != null) {
|
|
956
|
+
const zOffsetParam = { value: zOffset, isExpr: typeof zOffset === 'string' };
|
|
957
|
+
await assemblyBuilderAPI.updatePlanarConstraints([
|
|
958
|
+
{
|
|
959
|
+
constrId: constraintId,
|
|
960
|
+
mate1: {
|
|
961
|
+
matePath: rMatePath1,
|
|
962
|
+
wcsId: rWcs1,
|
|
963
|
+
flip: mate1.flip,
|
|
964
|
+
reoriented: mate1.reoriented,
|
|
965
|
+
},
|
|
966
|
+
mate2: {
|
|
967
|
+
matePath: rMatePath2,
|
|
968
|
+
wcsId: rWcs2,
|
|
969
|
+
flip: mate2.flip,
|
|
970
|
+
reoriented: mate2.reoriented,
|
|
971
|
+
},
|
|
972
|
+
zOffset: zOffsetParam,
|
|
973
|
+
xOffsetLimits,
|
|
974
|
+
yOffsetLimits,
|
|
975
|
+
zRotationLimits,
|
|
976
|
+
},
|
|
977
|
+
]);
|
|
978
|
+
return constraintId;
|
|
979
|
+
}
|
|
980
|
+
return null;
|
|
981
|
+
},
|
|
982
|
+
updatePlanarConstraints: async (...constraints) => {
|
|
983
|
+
var e_8, _a;
|
|
984
|
+
const constrToAdd = [];
|
|
985
|
+
try {
|
|
986
|
+
for (var constraints_6 = __asyncValues(constraints), constraints_6_1; constraints_6_1 = await constraints_6.next(), !constraints_6_1.done;) {
|
|
987
|
+
const constr = constraints_6_1.value;
|
|
988
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
989
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
990
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
991
|
+
const zOffsetParam = { value: constr.zOffset, isExpr: typeof constr.zOffset === 'string' };
|
|
992
|
+
constrToAdd.push({
|
|
993
|
+
constrId: rConstrId,
|
|
994
|
+
mate1: {
|
|
995
|
+
matePath: rMatePath1,
|
|
996
|
+
wcsId: rWcs1,
|
|
997
|
+
flip: constr.mate1.flip,
|
|
998
|
+
reoriented: constr.mate1.reoriented,
|
|
999
|
+
},
|
|
1000
|
+
mate2: {
|
|
1001
|
+
matePath: rMatePath2,
|
|
1002
|
+
wcsId: rWcs2,
|
|
1003
|
+
flip: constr.mate2.flip,
|
|
1004
|
+
reoriented: constr.mate2.reoriented,
|
|
1005
|
+
},
|
|
1006
|
+
zOffset: zOffsetParam,
|
|
1007
|
+
xOffsetLimits: constr.xOffsetLimits,
|
|
1008
|
+
yOffsetLimits: constr.yOffsetLimits,
|
|
1009
|
+
zRotationLimits: constr.zRotationLimits,
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
1014
|
+
finally {
|
|
1015
|
+
try {
|
|
1016
|
+
if (constraints_6_1 && !constraints_6_1.done && (_a = constraints_6.return)) await _a.call(constraints_6);
|
|
1017
|
+
}
|
|
1018
|
+
finally { if (e_8) throw e_8.error; }
|
|
1019
|
+
}
|
|
1020
|
+
await assemblyBuilderAPI.updatePlanarConstraints(constrToAdd);
|
|
1021
|
+
},
|
|
1022
|
+
createParallelConstraint: async (id, mate1, mate2, xOffsetLimits, yOffsetLimits, zOffsetLimits, zRotationLimits, name) => {
|
|
1023
|
+
const [rId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, mate1.wcsId, mate2.wcsId));
|
|
1024
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
1025
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
1026
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCParallelConstraint, name);
|
|
1027
|
+
if (constraintId != null) {
|
|
1028
|
+
await assemblyBuilderAPI.updateParallelConstraints([
|
|
1029
|
+
{
|
|
1030
|
+
constrId: constraintId,
|
|
1031
|
+
mate1: {
|
|
1032
|
+
matePath: rMatePath1,
|
|
1033
|
+
wcsId: rWcs1,
|
|
1034
|
+
flip: mate1.flip,
|
|
1035
|
+
reoriented: mate1.reoriented,
|
|
1036
|
+
},
|
|
1037
|
+
mate2: {
|
|
1038
|
+
matePath: rMatePath2,
|
|
1039
|
+
wcsId: rWcs2,
|
|
1040
|
+
flip: mate2.flip,
|
|
1041
|
+
reoriented: mate2.reoriented,
|
|
1042
|
+
},
|
|
1043
|
+
xOffsetLimits,
|
|
1044
|
+
yOffsetLimits,
|
|
1045
|
+
zOffsetLimits,
|
|
1046
|
+
zRotationLimits,
|
|
1047
|
+
},
|
|
1048
|
+
]);
|
|
1049
|
+
return constraintId;
|
|
1050
|
+
}
|
|
1051
|
+
return null;
|
|
1052
|
+
},
|
|
1053
|
+
updateParallelConstraints: async (...constraints) => {
|
|
1054
|
+
var e_9, _a;
|
|
1055
|
+
const constrToAdd = [];
|
|
1056
|
+
try {
|
|
1057
|
+
for (var constraints_7 = __asyncValues(constraints), constraints_7_1; constraints_7_1 = await constraints_7.next(), !constraints_7_1.done;) {
|
|
1058
|
+
const constr = constraints_7_1.value;
|
|
1059
|
+
const [rConstrId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.mate1.wcsId, constr.mate2.wcsId));
|
|
1060
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
1061
|
+
const rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
1062
|
+
constrToAdd.push({
|
|
1063
|
+
constrId: rConstrId,
|
|
1064
|
+
mate1: {
|
|
1065
|
+
matePath: rMatePath1,
|
|
1066
|
+
wcsId: rWcs1,
|
|
1067
|
+
flip: constr.mate1.flip,
|
|
1068
|
+
reoriented: constr.mate1.reoriented,
|
|
1069
|
+
},
|
|
1070
|
+
mate2: {
|
|
1071
|
+
matePath: rMatePath2,
|
|
1072
|
+
wcsId: rWcs2,
|
|
1073
|
+
flip: constr.mate2.flip,
|
|
1074
|
+
reoriented: constr.mate2.reoriented,
|
|
1075
|
+
},
|
|
1076
|
+
xOffsetLimits: constr.xOffsetLimits,
|
|
1077
|
+
yOffsetLimits: constr.yOffsetLimits,
|
|
1078
|
+
zOffsetLimits: constr.zOffsetLimits,
|
|
1079
|
+
zRotationLimits: constr.zRotationLimits,
|
|
1080
|
+
});
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
1084
|
+
finally {
|
|
1085
|
+
try {
|
|
1086
|
+
if (constraints_7_1 && !constraints_7_1.done && (_a = constraints_7.return)) await _a.call(constraints_7);
|
|
1087
|
+
}
|
|
1088
|
+
finally { if (e_9) throw e_9.error; }
|
|
1089
|
+
}
|
|
1090
|
+
await assemblyBuilderAPI.updateParallelConstraints(constrToAdd);
|
|
1091
|
+
},
|
|
1092
|
+
createGroupConstraint: async (id, instanceIds, name) => {
|
|
1093
|
+
const [rId] = await new Promise(res => this.resolve(ids => res(ids), id));
|
|
1094
|
+
const rInstanceIds = await new Promise(res => this.resolve(paths => res(paths), ...instanceIds));
|
|
1095
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCGroupConstraint, name);
|
|
1096
|
+
if (constraintId != null) {
|
|
1097
|
+
await assemblyBuilderAPI.updateGroupConstraints([
|
|
1098
|
+
{
|
|
1099
|
+
constrId: constraintId,
|
|
1100
|
+
instanceIds: rInstanceIds,
|
|
1101
|
+
},
|
|
1102
|
+
]);
|
|
1103
|
+
return constraintId;
|
|
1104
|
+
}
|
|
1105
|
+
return null;
|
|
1106
|
+
},
|
|
1107
|
+
updateGroupConstraints: async (...constraints) => {
|
|
1108
|
+
var e_10, _a;
|
|
1109
|
+
const constrToAdd = [];
|
|
1110
|
+
try {
|
|
1111
|
+
for (var constraints_8 = __asyncValues(constraints), constraints_8_1; constraints_8_1 = await constraints_8.next(), !constraints_8_1.done;) {
|
|
1112
|
+
const constr = constraints_8_1.value;
|
|
1113
|
+
const [rConstrId] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId));
|
|
1114
|
+
const rInstanceIds = await new Promise(res => this.resolve(paths => res(paths), ...constr.instanceIds));
|
|
1115
|
+
constrToAdd.push({
|
|
1116
|
+
constrId: rConstrId,
|
|
1117
|
+
instanceIds: rInstanceIds,
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
1122
|
+
finally {
|
|
1123
|
+
try {
|
|
1124
|
+
if (constraints_8_1 && !constraints_8_1.done && (_a = constraints_8.return)) await _a.call(constraints_8);
|
|
1125
|
+
}
|
|
1126
|
+
finally { if (e_10) throw e_10.error; }
|
|
1127
|
+
}
|
|
1128
|
+
await assemblyBuilderAPI.updateGroupConstraints(constrToAdd);
|
|
1129
|
+
},
|
|
1130
|
+
createLinearPatternConstraint: async (id, instanceId, mate1, firstDirInstanceCount, firstDirDistance, name, mate2, secondDirInstanceCount, secondDirDistance) => {
|
|
1131
|
+
const [rId, rInstanceId, rWcs1, rWcs2] = await new Promise(res => this.resolve(ids => res(ids), id, instanceId, mate1.wcsId, mate2 === null || mate2 === void 0 ? void 0 : mate2.wcsId));
|
|
1132
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
1133
|
+
let rMatePath2;
|
|
1134
|
+
if (mate2) {
|
|
1135
|
+
rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...mate2.matePath));
|
|
1136
|
+
}
|
|
1137
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCLinearPatternConstraint, name);
|
|
1138
|
+
if (constraintId != null) {
|
|
1139
|
+
const firstDirInstanceCountParam = {
|
|
1140
|
+
value: firstDirInstanceCount,
|
|
1141
|
+
isExpr: typeof firstDirInstanceCount === 'string',
|
|
1142
|
+
};
|
|
1143
|
+
const firstDirDistanceParam = {
|
|
1144
|
+
value: firstDirDistance,
|
|
1145
|
+
isExpr: typeof firstDirDistance === 'string',
|
|
1146
|
+
};
|
|
1147
|
+
const secondDirInstanceCountParam = secondDirInstanceCount !== undefined
|
|
1148
|
+
? {
|
|
1149
|
+
value: secondDirInstanceCount,
|
|
1150
|
+
isExpr: typeof secondDirInstanceCount === 'string',
|
|
1151
|
+
}
|
|
1152
|
+
: undefined;
|
|
1153
|
+
const secondDirDistanceParam = secondDirDistance !== undefined
|
|
1154
|
+
? {
|
|
1155
|
+
value: secondDirDistance,
|
|
1156
|
+
isExpr: typeof secondDirDistance === 'string',
|
|
1157
|
+
}
|
|
1158
|
+
: undefined;
|
|
1159
|
+
await assemblyBuilderAPI.updateLinearPatternConstraints([
|
|
1160
|
+
{
|
|
1161
|
+
constrId: constraintId,
|
|
1162
|
+
instanceId: rInstanceId,
|
|
1163
|
+
mate1: {
|
|
1164
|
+
matePath: rMatePath1,
|
|
1165
|
+
wcsId: rWcs1,
|
|
1166
|
+
flip: mate1.flip,
|
|
1167
|
+
reoriented: mate1.reoriented,
|
|
1168
|
+
},
|
|
1169
|
+
firstDirInstanceCount: firstDirInstanceCountParam,
|
|
1170
|
+
firstDirDistance: firstDirDistanceParam,
|
|
1171
|
+
mate2: mate2
|
|
1172
|
+
? {
|
|
1173
|
+
matePath: rMatePath2,
|
|
1174
|
+
wcsId: rWcs2,
|
|
1175
|
+
flip: mate2.flip,
|
|
1176
|
+
reoriented: mate2.reoriented,
|
|
1177
|
+
}
|
|
1178
|
+
: undefined,
|
|
1179
|
+
secondDirInstanceCount: secondDirInstanceCountParam,
|
|
1180
|
+
secondDirDistance: secondDirDistanceParam,
|
|
1181
|
+
},
|
|
1182
|
+
]);
|
|
1183
|
+
return constraintId;
|
|
1184
|
+
}
|
|
1185
|
+
return null;
|
|
1186
|
+
},
|
|
1187
|
+
updateLinearPatternConstraints: async (...constraints) => {
|
|
1188
|
+
var e_11, _a;
|
|
1189
|
+
const constrToAdd = [];
|
|
1190
|
+
try {
|
|
1191
|
+
for (var constraints_9 = __asyncValues(constraints), constraints_9_1; constraints_9_1 = await constraints_9.next(), !constraints_9_1.done;) {
|
|
1192
|
+
const constr = constraints_9_1.value;
|
|
1193
|
+
const [rConstrId, rInstanceId, rWcs1, rWcs2] = await new Promise(res => {
|
|
1194
|
+
var _a;
|
|
1195
|
+
return this.resolve(ids => res(ids), constr.constrId, constr.instanceId, constr.mate1.wcsId, (_a = constr.mate2) === null || _a === void 0 ? void 0 : _a.wcsId);
|
|
1196
|
+
});
|
|
1197
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
1198
|
+
let rMatePath2;
|
|
1199
|
+
if (constr.mate2) {
|
|
1200
|
+
rMatePath2 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate2.matePath));
|
|
1201
|
+
}
|
|
1202
|
+
const firstDirInstanceCountParam = {
|
|
1203
|
+
value: constr.firstDirInstanceCount,
|
|
1204
|
+
isExpr: typeof constr.firstDirInstanceCount === 'string',
|
|
1205
|
+
};
|
|
1206
|
+
const firstDirDistanceParam = {
|
|
1207
|
+
value: constr.firstDirDistance,
|
|
1208
|
+
isExpr: typeof constr.firstDirDistance === 'string',
|
|
1209
|
+
};
|
|
1210
|
+
const secondDirInstanceCountParam = constr.secondDirInstanceCount !== undefined
|
|
1211
|
+
? {
|
|
1212
|
+
value: constr.secondDirInstanceCount,
|
|
1213
|
+
isExpr: typeof constr.secondDirInstanceCount === 'string',
|
|
1214
|
+
}
|
|
1215
|
+
: undefined;
|
|
1216
|
+
const secondDirDistanceParam = constr.secondDirDistance !== undefined
|
|
1217
|
+
? {
|
|
1218
|
+
value: constr.secondDirDistance,
|
|
1219
|
+
isExpr: typeof constr.secondDirDistance === 'string',
|
|
1220
|
+
}
|
|
1221
|
+
: undefined;
|
|
1222
|
+
constrToAdd.push({
|
|
1223
|
+
constrId: rConstrId,
|
|
1224
|
+
instanceId: rInstanceId,
|
|
1225
|
+
mate1: {
|
|
1226
|
+
matePath: rMatePath1,
|
|
1227
|
+
wcsId: rWcs1,
|
|
1228
|
+
flip: constr.mate1.flip,
|
|
1229
|
+
reoriented: constr.mate1.reoriented,
|
|
1230
|
+
},
|
|
1231
|
+
firstDirInstanceCount: firstDirInstanceCountParam,
|
|
1232
|
+
firstDirDistance: firstDirDistanceParam,
|
|
1233
|
+
mate2: constr.mate2
|
|
1234
|
+
? {
|
|
1235
|
+
matePath: rMatePath2,
|
|
1236
|
+
wcsId: rWcs2,
|
|
1237
|
+
flip: constr.mate2.flip,
|
|
1238
|
+
reoriented: constr.mate2.reoriented,
|
|
1239
|
+
}
|
|
1240
|
+
: undefined,
|
|
1241
|
+
secondDirInstanceCount: secondDirInstanceCountParam,
|
|
1242
|
+
secondDirDistance: secondDirDistanceParam,
|
|
1243
|
+
});
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
1247
|
+
finally {
|
|
1248
|
+
try {
|
|
1249
|
+
if (constraints_9_1 && !constraints_9_1.done && (_a = constraints_9.return)) await _a.call(constraints_9);
|
|
1250
|
+
}
|
|
1251
|
+
finally { if (e_11) throw e_11.error; }
|
|
1252
|
+
}
|
|
1253
|
+
await assemblyBuilderAPI.updateLinearPatternConstraints(constrToAdd);
|
|
1254
|
+
},
|
|
1255
|
+
createCircularPatternConstraint: async (id, instanceId, mate1, instanceCount, angle, offset, name) => {
|
|
1256
|
+
const [rId, rInstanceId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), id, instanceId, mate1.wcsId));
|
|
1257
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...mate1.matePath));
|
|
1258
|
+
const constraintId = await assemblyBuilderAPI.create3DConstraint(rId, CCClasses.CCCircularPatternConstraint, name);
|
|
1259
|
+
if (constraintId != null) {
|
|
1260
|
+
const instanceCountParam = {
|
|
1261
|
+
value: instanceCount,
|
|
1262
|
+
isExpr: typeof instanceCount === 'string',
|
|
1263
|
+
};
|
|
1264
|
+
const angleParam = { value: angle, isExpr: typeof angle === 'string' };
|
|
1265
|
+
const offsetParam = { value: offset, isExpr: typeof offset === 'string' };
|
|
1266
|
+
await assemblyBuilderAPI.updateCircularPatternConstraints([
|
|
1267
|
+
{
|
|
1268
|
+
constrId: constraintId,
|
|
1269
|
+
instanceId: rInstanceId,
|
|
1270
|
+
mate1: {
|
|
1271
|
+
matePath: rMatePath1,
|
|
1272
|
+
wcsId: rWcs1,
|
|
1273
|
+
flip: mate1.flip,
|
|
1274
|
+
reoriented: mate1.reoriented,
|
|
1275
|
+
},
|
|
1276
|
+
instanceCount: instanceCountParam,
|
|
1277
|
+
angle: angleParam,
|
|
1278
|
+
offset: offsetParam,
|
|
1279
|
+
},
|
|
1280
|
+
]);
|
|
1281
|
+
return constraintId;
|
|
1282
|
+
}
|
|
1283
|
+
return null;
|
|
1284
|
+
},
|
|
1285
|
+
updateCircularPatternConstraints: async (...constraints) => {
|
|
1286
|
+
var e_12, _a;
|
|
1287
|
+
const constrToAdd = [];
|
|
1288
|
+
try {
|
|
1289
|
+
for (var constraints_10 = __asyncValues(constraints), constraints_10_1; constraints_10_1 = await constraints_10.next(), !constraints_10_1.done;) {
|
|
1290
|
+
const constr = constraints_10_1.value;
|
|
1291
|
+
const [rConstrId, rInstanceId, rWcs1] = await new Promise(res => this.resolve(ids => res(ids), constr.constrId, constr.instanceId, constr.mate1.wcsId));
|
|
1292
|
+
const rMatePath1 = await new Promise(res => this.resolve(paths => res(paths), ...constr.mate1.matePath));
|
|
1293
|
+
const instanceCountParam = {
|
|
1294
|
+
value: constr.instanceCount,
|
|
1295
|
+
isExpr: typeof constr.instanceCount === 'string',
|
|
1296
|
+
};
|
|
1297
|
+
const angleParam = { value: constr.angle, isExpr: typeof constr.angle === 'string' };
|
|
1298
|
+
const offsetParam = { value: constr.offset, isExpr: typeof constr.offset === 'string' };
|
|
1299
|
+
constrToAdd.push({
|
|
1300
|
+
constrId: rConstrId,
|
|
1301
|
+
instanceId: rInstanceId,
|
|
1302
|
+
mate1: {
|
|
1303
|
+
matePath: rMatePath1,
|
|
1304
|
+
wcsId: rWcs1,
|
|
1305
|
+
flip: constr.mate1.flip,
|
|
1306
|
+
reoriented: constr.mate1.reoriented,
|
|
1307
|
+
},
|
|
1308
|
+
instanceCount: instanceCountParam,
|
|
1309
|
+
angle: angleParam,
|
|
1310
|
+
offset: offsetParam,
|
|
1311
|
+
});
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
1315
|
+
finally {
|
|
1316
|
+
try {
|
|
1317
|
+
if (constraints_10_1 && !constraints_10_1.done && (_a = constraints_10.return)) await _a.call(constraints_10);
|
|
1318
|
+
}
|
|
1319
|
+
finally { if (e_12) throw e_12.error; }
|
|
1320
|
+
}
|
|
1321
|
+
await assemblyBuilderAPI.updateCircularPatternConstraints(constrToAdd);
|
|
1322
|
+
},
|
|
1323
|
+
update3dConstraintValues: async (...constrValues) => {
|
|
1324
|
+
var e_13, _a;
|
|
1325
|
+
const constrValueParams = [];
|
|
1326
|
+
try {
|
|
1327
|
+
for (var constrValues_1 = __asyncValues(constrValues), constrValues_1_1; constrValues_1_1 = await constrValues_1.next(), !constrValues_1_1.done;) {
|
|
1328
|
+
const constrVal = constrValues_1_1.value;
|
|
1329
|
+
const [rConstrId] = await new Promise(res => this.resolve(ids => res(ids), constrVal.constrId));
|
|
1330
|
+
constrValueParams.push({
|
|
1331
|
+
constrId: rConstrId,
|
|
1332
|
+
paramName: constrVal.paramName,
|
|
1333
|
+
value: constrVal.value,
|
|
1334
|
+
});
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
1338
|
+
finally {
|
|
1339
|
+
try {
|
|
1340
|
+
if (constrValues_1_1 && !constrValues_1_1.done && (_a = constrValues_1.return)) await _a.call(constrValues_1);
|
|
1341
|
+
}
|
|
1342
|
+
finally { if (e_13) throw e_13.error; }
|
|
1343
|
+
}
|
|
1344
|
+
await assemblyBuilderAPI.update3DConstraintValues(constrValueParams);
|
|
1345
|
+
},
|
|
1346
|
+
createBufferGeometry: async (objectId) => {
|
|
1347
|
+
await this.queue;
|
|
1348
|
+
this.queue = Promise.resolve(0);
|
|
1349
|
+
const rObjectId = await objectId;
|
|
1350
|
+
const cDrawing = getDrawing(drawingId);
|
|
1351
|
+
const structureTree = cDrawing.structure.tree;
|
|
1352
|
+
const bufferGeomArray = [];
|
|
1353
|
+
if (rObjectId != null) {
|
|
1354
|
+
const rootObj = structureTree[rObjectId];
|
|
1355
|
+
await createRecursiveBufferGeometry(rootObj, drawingId, bufferGeomArray);
|
|
1356
|
+
if (bufferGeomArray.length > 0) {
|
|
1357
|
+
return bufferGeomArray;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
return undefined;
|
|
1361
|
+
},
|
|
1362
|
+
createScene: async (objectId, options) => {
|
|
1363
|
+
await this.queue;
|
|
1364
|
+
this.queue = Promise.resolve(0);
|
|
1365
|
+
const cDrawing = getDrawing(drawingId);
|
|
1366
|
+
const structureTree = cDrawing.structure.tree;
|
|
1367
|
+
const rObjectId = objectId ? await objectId : cDrawing.structure.root;
|
|
1368
|
+
const scene = new Scene();
|
|
1369
|
+
const result = {
|
|
1370
|
+
nodes: {},
|
|
1371
|
+
materials: {},
|
|
1372
|
+
};
|
|
1373
|
+
if (rObjectId != null) {
|
|
1374
|
+
const rootObj = structureTree[rObjectId];
|
|
1375
|
+
if (rootObj) {
|
|
1376
|
+
await createRecursiveScene(rootObj, drawingId, scene, result, options);
|
|
1377
|
+
}
|
|
1378
|
+
else {
|
|
1379
|
+
throw new Error('Root object does not exist!');
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
return Object.assign({ scene }, result);
|
|
1383
|
+
},
|
|
1384
|
+
createExpressions: (partId, ...members) => {
|
|
1385
|
+
return this.resolve(async ([rPartId]) => {
|
|
1386
|
+
const membersToAdd = [];
|
|
1387
|
+
members.forEach(mem => {
|
|
1388
|
+
const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen STrings
|
|
1389
|
+
const dataType = DataType.REAL; // TODO: Aktuell nur Real Werte als Expression
|
|
1390
|
+
const featureAPIParam = {
|
|
1391
|
+
value: mem.value,
|
|
1392
|
+
isExpr: isExpr,
|
|
1393
|
+
};
|
|
1394
|
+
membersToAdd.push({ name: mem.name, value: featureAPIParam, dataType });
|
|
1395
|
+
});
|
|
1396
|
+
const success = featureAPI.updateExpressions([
|
|
1397
|
+
{ productId: rPartId, toAddMembers: membersToAdd, toModifyMembers: [], toDeleteList: [] },
|
|
1398
|
+
]);
|
|
1399
|
+
return success;
|
|
1400
|
+
}, partId);
|
|
1401
|
+
},
|
|
1402
|
+
createAssemblyAsTemplate: (name) => {
|
|
1403
|
+
return this.resolve(async ([]) => {
|
|
1404
|
+
return await assemblyBuilderAPI.createAssemblyAsTemplate(name);
|
|
1405
|
+
});
|
|
1406
|
+
},
|
|
1407
|
+
createRootAssembly: (name, options) => {
|
|
1408
|
+
return this.resolve(async ([]) => {
|
|
1409
|
+
return await assemblyBuilderAPI.createRootAssembly(name, options);
|
|
1410
|
+
});
|
|
1411
|
+
},
|
|
1412
|
+
createPart: (name) => {
|
|
1413
|
+
return this.resolve(async ([]) => {
|
|
1414
|
+
const partName = name ? name : 'Part';
|
|
1415
|
+
return await featureAPI.newPart(partName);
|
|
1416
|
+
});
|
|
1417
|
+
},
|
|
1418
|
+
createPartAsTemplate: (name) => {
|
|
1419
|
+
return this.resolve(async ([]) => {
|
|
1420
|
+
const partName = name ? name : 'Part';
|
|
1421
|
+
return await assemblyBuilderAPI.createPartAsTemplate(partName);
|
|
1422
|
+
});
|
|
1423
|
+
},
|
|
1424
|
+
createWorkAxis: (partId, type, references, position, direction, local, name) => {
|
|
1425
|
+
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1426
|
+
const wAName = name ? name : 'WorkAxis';
|
|
1427
|
+
const wAId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkAxis, wAName);
|
|
1428
|
+
if (wAId != null) {
|
|
1429
|
+
const resPosition = resolveVec(position);
|
|
1430
|
+
const positionParam = {
|
|
1431
|
+
value: resPosition,
|
|
1432
|
+
isExpr: typeof resPosition === 'string',
|
|
1433
|
+
};
|
|
1434
|
+
const resDirection = resolveVec(direction);
|
|
1435
|
+
const directionParam = {
|
|
1436
|
+
value: resDirection,
|
|
1437
|
+
isExpr: typeof resDirection === 'string',
|
|
1438
|
+
};
|
|
1439
|
+
await featureAPI.updateWorkAxis(wAId, type, rReferences, positionParam, directionParam, local);
|
|
1440
|
+
return wAId;
|
|
1441
|
+
}
|
|
1442
|
+
return null;
|
|
1443
|
+
}, partId, ...references);
|
|
1444
|
+
},
|
|
1445
|
+
createWorkCoordSystem: (partId, type, references, offset, rotation, inverted = false, name) => {
|
|
1446
|
+
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1447
|
+
const wCSName = name ? name : 'WorkCoordSystem';
|
|
1448
|
+
const wCSId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkCSys, wCSName);
|
|
1449
|
+
if (wCSId != null) {
|
|
1450
|
+
const resOffset = resolveVec(offset);
|
|
1451
|
+
const offsetParam = {
|
|
1452
|
+
value: resOffset,
|
|
1453
|
+
isExpr: typeof resOffset === 'string',
|
|
1454
|
+
};
|
|
1455
|
+
const resRotation = resolveVec(rotation);
|
|
1456
|
+
const rotationParam = {
|
|
1457
|
+
value: resRotation,
|
|
1458
|
+
isExpr: typeof resRotation === 'string',
|
|
1459
|
+
};
|
|
1460
|
+
await featureAPI.updateWorkCSys(wCSId, type, rReferences, offsetParam, rotationParam, inverted ? 1 : 0);
|
|
1461
|
+
return wCSId;
|
|
1462
|
+
}
|
|
1463
|
+
return null;
|
|
1464
|
+
}, partId, ...references);
|
|
1465
|
+
},
|
|
1466
|
+
createWorkPlane: (partId, type, references, offset, angle, position, normal, local, name) => {
|
|
1467
|
+
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1468
|
+
const wPName = name ? name : 'WorkPlane';
|
|
1469
|
+
const wPId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkPlane, wPName);
|
|
1470
|
+
if (wPId != undefined) {
|
|
1471
|
+
const offsetParam = { value: offset, isExpr: typeof offset === 'string' };
|
|
1472
|
+
const angleParam = { value: angle, isExpr: typeof angle === 'string' };
|
|
1473
|
+
const resPosition = resolveVec(position);
|
|
1474
|
+
const positionParam = {
|
|
1475
|
+
value: resPosition,
|
|
1476
|
+
isExpr: typeof resPosition === 'string',
|
|
1477
|
+
};
|
|
1478
|
+
const resNormal = resolveVec(normal);
|
|
1479
|
+
const normalParam = {
|
|
1480
|
+
value: resNormal,
|
|
1481
|
+
isExpr: typeof resNormal === 'string',
|
|
1482
|
+
};
|
|
1483
|
+
await featureAPI.updateWorkPlane(wPId, type, rReferences, offsetParam, angleParam, positionParam, normalParam, local);
|
|
1484
|
+
return wPId;
|
|
1485
|
+
}
|
|
1486
|
+
return null;
|
|
1487
|
+
}, partId, ...references);
|
|
1488
|
+
},
|
|
1489
|
+
createWorkPoint: (partId, type, references, position, local, name) => {
|
|
1490
|
+
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
1491
|
+
const wPTName = name ? name : 'WorkPoint';
|
|
1492
|
+
const wPTId = await featureAPI.createWorkGeometry(rPartId, CCClasses.CCWorkPoint, wPTName);
|
|
1493
|
+
if (wPTId != undefined) {
|
|
1494
|
+
const resPosition = resolveVec(position);
|
|
1495
|
+
const positionParam = {
|
|
1496
|
+
value: resPosition,
|
|
1497
|
+
isExpr: typeof resPosition === 'string',
|
|
1498
|
+
};
|
|
1499
|
+
await featureAPI.updateWorkPoint(wPTId, type, rReferences, positionParam, local);
|
|
1500
|
+
return wPTId;
|
|
1501
|
+
}
|
|
1502
|
+
return null;
|
|
1503
|
+
}, partId, ...references);
|
|
1504
|
+
},
|
|
1505
|
+
fillet: (partId, references, radius) => {
|
|
1506
|
+
return this.resolve(async ([rPartId, rReferences]) => {
|
|
1507
|
+
const radiusParam = { value: radius, isExpr: typeof radius === 'string' };
|
|
1508
|
+
const filletId = await featureAPI.createFeature(rPartId, CCClasses.CCConstantRadiusFillet, 'Fillet');
|
|
1509
|
+
if (filletId != null) {
|
|
1510
|
+
await featureAPI.updateFillet(filletId, rReferences, radiusParam);
|
|
1511
|
+
return filletId;
|
|
1512
|
+
}
|
|
1513
|
+
return null;
|
|
1514
|
+
}, partId, references);
|
|
1515
|
+
},
|
|
1516
|
+
selectGeometry: (types, count) => {
|
|
1517
|
+
const drId = this.drawingId;
|
|
1518
|
+
return this.resolve(async ([]) => {
|
|
1519
|
+
const filter = (scope, data) => scope === BuerliScope && types.some(type => type === data);
|
|
1520
|
+
// Check count param. If not set use by default 1, else check if not < 1
|
|
1521
|
+
const lCount = count ? (count < 1 ? 1 : count) : 1;
|
|
1522
|
+
const selections = (await waitForSelect(lCount, filter, (resolveSelection, items, diff) => {
|
|
1523
|
+
if (items.length > lCount - 1) {
|
|
1524
|
+
resolveSelection(items);
|
|
1525
|
+
}
|
|
1526
|
+
}));
|
|
1527
|
+
const interactionInfos = [];
|
|
1528
|
+
for (const selection of selections) {
|
|
1529
|
+
// Get matching points from selected geometry and add to userData. TODO: Only if in part mode useful?
|
|
1530
|
+
const points = await geometryAPI.getPointsByGeometries([selection.data.graphicId]);
|
|
1531
|
+
const matrix = getDrawing(drId).api.structure.calculateGlobalTransformation(selection.data.productId);
|
|
1532
|
+
const clone = selection.data.geometry.clone().applyMatrix4(matrix);
|
|
1533
|
+
// TODO: Should the transform code be moved to something else than Measure? It's helpful for more cases than just measuring.
|
|
1534
|
+
const transformedData = Measure.transform([selection.data], drId)[0];
|
|
1535
|
+
const interactionInfo = createInfo({
|
|
1536
|
+
objectId: selection.data.container.ownerId,
|
|
1537
|
+
prodRefId: selection.data.productId,
|
|
1538
|
+
containerId: selection.data.container.id,
|
|
1539
|
+
graphicId: selection.data.graphicId,
|
|
1540
|
+
// objectPath: ?, TODO: Add path to the root in expanded tree, as soon as available
|
|
1541
|
+
userData: Object.assign(Object.assign({}, transformedData), { geometry: clone, matchingPoints: points }),
|
|
1542
|
+
});
|
|
1543
|
+
interactionInfos.push(interactionInfo);
|
|
1544
|
+
}
|
|
1545
|
+
return interactionInfos;
|
|
1546
|
+
});
|
|
1547
|
+
},
|
|
1548
|
+
findGeometry: (partId, type, positions) => {
|
|
1549
|
+
return this.resolve(async ([rPartId]) => {
|
|
1550
|
+
const geoms = await geometryAPI.findGeometriesByPoints(rPartId, type, positions.map(pos => pos.map(p => resolveVec(p))));
|
|
1551
|
+
return geoms;
|
|
1552
|
+
}, partId);
|
|
1553
|
+
},
|
|
1554
|
+
getAssemblyTemplate: (asmName) => {
|
|
1555
|
+
return this.resolve(async ([]) => {
|
|
1556
|
+
const asmIds = asmUtils.getAssemblyTemplate(drawingId, asmName);
|
|
1557
|
+
if (asmIds != undefined) {
|
|
1558
|
+
return Array.isArray(asmIds) ? asmIds : [asmIds];
|
|
1559
|
+
}
|
|
1560
|
+
return null;
|
|
1561
|
+
});
|
|
1562
|
+
},
|
|
1563
|
+
getInstance: (id, instanceName) => {
|
|
1564
|
+
return this.resolve(async ([rId]) => {
|
|
1565
|
+
const instances = asmUtils.getInstance(drawingId, rId, instanceName);
|
|
1566
|
+
if (instances != undefined) {
|
|
1567
|
+
return Array.isArray(instances) ? instances : [instances];
|
|
1568
|
+
}
|
|
1569
|
+
return null;
|
|
1570
|
+
}, id);
|
|
1571
|
+
},
|
|
1572
|
+
findInstance: (options) => {
|
|
1573
|
+
return this.resolve(async () => {
|
|
1574
|
+
const instance = baseUtils.findObject(drawingId, {
|
|
1575
|
+
ident: options.instanceIdent,
|
|
1576
|
+
name: options.instanceName,
|
|
1577
|
+
});
|
|
1578
|
+
if (!instance) {
|
|
1579
|
+
return null;
|
|
1580
|
+
}
|
|
1581
|
+
const clazz = getDrawing(drawingId).structure.tree[instance].class;
|
|
1582
|
+
if (!baseUtils.isA(clazz, CCClasses.IProductReference)) {
|
|
1583
|
+
return null;
|
|
1584
|
+
}
|
|
1585
|
+
else {
|
|
1586
|
+
return instance;
|
|
1587
|
+
}
|
|
1588
|
+
});
|
|
1589
|
+
},
|
|
1590
|
+
getProductsOfInstances: (instanceIds) => {
|
|
1591
|
+
return this.resolve(async ([rInstanceIds]) => {
|
|
1592
|
+
const drawing = getDrawing(drawingId);
|
|
1593
|
+
const tree = drawing.structure.tree;
|
|
1594
|
+
const products = [];
|
|
1595
|
+
for (const rInstanceId of rInstanceIds) {
|
|
1596
|
+
const product = asmUtils.findProduct(rInstanceId, tree);
|
|
1597
|
+
products.push(product);
|
|
1598
|
+
}
|
|
1599
|
+
return products;
|
|
1600
|
+
}, instanceIds);
|
|
1601
|
+
},
|
|
1602
|
+
setCurrentInstance: (id) => {
|
|
1603
|
+
return this.resolve(async ([rId]) => {
|
|
1604
|
+
await assemblyBuilderAPI.setCurrentInstance(rId);
|
|
1605
|
+
}, id);
|
|
1606
|
+
},
|
|
1607
|
+
getCurrentInstance: () => {
|
|
1608
|
+
return this.resolve(async () => {
|
|
1609
|
+
const drw = getDrawing(drawingId);
|
|
1610
|
+
return drw.structure.currentInstance;
|
|
1611
|
+
});
|
|
1612
|
+
},
|
|
1613
|
+
getTransformation: (id) => {
|
|
1614
|
+
return this.resolve(async ([rId]) => {
|
|
1615
|
+
const coordSys = asmUtils.getTransformation(drawingId, rId);
|
|
1616
|
+
if (coordSys != undefined) {
|
|
1617
|
+
return coordSys;
|
|
1618
|
+
}
|
|
1619
|
+
return null;
|
|
1620
|
+
}, id);
|
|
1621
|
+
},
|
|
1622
|
+
setCurrentProduct: (productId) => {
|
|
1623
|
+
return this.resolve(async ([rProductId]) => {
|
|
1624
|
+
await baseModelerAPI.setCurrentProduct(rProductId);
|
|
1625
|
+
}, productId);
|
|
1626
|
+
},
|
|
1627
|
+
getCurrentProduct: () => {
|
|
1628
|
+
return this.resolve(async () => {
|
|
1629
|
+
const drw = getDrawing(drawingId);
|
|
1630
|
+
return drw.structure.currentProduct;
|
|
1631
|
+
});
|
|
1632
|
+
},
|
|
1633
|
+
getPartTemplate: (partName) => {
|
|
1634
|
+
return this.resolve(async ([]) => {
|
|
1635
|
+
const partIds = asmUtils.getPartTemplate(drawingId, partName);
|
|
1636
|
+
if (partIds != undefined) {
|
|
1637
|
+
return Array.isArray(partIds) ? partIds : [partIds];
|
|
1638
|
+
}
|
|
1639
|
+
return null;
|
|
1640
|
+
});
|
|
1641
|
+
},
|
|
1642
|
+
getWorkCoordSystem: (id, wcsName) => {
|
|
1643
|
+
return this.resolve(async ([rId]) => {
|
|
1644
|
+
console.warn('Warning: getWorkCoordSystem() is deprecated, use getWorkGeometry() instead, getWorkCoordSystem() will be removed in a future release.');
|
|
1645
|
+
const wcsIds = asmUtils.getWorkCoordSystem(drawingId, rId, wcsName);
|
|
1646
|
+
if (wcsIds != undefined) {
|
|
1647
|
+
return Array.isArray(wcsIds) ? wcsIds : [wcsIds];
|
|
1648
|
+
}
|
|
1649
|
+
return null;
|
|
1650
|
+
}, id);
|
|
1651
|
+
},
|
|
1652
|
+
getSketchRegion: (id, sketchRegionName) => {
|
|
1653
|
+
return this.resolve(async ([rId]) => {
|
|
1654
|
+
const sRIds = partUtils.getSketchRegion(drawingId, rId, sketchRegionName);
|
|
1655
|
+
if (sRIds != undefined) {
|
|
1656
|
+
return Array.isArray(sRIds) ? sRIds : [sRIds];
|
|
1657
|
+
}
|
|
1658
|
+
return null;
|
|
1659
|
+
}, id);
|
|
1660
|
+
},
|
|
1661
|
+
getSketch: (id, sketchName) => {
|
|
1662
|
+
return this.resolve(async ([rId]) => {
|
|
1663
|
+
const sIds = partUtils.getSketch(drawingId, rId, sketchName);
|
|
1664
|
+
if (sIds != undefined) {
|
|
1665
|
+
return Array.isArray(sIds) ? sIds : [sIds];
|
|
1666
|
+
}
|
|
1667
|
+
return null;
|
|
1668
|
+
}, id);
|
|
1669
|
+
},
|
|
1670
|
+
getWorkGeometry: (refId, type, wgName) => {
|
|
1671
|
+
return this.resolve(async ([rRefId]) => {
|
|
1672
|
+
const wgIds = asmUtils.getWorkGeometry(drawingId, rRefId, type, wgName);
|
|
1673
|
+
if (wgIds != undefined) {
|
|
1674
|
+
return Array.isArray(wgIds) ? wgIds : [wgIds];
|
|
1675
|
+
}
|
|
1676
|
+
return null;
|
|
1677
|
+
}, refId);
|
|
1678
|
+
},
|
|
1679
|
+
getConstraint: (refId, constrName) => {
|
|
1680
|
+
return this.resolve(async ([rRefId]) => {
|
|
1681
|
+
console.warn('Warning: getConstraint() is deprecated, use specific methods e.g. getFastenedConstraint() instead, getConstraint() will be removed in a future release.');
|
|
1682
|
+
const constrIds = asmUtils.getConstraint(drawingId, rRefId, constrName);
|
|
1683
|
+
if (constrIds != undefined) {
|
|
1684
|
+
return Array.isArray(constrIds) ? constrIds : [constrIds];
|
|
1685
|
+
}
|
|
1686
|
+
return null;
|
|
1687
|
+
}, refId);
|
|
1688
|
+
},
|
|
1689
|
+
getFastenedConstraint: (id, constrName) => {
|
|
1690
|
+
return this.resolve(async ([rId]) => {
|
|
1691
|
+
const constraint = asmUtils.getFastenedConstraint(drawingId, rId, constrName);
|
|
1692
|
+
if (constraint != undefined) {
|
|
1693
|
+
return {
|
|
1694
|
+
constrId: constraint.constrId,
|
|
1695
|
+
mate1: constraint.mate1,
|
|
1696
|
+
mate2: constraint.mate2,
|
|
1697
|
+
xOffset: constraint.xOffset.value,
|
|
1698
|
+
yOffset: constraint.yOffset.value,
|
|
1699
|
+
zOffset: constraint.zOffset.value,
|
|
1700
|
+
xRotation: constraint.xRotation.value,
|
|
1701
|
+
yRotation: constraint.yRotation.value,
|
|
1702
|
+
zRotation: constraint.zRotation.value,
|
|
1703
|
+
};
|
|
1704
|
+
}
|
|
1705
|
+
return null;
|
|
1706
|
+
}, id);
|
|
1707
|
+
},
|
|
1708
|
+
getFastenedOriginConstraint: (id, constrName) => {
|
|
1709
|
+
return this.resolve(async ([rId]) => {
|
|
1710
|
+
const constraint = asmUtils.getFastenedOriginConstraint(drawingId, rId, constrName);
|
|
1711
|
+
if (constraint != undefined) {
|
|
1712
|
+
return {
|
|
1713
|
+
constrId: constraint.constrId,
|
|
1714
|
+
mate1: constraint.mate1,
|
|
1715
|
+
xOffset: constraint.xOffset.value,
|
|
1716
|
+
yOffset: constraint.yOffset.value,
|
|
1717
|
+
zOffset: constraint.zOffset.value,
|
|
1718
|
+
xRotation: constraint.xRotation.value,
|
|
1719
|
+
yRotation: constraint.yRotation.value,
|
|
1720
|
+
zRotation: constraint.zRotation.value,
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
return null;
|
|
1724
|
+
}, id);
|
|
1725
|
+
},
|
|
1726
|
+
getRevoluteConstraint: (id, constrName) => {
|
|
1727
|
+
return this.resolve(async ([rId]) => {
|
|
1728
|
+
const constraint = asmUtils.getRevoluteConstraint(drawingId, rId, constrName);
|
|
1729
|
+
if (constraint != undefined) {
|
|
1730
|
+
return {
|
|
1731
|
+
constrId: constraint.constrId,
|
|
1732
|
+
mate1: constraint.mate1,
|
|
1733
|
+
mate2: constraint.mate2,
|
|
1734
|
+
zOffset: constraint.zOffset.value,
|
|
1735
|
+
zRotationLimits: constraint.zRotationLimits,
|
|
1736
|
+
};
|
|
1737
|
+
}
|
|
1738
|
+
return null;
|
|
1739
|
+
}, id);
|
|
1740
|
+
},
|
|
1741
|
+
getSliderConstraint: (id, constrName) => {
|
|
1742
|
+
return this.resolve(async ([rId]) => {
|
|
1743
|
+
const constraint = asmUtils.getSliderConstraint(drawingId, rId, constrName);
|
|
1744
|
+
if (constraint != undefined) {
|
|
1745
|
+
return {
|
|
1746
|
+
constrId: constraint.constrId,
|
|
1747
|
+
mate1: constraint.mate1,
|
|
1748
|
+
mate2: constraint.mate2,
|
|
1749
|
+
xOffset: constraint.xOffset.value,
|
|
1750
|
+
yOffset: constraint.yOffset.value,
|
|
1751
|
+
zOffsetLimits: constraint.zOffsetLimits,
|
|
1752
|
+
};
|
|
1753
|
+
}
|
|
1754
|
+
return null;
|
|
1755
|
+
}, id);
|
|
1756
|
+
},
|
|
1757
|
+
getPlanarConstraint: (id, constrName) => {
|
|
1758
|
+
return this.resolve(async ([rId]) => {
|
|
1759
|
+
const constraint = asmUtils.getPlanarConstraint(drawingId, rId, constrName);
|
|
1760
|
+
if (constraint != undefined) {
|
|
1761
|
+
return {
|
|
1762
|
+
constrId: constraint.constrId,
|
|
1763
|
+
mate1: constraint.mate1,
|
|
1764
|
+
mate2: constraint.mate2,
|
|
1765
|
+
zOffset: constraint.zOffset.value,
|
|
1766
|
+
xOffsetLimits: constraint.xOffsetLimits,
|
|
1767
|
+
yOffsetLimits: constraint.yOffsetLimits,
|
|
1768
|
+
zRotationLimits: constraint.zRotationLimits,
|
|
1769
|
+
};
|
|
1770
|
+
}
|
|
1771
|
+
return null;
|
|
1772
|
+
}, id);
|
|
1773
|
+
},
|
|
1774
|
+
getParallelConstraint: (id, constrName) => {
|
|
1775
|
+
return this.resolve(async ([rId]) => {
|
|
1776
|
+
const constraint = asmUtils.getParallelConstraint(drawingId, rId, constrName);
|
|
1777
|
+
if (constraint != undefined) {
|
|
1778
|
+
return {
|
|
1779
|
+
constrId: constraint.constrId,
|
|
1780
|
+
mate1: constraint.mate1,
|
|
1781
|
+
mate2: constraint.mate2,
|
|
1782
|
+
xOffsetLimits: constraint.xOffsetLimits,
|
|
1783
|
+
yOffsetLimits: constraint.yOffsetLimits,
|
|
1784
|
+
zOffsetLimits: constraint.zOffsetLimits,
|
|
1785
|
+
zRotationLimits: constraint.zRotationLimits,
|
|
1786
|
+
};
|
|
1787
|
+
}
|
|
1788
|
+
return null;
|
|
1789
|
+
}, id);
|
|
1790
|
+
},
|
|
1791
|
+
getCylindricalConstraint: (id, constrName) => {
|
|
1792
|
+
return this.resolve(async ([rId]) => {
|
|
1793
|
+
const constraint = asmUtils.getCylindricalConstraint(drawingId, rId, constrName);
|
|
1794
|
+
if (constraint != undefined) {
|
|
1795
|
+
return {
|
|
1796
|
+
constrId: constraint.constrId,
|
|
1797
|
+
mate1: constraint.mate1,
|
|
1798
|
+
mate2: constraint.mate2,
|
|
1799
|
+
zOffsetLimits: constraint.zOffsetLimits,
|
|
1800
|
+
zRotationLimits: constraint.zRotationLimits,
|
|
1801
|
+
};
|
|
1802
|
+
}
|
|
1803
|
+
return null;
|
|
1804
|
+
}, id);
|
|
1805
|
+
},
|
|
1806
|
+
getGroupConstraint: (id, constrName) => {
|
|
1807
|
+
return this.resolve(async ([rId]) => {
|
|
1808
|
+
const constraint = asmUtils.getGroupConstraint(drawingId, rId, constrName);
|
|
1809
|
+
if (constraint != undefined) {
|
|
1810
|
+
return {
|
|
1811
|
+
constrId: constraint.constrId,
|
|
1812
|
+
instanceIds: constraint.instanceIds,
|
|
1813
|
+
};
|
|
1814
|
+
}
|
|
1815
|
+
return null;
|
|
1816
|
+
}, id);
|
|
1817
|
+
},
|
|
1818
|
+
getLinearPatternConstraint: (id, constrName) => {
|
|
1819
|
+
return this.resolve(async ([rId]) => {
|
|
1820
|
+
var _a, _b;
|
|
1821
|
+
const constraint = asmUtils.getLinearPatternConstraint(drawingId, rId, constrName);
|
|
1822
|
+
if (constraint != undefined) {
|
|
1823
|
+
return {
|
|
1824
|
+
constrId: constraint.constrId,
|
|
1825
|
+
instanceId: constraint.instanceId,
|
|
1826
|
+
mate1: constraint.mate1,
|
|
1827
|
+
firstDirInstanceCount: constraint.firstDirInstanceCount.value,
|
|
1828
|
+
firstDirDistance: constraint.firstDirDistance.value,
|
|
1829
|
+
mate2: constraint.mate2,
|
|
1830
|
+
secondDirInstanceCount: (_a = constraint === null || constraint === void 0 ? void 0 : constraint.secondDirInstanceCount) === null || _a === void 0 ? void 0 : _a.value,
|
|
1831
|
+
secondDirDistance: (_b = constraint === null || constraint === void 0 ? void 0 : constraint.secondDirDistance) === null || _b === void 0 ? void 0 : _b.value,
|
|
1832
|
+
};
|
|
1833
|
+
}
|
|
1834
|
+
return null;
|
|
1835
|
+
}, id);
|
|
1836
|
+
},
|
|
1837
|
+
getCircularPatternConstraint: (id, constrName) => {
|
|
1838
|
+
return this.resolve(async ([rId]) => {
|
|
1839
|
+
const constraint = asmUtils.getCircularPatternConstraint(drawingId, rId, constrName);
|
|
1840
|
+
if (constraint != undefined) {
|
|
1841
|
+
return {
|
|
1842
|
+
constrId: constraint.constrId,
|
|
1843
|
+
instanceId: constraint.instanceId,
|
|
1844
|
+
mate1: constraint.mate1,
|
|
1845
|
+
instanceCount: constraint.instanceCount.value,
|
|
1846
|
+
angle: constraint.angle.value,
|
|
1847
|
+
offset: constraint.offset.value,
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1850
|
+
return null;
|
|
1851
|
+
}, id);
|
|
1852
|
+
},
|
|
1853
|
+
getFeatureByName: (partId, featureName) => {
|
|
1854
|
+
return this.resolve(async ([rProductId]) => {
|
|
1855
|
+
const feature = await featureAPI.getFeatureByName(rProductId, featureName);
|
|
1856
|
+
if (feature !== null) {
|
|
1857
|
+
return feature;
|
|
1858
|
+
}
|
|
1859
|
+
return null;
|
|
1860
|
+
}, partId);
|
|
1861
|
+
},
|
|
1862
|
+
getGeometryInformation: (id) => {
|
|
1863
|
+
return this.resolve(async ([rId]) => {
|
|
1864
|
+
const values = await baseModelerAPI.getGeometryInformation(rId);
|
|
1865
|
+
if (values !== null) {
|
|
1866
|
+
return { centerOfGravity: values[0], volume: values[1] };
|
|
1867
|
+
}
|
|
1868
|
+
return null;
|
|
1869
|
+
}, id);
|
|
1870
|
+
},
|
|
1871
|
+
removeInstances: async (...instances) => {
|
|
1872
|
+
var e_14, _a;
|
|
1873
|
+
const instancesToRemove = [];
|
|
1874
|
+
try {
|
|
1875
|
+
for (var instances_2 = __asyncValues(instances), instances_2_1; instances_2_1 = await instances_2.next(), !instances_2_1.done;) {
|
|
1876
|
+
const instance = instances_2_1.value;
|
|
1877
|
+
const [rInstanceId] = await new Promise(res => this.resolve(id => res(id), instance.id));
|
|
1878
|
+
let instanceId = rInstanceId;
|
|
1879
|
+
if (typeof rInstanceId === 'string') {
|
|
1880
|
+
instanceId = baseUtils.findObject(drawingId, {
|
|
1881
|
+
ident: rInstanceId,
|
|
1882
|
+
name: rInstanceId,
|
|
1883
|
+
});
|
|
1884
|
+
if (!instanceId) {
|
|
1885
|
+
throw 'The instance to remove given by name or ident "' + rInstanceId + '" does not exist.';
|
|
1886
|
+
}
|
|
1887
|
+
const clazz = getDrawing(drawingId).structure.tree[instanceId].class;
|
|
1888
|
+
if (!baseUtils.isA(clazz, CCClasses.IProductReference)) {
|
|
1889
|
+
throw ('The instance to remove given by name or ident "' +
|
|
1890
|
+
rInstanceId +
|
|
1891
|
+
'" is of the wrong type "' +
|
|
1892
|
+
clazz +
|
|
1893
|
+
'". Make sure the object is an instance.');
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
const instanceParam = { id: instanceId };
|
|
1897
|
+
instancesToRemove.push(instanceParam);
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
1901
|
+
finally {
|
|
1902
|
+
try {
|
|
1903
|
+
if (instances_2_1 && !instances_2_1.done && (_a = instances_2.return)) await _a.call(instances_2);
|
|
1904
|
+
}
|
|
1905
|
+
finally { if (e_14) throw e_14.error; }
|
|
1906
|
+
}
|
|
1907
|
+
return assemblyBuilderAPI.removeInstances(instancesToRemove);
|
|
1908
|
+
},
|
|
1909
|
+
importFeature: (partId, content, format, name) => {
|
|
1910
|
+
return this.resolve(async ([rPartId]) => {
|
|
1911
|
+
const featureName = name ? name : 'Import';
|
|
1912
|
+
const importFeatureId = await featureAPI.createFeature(rPartId, CCClasses.CCImport, featureName);
|
|
1913
|
+
if (importFeatureId !== null) {
|
|
1914
|
+
const solids = await featureAPI.updateImport(importFeatureId, content, format.toUpperCase(), featureName);
|
|
1915
|
+
if (solids !== null) {
|
|
1916
|
+
return importFeatureId;
|
|
1917
|
+
}
|
|
1918
|
+
}
|
|
1919
|
+
return null;
|
|
1920
|
+
}, partId);
|
|
1921
|
+
},
|
|
1922
|
+
loadSketch: (partId, stream, planeId, name) => {
|
|
1923
|
+
return this.resolve(async ([rPartId, rPlaneId]) => {
|
|
1924
|
+
const sketch = await sketcherAPI.createSketch(rPartId);
|
|
1925
|
+
if (sketch) {
|
|
1926
|
+
await featureAPI.closeFeature(sketch);
|
|
1927
|
+
const tree = getDrawing(drawingId).structure.tree;
|
|
1928
|
+
const plane = tree[rPlaneId];
|
|
1929
|
+
if (plane && baseUtils.isA(plane.class, CCClasses.CCWorkPlane)) {
|
|
1930
|
+
await sketcherAPI.setWorkPlane(sketch, rPlaneId);
|
|
1931
|
+
}
|
|
1932
|
+
else {
|
|
1933
|
+
await sketcherAPI.createAndSetWorkPlane(sketch, rPlaneId);
|
|
1934
|
+
}
|
|
1935
|
+
await sketcherAPI.loadSketch(rPartId, sketch, stream, name);
|
|
1936
|
+
return sketch;
|
|
1937
|
+
}
|
|
1938
|
+
}, partId, planeId);
|
|
1939
|
+
},
|
|
1940
|
+
copySketch: (partId, sketchId, planeId) => {
|
|
1941
|
+
return this.resolve(async ([rPartId, rPlaneId, rSketchId]) => {
|
|
1942
|
+
const sketch = await sketcherAPI.createSketch(rPartId);
|
|
1943
|
+
if (sketch) {
|
|
1944
|
+
await featureAPI.closeFeature(sketch);
|
|
1945
|
+
const tree = getDrawing(drawingId).structure.tree;
|
|
1946
|
+
const plane = tree[rPlaneId];
|
|
1947
|
+
if (plane && baseUtils.isA(plane.class, CCClasses.CCWorkPlane)) {
|
|
1948
|
+
await sketcherAPI.setWorkPlane(sketch, rPlaneId);
|
|
1949
|
+
}
|
|
1950
|
+
else {
|
|
1951
|
+
await sketcherAPI.createAndSetWorkPlane(sketch, rPlaneId);
|
|
1952
|
+
}
|
|
1953
|
+
await sketcherAPI.copySketch(sketch, rSketchId);
|
|
1954
|
+
return sketch;
|
|
1955
|
+
}
|
|
1956
|
+
}, partId, planeId, sketchId);
|
|
1957
|
+
},
|
|
1958
|
+
placeSketch: (sketchId, planeId, invertPlane, axisId, isXAxis, invertAxis, originId) => {
|
|
1959
|
+
return this.resolve(async ([rSketchId, rPlaneId, rAxisId, rOriginId]) => {
|
|
1960
|
+
await sketcherAPI.setSketchRefs(rSketchId, rPlaneId, invertPlane, rAxisId, isXAxis, invertAxis, rOriginId);
|
|
1961
|
+
}, sketchId, planeId, axisId, originId);
|
|
1962
|
+
},
|
|
1963
|
+
transformInstances: async (...instances) => {
|
|
1964
|
+
var e_15, _a;
|
|
1965
|
+
const instancesToTransform = [];
|
|
1966
|
+
try {
|
|
1967
|
+
for (var instances_3 = __asyncValues(instances), instances_3_1; instances_3_1 = await instances_3.next(), !instances_3_1.done;) {
|
|
1968
|
+
const instance = instances_3_1.value;
|
|
1969
|
+
const [rInstanceId] = await new Promise(res => this.resolve(id => res(id), instance.id));
|
|
1970
|
+
let instanceId = rInstanceId;
|
|
1971
|
+
if (typeof rInstanceId === 'string') {
|
|
1972
|
+
instanceId = baseUtils.findObject(drawingId, {
|
|
1973
|
+
ident: rInstanceId,
|
|
1974
|
+
name: rInstanceId,
|
|
1975
|
+
});
|
|
1976
|
+
if (!instanceId) {
|
|
1977
|
+
throw 'The instance to transform given by name or ident "' + rInstanceId + '" does not exist.';
|
|
1978
|
+
}
|
|
1979
|
+
const clazz = getDrawing(drawingId).structure.tree[instanceId].class;
|
|
1980
|
+
if (!baseUtils.isA(clazz, CCClasses.IProductReference)) {
|
|
1981
|
+
throw ('The instance to transform given by name or ident "' +
|
|
1982
|
+
rInstanceId +
|
|
1983
|
+
'" is of the wrong type "' +
|
|
1984
|
+
clazz +
|
|
1985
|
+
'". Make sure the object is an instance.');
|
|
1986
|
+
}
|
|
1987
|
+
}
|
|
1988
|
+
const instanceParam = {
|
|
1989
|
+
id: instanceId,
|
|
1990
|
+
transformation: instance.transformation,
|
|
1991
|
+
options: { isLocal: true }, // in non-interactive mode, the transformation is local to the owner
|
|
1992
|
+
};
|
|
1993
|
+
instancesToTransform.push(instanceParam);
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
1997
|
+
finally {
|
|
1998
|
+
try {
|
|
1999
|
+
if (instances_3_1 && !instances_3_1.done && (_a = instances_3.return)) await _a.call(instances_3);
|
|
2000
|
+
}
|
|
2001
|
+
finally { if (e_15) throw e_15.error; }
|
|
2002
|
+
}
|
|
2003
|
+
return assemblyBuilderAPI.transformInstances(instancesToTransform);
|
|
2004
|
+
},
|
|
2005
|
+
translate: (partId, operations, references, inverted, distance) => {
|
|
2006
|
+
return this.resolve(async ([rPartId, rOperations, ...rReferences]) => {
|
|
2007
|
+
const translationId = await featureAPI.createFeature(rPartId, CCClasses.CCTranslation, 'Translate');
|
|
2008
|
+
if (translationId !== null) {
|
|
2009
|
+
const cDrawing = await getDrawing(drawingId);
|
|
2010
|
+
const entArray = [];
|
|
2011
|
+
for (const rOperation of rOperations) {
|
|
2012
|
+
const entities = cDrawing.structure.tree[(await rOperation)].children;
|
|
2013
|
+
if (entities != undefined) {
|
|
2014
|
+
entArray.push(entities[0]);
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
const dist = { value: distance, isExpr: typeof distance === 'string' };
|
|
2018
|
+
await featureAPI.updateTransformation(translationId, entArray, rReferences, inverted, dist);
|
|
2019
|
+
return translationId;
|
|
2020
|
+
}
|
|
2021
|
+
return null;
|
|
2022
|
+
}, partId, operations, ...references);
|
|
2023
|
+
},
|
|
2024
|
+
// TODO: Remove this method. Is it necessary?
|
|
2025
|
+
updateTranslate: (translationId, distance) => {
|
|
2026
|
+
return this.resolve(async ([rTranslationId]) => {
|
|
2027
|
+
const cDrawing = await getDrawing(drawingId);
|
|
2028
|
+
const members = cDrawing.structure.tree[rTranslationId].members;
|
|
2029
|
+
if (members !== null && members !== undefined) {
|
|
2030
|
+
const entArray = members['bodiesToTransform'].members.map(m => m.value);
|
|
2031
|
+
const references = members['references'].members.map(m => m.value);
|
|
2032
|
+
const inverted = members['inverted'].value;
|
|
2033
|
+
const dist = distance !== null ? distance : members['translationDistance'].value;
|
|
2034
|
+
const distParam = { value: dist, isExpr: typeof distance === 'string' };
|
|
2035
|
+
await featureAPI.openFeature(rTranslationId);
|
|
2036
|
+
await featureAPI.updateTransformation(rTranslationId, entArray, references, inverted, distParam);
|
|
2037
|
+
await featureAPI.closeFeature(rTranslationId);
|
|
2038
|
+
}
|
|
2039
|
+
}, translationId);
|
|
2040
|
+
},
|
|
2041
|
+
save: (type) => {
|
|
2042
|
+
return baseModelerAPI.save(type);
|
|
2043
|
+
},
|
|
2044
|
+
saveToUrl: (url, filetype) => {
|
|
2045
|
+
return baseModelerAPI.saveToUrl(url, filetype);
|
|
2046
|
+
},
|
|
2047
|
+
load: (content, type, options) => {
|
|
2048
|
+
return baseModelerAPI.load(content, type, '', options);
|
|
2049
|
+
},
|
|
2050
|
+
loadFromUrl: (url, filetype, options) => {
|
|
2051
|
+
return baseModelerAPI.loadFromUrl(url, filetype, true, options);
|
|
2052
|
+
},
|
|
2053
|
+
loadProduct: (content, type, options) => {
|
|
2054
|
+
return assemblyBuilderAPI.loadProduct(content, type, options);
|
|
2055
|
+
},
|
|
2056
|
+
loadProductFromUrl: (url, filetype, options) => {
|
|
2057
|
+
return assemblyBuilderAPI.loadProductFromUrl(url, filetype, options);
|
|
2058
|
+
},
|
|
2059
|
+
pick: (partId, type, points) => {
|
|
2060
|
+
return this.resolve(async ([rPartId]) => {
|
|
2061
|
+
console.warn('Warning: pick() is deprecated, use findGeometry() instead, pick() will be removed in a future release.');
|
|
2062
|
+
const refs = await featureAPI.pick(rPartId, type, points.map(p => resolveVec(p)));
|
|
2063
|
+
if (refs != undefined) {
|
|
2064
|
+
return Array.isArray(refs) ? refs : [refs];
|
|
2065
|
+
}
|
|
2066
|
+
return null;
|
|
2067
|
+
}, partId);
|
|
2068
|
+
},
|
|
2069
|
+
setExpressions: async (...expressions) => {
|
|
2070
|
+
var e_16, _a;
|
|
2071
|
+
const expressionsToSet = [];
|
|
2072
|
+
try {
|
|
2073
|
+
for (var expressions_1 = __asyncValues(expressions), expressions_1_1; expressions_1_1 = await expressions_1.next(), !expressions_1_1.done;) {
|
|
2074
|
+
const expr = expressions_1_1.value;
|
|
2075
|
+
const [rPartId] = await new Promise(res => this.resolve(id => res(id), expr.partId));
|
|
2076
|
+
const membersToModify = [];
|
|
2077
|
+
expr.members.forEach((mem) => {
|
|
2078
|
+
const isExpr = typeof mem.value === 'string'; // TODO Expression unterscheiden von normalen Strings
|
|
2079
|
+
const featureAPIParam = {
|
|
2080
|
+
value: mem.value,
|
|
2081
|
+
isExpr,
|
|
2082
|
+
};
|
|
2083
|
+
membersToModify.push({ name: mem.name, value: featureAPIParam });
|
|
2084
|
+
});
|
|
2085
|
+
// Looking for the partId given by an identifier or name
|
|
2086
|
+
let part = rPartId;
|
|
2087
|
+
if (typeof part === 'string') {
|
|
2088
|
+
const foundPart = baseUtils.findObject(drawingId, { ident: part, name: part });
|
|
2089
|
+
if (!foundPart) {
|
|
2090
|
+
throw 'No part found to set expressions on for given name or ident: ' + part;
|
|
2091
|
+
}
|
|
2092
|
+
const clazz = getDrawing(drawingId).structure.tree[foundPart].class;
|
|
2093
|
+
if (!baseUtils.isA(clazz, CCClasses.CCPart)) {
|
|
2094
|
+
throw ('The part to set expressions on given by name or ident "' +
|
|
2095
|
+
part +
|
|
2096
|
+
'" is of the wrong type "' +
|
|
2097
|
+
clazz +
|
|
2098
|
+
'". Make sure the object is a part.');
|
|
2099
|
+
}
|
|
2100
|
+
else {
|
|
2101
|
+
part = foundPart;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
expressionsToSet.push({
|
|
2105
|
+
productId: part,
|
|
2106
|
+
toAddMembers: [],
|
|
2107
|
+
toModifyMembers: membersToModify,
|
|
2108
|
+
toDeleteList: [],
|
|
2109
|
+
});
|
|
2110
|
+
}
|
|
2111
|
+
}
|
|
2112
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
2113
|
+
finally {
|
|
2114
|
+
try {
|
|
2115
|
+
if (expressions_1_1 && !expressions_1_1.done && (_a = expressions_1.return)) await _a.call(expressions_1);
|
|
2116
|
+
}
|
|
2117
|
+
finally { if (e_16) throw e_16.error; }
|
|
2118
|
+
}
|
|
2119
|
+
const success = await featureAPI.updateExpressions(expressionsToSet);
|
|
2120
|
+
return success;
|
|
2121
|
+
},
|
|
2122
|
+
renameExpressions: (partId, members) => {
|
|
2123
|
+
return this.resolve(async ([rPartId]) => {
|
|
2124
|
+
const success = featureAPI.updateExpressions([
|
|
2125
|
+
{ productId: rPartId, toAddMembers: [], toModifyMembers: [], toRenameMembers: members, toDeleteList: [] },
|
|
2126
|
+
]);
|
|
2127
|
+
return success;
|
|
2128
|
+
}, partId);
|
|
2129
|
+
},
|
|
2130
|
+
deleteExpressions: (partId, members) => {
|
|
2131
|
+
return this.resolve(async ([rPartId]) => {
|
|
2132
|
+
const success = featureAPI.updateExpressions([
|
|
2133
|
+
{ productId: rPartId, toAddMembers: [], toModifyMembers: [], toDeleteList: members },
|
|
2134
|
+
]);
|
|
2135
|
+
return success;
|
|
2136
|
+
}, partId);
|
|
2137
|
+
},
|
|
2138
|
+
sphere: (partId, references, radius) => {
|
|
2139
|
+
return this.resolve(async ([rPartId, ...rReferences]) => {
|
|
2140
|
+
const sphereId = await featureAPI.createFeature(rPartId, CCClasses.CCSphere, 'Sphere');
|
|
2141
|
+
if (sphereId != null) {
|
|
2142
|
+
const radiusParam = { value: radius, isExpr: typeof radius === 'string' };
|
|
2143
|
+
await featureAPI.updateSphere(sphereId, rReferences, radiusParam);
|
|
2144
|
+
return sphereId;
|
|
2145
|
+
}
|
|
2146
|
+
return null;
|
|
2147
|
+
}, partId, ...references);
|
|
2148
|
+
},
|
|
2149
|
+
mirror: async (partId, operations, references) => {
|
|
2150
|
+
const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
|
|
2151
|
+
const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
|
|
2152
|
+
const rReferences = await new Promise(res => this.resolve(paths => res(paths), ...references));
|
|
2153
|
+
const cDrawing = getDrawing(drawingId);
|
|
2154
|
+
const entArray = [];
|
|
2155
|
+
for (const rOperation of rOperations) {
|
|
2156
|
+
const entities = cDrawing.structure.tree[rOperation].children;
|
|
2157
|
+
if (entities != undefined) {
|
|
2158
|
+
entArray.push(entities[0]);
|
|
2159
|
+
}
|
|
2160
|
+
}
|
|
2161
|
+
const mirrorId = await featureAPI.createFeature(rPartId, CCClasses.CCMirror, 'Mirror');
|
|
2162
|
+
if (mirrorId != null) {
|
|
2163
|
+
await featureAPI.updateMirror(mirrorId, entArray, rReferences);
|
|
2164
|
+
return mirrorId;
|
|
2165
|
+
}
|
|
2166
|
+
return null;
|
|
2167
|
+
},
|
|
2168
|
+
removeOperations: async (operations, toOperation) => {
|
|
2169
|
+
const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
|
|
2170
|
+
const [rToOperation] = await new Promise(res => this.resolve(paths => res(paths), toOperation));
|
|
2171
|
+
if (operations && operations.length > 0) {
|
|
2172
|
+
await baseModelerAPI.deleteObjects(rOperations);
|
|
2173
|
+
}
|
|
2174
|
+
else if (rToOperation) {
|
|
2175
|
+
const toRemoveOps = [];
|
|
2176
|
+
const cDrawing = getDrawing(drawingId);
|
|
2177
|
+
const tree = cDrawing.structure.tree;
|
|
2178
|
+
const opSeq = cDrawing.api.structure.filterTree(tree, obj => obj.name === 'OperationSequence').pop();
|
|
2179
|
+
const opRefs = opSeq && baseUtils.getChildren(opSeq.id, CCClasses.CCObjectReference, tree);
|
|
2180
|
+
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; });
|
|
2181
|
+
if (filteredOps) {
|
|
2182
|
+
let opNotFound = true;
|
|
2183
|
+
let index = filteredOps.length - 2; // -2 => Avoid RollBackBar
|
|
2184
|
+
while (opNotFound) {
|
|
2185
|
+
if (filteredOps[index] !== rToOperation) {
|
|
2186
|
+
toRemoveOps.push(filteredOps[index]);
|
|
2187
|
+
}
|
|
2188
|
+
else {
|
|
2189
|
+
opNotFound = false;
|
|
2190
|
+
}
|
|
2191
|
+
index--;
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
await baseModelerAPI.deleteObjects(toRemoveOps);
|
|
2195
|
+
}
|
|
2196
|
+
},
|
|
2197
|
+
getMatePath: async (refId) => {
|
|
2198
|
+
return this.resolve(async ([rRefId]) => {
|
|
2199
|
+
return asmUtils.getMatePath(drawingId, rRefId);
|
|
2200
|
+
}, refId);
|
|
2201
|
+
},
|
|
2202
|
+
slice: async (partId, operations, reference, sideFlag) => {
|
|
2203
|
+
const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
|
|
2204
|
+
const rOperations = await new Promise(res => this.resolve(ids => res(ids), ...operations));
|
|
2205
|
+
const [rReference] = await new Promise(res => this.resolve(paths => res(paths), reference));
|
|
2206
|
+
const cDrawing = getDrawing(drawingId);
|
|
2207
|
+
const entArray = [];
|
|
2208
|
+
for (const rOperation of rOperations) {
|
|
2209
|
+
const entities = cDrawing.structure.tree[rOperation].children;
|
|
2210
|
+
if (entities != undefined && entities.length > 0) {
|
|
2211
|
+
entArray.push(entities[0]); // use first entity of operation
|
|
2212
|
+
}
|
|
2213
|
+
}
|
|
2214
|
+
const sliceId = await featureAPI.createFeature(rPartId, CCClasses.CCSlice, 'Slice');
|
|
2215
|
+
if (sliceId != null) {
|
|
2216
|
+
await featureAPI.openFeature(sliceId);
|
|
2217
|
+
if (entArray.length > 0) {
|
|
2218
|
+
await featureAPI.updateSlice(sliceId, entArray, rReference, sideFlag ? 1 : 0);
|
|
2219
|
+
await featureAPI.closeFeature(sliceId);
|
|
2220
|
+
return sliceId;
|
|
2221
|
+
}
|
|
2222
|
+
await featureAPI.closeFeature(sliceId);
|
|
2223
|
+
await baseModelerAPI.deleteObjects([sliceId]);
|
|
2224
|
+
}
|
|
2225
|
+
return null;
|
|
2226
|
+
},
|
|
2227
|
+
sliceBySheet: async (partId, operationToSlice, operationOfSheet, sideFlag) => {
|
|
2228
|
+
const [rPartId] = await new Promise(res => this.resolve(ids => res(ids), partId));
|
|
2229
|
+
const [rOperationToSlice] = await new Promise(res => this.resolve(ids => res(ids), operationToSlice));
|
|
2230
|
+
const [rOperationOfSheet] = await new Promise(res => this.resolve(ids => res(ids), operationOfSheet));
|
|
2231
|
+
const entityToSlice = getDrawing(drawingId).structure.tree[rOperationToSlice].children;
|
|
2232
|
+
const entityOfSheet = getDrawing(drawingId).structure.tree[rOperationOfSheet].children;
|
|
2233
|
+
const sliceBySheetId = await featureAPI.createFeature(rPartId, CCClasses.CCSliceBySheet, 'SliceBySheet');
|
|
2234
|
+
if (sliceBySheetId != null) {
|
|
2235
|
+
await featureAPI.openFeature(sliceBySheetId);
|
|
2236
|
+
if (entityToSlice && entityToSlice.length > 0 && entityOfSheet && entityOfSheet.length > 0) {
|
|
2237
|
+
await featureAPI.updateSliceBySheet(sliceBySheetId, entityToSlice[0], entityOfSheet[0], sideFlag ? 1 : 0);
|
|
2238
|
+
await featureAPI.closeFeature(sliceBySheetId);
|
|
2239
|
+
return sliceBySheetId;
|
|
2240
|
+
}
|
|
2241
|
+
await featureAPI.closeFeature(sliceBySheetId);
|
|
2242
|
+
await baseModelerAPI.deleteObjects([sliceBySheetId]);
|
|
2243
|
+
}
|
|
2244
|
+
return null;
|
|
2245
|
+
},
|
|
2246
|
+
twist: async (param) => {
|
|
2247
|
+
return this.resolve(async ([rPartId, rSketchOrRegionIds]) => {
|
|
2248
|
+
const twist = await featureAPI.createFeature(rPartId, CCClasses.CCTwist, 'Twist');
|
|
2249
|
+
if (twist) {
|
|
2250
|
+
const resSketchOrRegionIds = Array.isArray(rSketchOrRegionIds)
|
|
2251
|
+
? rSketchOrRegionIds
|
|
2252
|
+
: [rSketchOrRegionIds];
|
|
2253
|
+
if (resSketchOrRegionIds && resSketchOrRegionIds.length > 0) {
|
|
2254
|
+
const limit1Param = {
|
|
2255
|
+
value: param.limit1,
|
|
2256
|
+
isExpr: typeof param.limit1 === 'string',
|
|
2257
|
+
};
|
|
2258
|
+
const limit2Param = {
|
|
2259
|
+
value: param.limit2,
|
|
2260
|
+
isExpr: typeof param.limit2 === 'string',
|
|
2261
|
+
};
|
|
2262
|
+
const twistAngleParam = {
|
|
2263
|
+
value: param.twistAngle,
|
|
2264
|
+
isExpr: typeof param.twistAngle === 'string',
|
|
2265
|
+
};
|
|
2266
|
+
if (!param.direction) {
|
|
2267
|
+
param.direction = { x: 0, y: 0, z: 1 };
|
|
2268
|
+
}
|
|
2269
|
+
if (!param.twistCenter) {
|
|
2270
|
+
param.twistCenter = { x: 0, y: 0, z: 0 };
|
|
2271
|
+
}
|
|
2272
|
+
const resDirection = resolveVec(param.direction);
|
|
2273
|
+
const directionParam = {
|
|
2274
|
+
value: resDirection,
|
|
2275
|
+
isExpr: typeof resDirection === 'string',
|
|
2276
|
+
};
|
|
2277
|
+
const resTwistCenter = resolveVec(param.twistCenter);
|
|
2278
|
+
const twistCenterParam = {
|
|
2279
|
+
value: resTwistCenter,
|
|
2280
|
+
isExpr: typeof resTwistCenter === 'string',
|
|
2281
|
+
};
|
|
2282
|
+
await featureAPI.updateTwist(twist, resSketchOrRegionIds, param.type, limit1Param, limit2Param, directionParam, twistAngleParam, twistCenterParam, param.capEnds);
|
|
2283
|
+
return twist;
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
}, param.partId, param.sketchOrRegionIds);
|
|
2287
|
+
},
|
|
2288
|
+
};
|
|
2289
|
+
callback(publicApi);
|
|
2290
|
+
resolve(drawingId);
|
|
2291
|
+
});
|
|
2292
|
+
return () => promise.then(drawingId => api.getState().api.removeDrawing(drawingId));
|
|
2293
|
+
}
|
|
2294
|
+
destroy() {
|
|
2295
|
+
this.drawingId && api.getState().api.removeDrawing(this.drawingId);
|
|
2296
|
+
}
|
|
2297
|
+
}
|
|
2298
|
+
export class history extends History {
|
|
2299
|
+
constructor() {
|
|
2300
|
+
super();
|
|
2301
|
+
console.warn("Warning: 'history' is deprecated, use 'History' instead, 'history' will be removed in a future release.");
|
|
2302
|
+
}
|
|
2303
|
+
}
|