@buerli.io/headless 0.13.1-beta.7.apiversion → 0.13.1-beta.9

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.
@@ -25,7 +25,7 @@ const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray)
25
25
  const tree = cDrawing.structure.tree;
26
26
  if (object.link || object.solids) {
27
27
  // Part
28
- const baseModeler = (0, classcad_1.api)(drawingId).v0.baseModeler;
28
+ const baseModeler = (0, classcad_1.createApi)(drawingId).v0.baseModeler;
29
29
  const solids = object.link ? tree[object.link].solids : object.solids;
30
30
  if (solids != undefined) {
31
31
  let geometries = [];
@@ -81,7 +81,7 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
81
81
  const tree = cDrawing.structure.tree;
82
82
  if (object.link || object.solids) {
83
83
  // Part
84
- const baseModeler = (0, classcad_1.api)(drawingId).v0.baseModeler;
84
+ const baseModeler = (0, classcad_1.createApi)(drawingId).v0.baseModeler;
85
85
  const entities = object.link ? tree[object.link].solids : object.solids;
86
86
  if (entities != undefined) {
87
87
  const part = new three_1.Group();
@@ -222,11 +222,11 @@ class History {
222
222
  }
223
223
  init(callback) {
224
224
  const promise = new Promise(async (resolve, reject) => {
225
- const drawingId = await classcad_1.Connection.create();
225
+ const drawingId = await classcad_1.BuerliCadFacade.utils.connect('history');
226
226
  if (!drawingId)
227
227
  throw new Error('Connection/Drawing could not be created');
228
228
  this.drawingId = drawingId;
229
- const cc = (0, classcad_1.api)(drawingId);
229
+ const cc = (0, classcad_1.createApi)(drawingId);
230
230
  const featureAPI = cc.v0.feature;
231
231
  const sketcherAPI = cc.v0.sketcher;
232
232
  const baseModelerAPI = cc.v0.baseModeler;
@@ -1914,7 +1914,7 @@ class History {
1914
1914
  const featureName = name ? name : 'Import';
1915
1915
  const importFeatureId = await featureAPI.createFeature(rPartId, classcad_1.CCClasses.CCImport, featureName);
1916
1916
  if (importFeatureId !== null) {
1917
- const solids = await featureAPI.updateImport(importFeatureId, content, format, featureName);
1917
+ const solids = await featureAPI.updateImport(importFeatureId, content, format.toUpperCase(), featureName);
1918
1918
  if (solids !== null) {
1919
1919
  return importFeatureId;
1920
1920
  }
@@ -2122,6 +2122,14 @@ class History {
2122
2122
  const success = await featureAPI.updateExpressions(expressionsToSet);
2123
2123
  return success;
2124
2124
  },
2125
+ renameExpressions: (partId, members) => {
2126
+ return this.resolve(async ([rPartId]) => {
2127
+ const success = featureAPI.updateExpressions([
2128
+ { productId: rPartId, toAddMembers: [], toModifyMembers: [], toRenameMembers: members, toDeleteList: [] },
2129
+ ]);
2130
+ return success;
2131
+ }, partId);
2132
+ },
2125
2133
  deleteExpressions: (partId, members) => {
2126
2134
  return this.resolve(async ([rPartId]) => {
2127
2135
  const success = featureAPI.updateExpressions([
@@ -198,11 +198,11 @@ class Solid {
198
198
  }
199
199
  init(callback) {
200
200
  const promise = new Promise(async (resolve, reject) => {
201
- const drawingId = await classcad_1.Connection.create('solid');
201
+ const drawingId = await classcad_1.BuerliCadFacade.utils.connect('solid');
202
202
  if (!drawingId)
203
203
  throw new Error('Connection/Drawing could not be created');
204
204
  this.drawingId = drawingId;
205
- const { solid: solidAPI, baseModeler: baseModelerAPI, common: commonAPI } = (0, classcad_1.api)(drawingId).v0;
205
+ const { solid: solidAPI, baseModeler: baseModelerAPI, common: commonAPI } = (0, classcad_1.createApi)(drawingId).v0;
206
206
  await solidAPI.init();
207
207
  const publicApi = {
208
208
  getDrawingId: () => drawingId,
@@ -6,7 +6,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
6
6
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
7
7
  };
8
8
  /* eslint-disable max-lines */
9
- import { api as ccApi, CCClasses, ccUtils, DataType, SVGModusType, Connection, } from '@buerli.io/classcad';
9
+ import { createApi, CCClasses, ccUtils, DataType, SVGModusType, BuerliCadFacade, } from '@buerli.io/classcad';
10
10
  import { api, getDrawing, MathUtils, BuerliScope, createInfo, Measure, } from '@buerli.io/core';
11
11
  import { Group, Matrix4, Mesh, MeshStandardMaterial, Scene } from 'three';
12
12
  import { mergeBufferGeometries } from 'three-stdlib';
@@ -22,7 +22,7 @@ const createRecursiveBufferGeometry = async (object, drawingId, bufferGeomArray)
22
22
  const tree = cDrawing.structure.tree;
23
23
  if (object.link || object.solids) {
24
24
  // Part
25
- const baseModeler = ccApi(drawingId).v0.baseModeler;
25
+ const baseModeler = createApi(drawingId).v0.baseModeler;
26
26
  const solids = object.link ? tree[object.link].solids : object.solids;
27
27
  if (solids != undefined) {
28
28
  let geometries = [];
@@ -78,7 +78,7 @@ const createRecursiveScene = async (object, drawingId, root, result, options) =>
78
78
  const tree = cDrawing.structure.tree;
79
79
  if (object.link || object.solids) {
80
80
  // Part
81
- const baseModeler = ccApi(drawingId).v0.baseModeler;
81
+ const baseModeler = createApi(drawingId).v0.baseModeler;
82
82
  const entities = object.link ? tree[object.link].solids : object.solids;
83
83
  if (entities != undefined) {
84
84
  const part = new Group();
@@ -219,11 +219,11 @@ export class History {
219
219
  }
220
220
  init(callback) {
221
221
  const promise = new Promise(async (resolve, reject) => {
222
- const drawingId = await Connection.create();
222
+ const drawingId = await BuerliCadFacade.utils.connect('history');
223
223
  if (!drawingId)
224
224
  throw new Error('Connection/Drawing could not be created');
225
225
  this.drawingId = drawingId;
226
- const cc = ccApi(drawingId);
226
+ const cc = createApi(drawingId);
227
227
  const featureAPI = cc.v0.feature;
228
228
  const sketcherAPI = cc.v0.sketcher;
229
229
  const baseModelerAPI = cc.v0.baseModeler;
@@ -1911,7 +1911,7 @@ export class History {
1911
1911
  const featureName = name ? name : 'Import';
1912
1912
  const importFeatureId = await featureAPI.createFeature(rPartId, CCClasses.CCImport, featureName);
1913
1913
  if (importFeatureId !== null) {
1914
- const solids = await featureAPI.updateImport(importFeatureId, content, format, featureName);
1914
+ const solids = await featureAPI.updateImport(importFeatureId, content, format.toUpperCase(), featureName);
1915
1915
  if (solids !== null) {
1916
1916
  return importFeatureId;
1917
1917
  }
@@ -2119,6 +2119,14 @@ export class History {
2119
2119
  const success = await featureAPI.updateExpressions(expressionsToSet);
2120
2120
  return success;
2121
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
+ },
2122
2130
  deleteExpressions: (partId, members) => {
2123
2131
  return this.resolve(async ([rPartId]) => {
2124
2132
  const success = featureAPI.updateExpressions([
@@ -6,7 +6,7 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
6
6
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
7
7
  };
8
8
  /* eslint-disable max-lines */
9
- import { api as ccApi, Connection } from '@buerli.io/classcad';
9
+ import { createApi, BuerliCadFacade } from '@buerli.io/classcad';
10
10
  import { api, getDrawing } from '@buerli.io/core';
11
11
  import { Group, Mesh, MeshStandardMaterial, Scene } from 'three';
12
12
  import { mergeBufferGeometries } from 'three-stdlib';
@@ -194,11 +194,11 @@ export class Solid {
194
194
  }
195
195
  init(callback) {
196
196
  const promise = new Promise(async (resolve, reject) => {
197
- const drawingId = await Connection.create('solid');
197
+ const drawingId = await BuerliCadFacade.utils.connect('solid');
198
198
  if (!drawingId)
199
199
  throw new Error('Connection/Drawing could not be created');
200
200
  this.drawingId = drawingId;
201
- const { solid: solidAPI, baseModeler: baseModelerAPI, common: commonAPI } = ccApi(drawingId).v0;
201
+ const { solid: solidAPI, baseModeler: baseModelerAPI, common: commonAPI } = createApi(drawingId).v0;
202
202
  await solidAPI.init();
203
203
  const publicApi = {
204
204
  getDrawingId: () => drawingId,
@@ -2,6 +2,8 @@ import { BooleanOperationType, ChamferType, FlipType, ReorientedType, WorkAxisTy
2
2
  import { DrawingID, InteractionInfo, GeometryElement, DrawingState, BuerliState } from '@buerli.io/core';
3
3
  import { BufferGeometry, Material, Object3D, Scene } from 'three';
4
4
  /**
5
+ * @deprecated replaced by @see BuerliCadFacade in buerli.io/classcad
6
+ *
5
7
  * History based modeling is similar to solid modeling, but it is non-destructive and
6
8
  * parametric. You can move back and forth in the modeling history and create feature
7
9
  * expressions which you can alter at a later time, prompting your model to re-calculate.
@@ -1515,6 +1517,24 @@ export declare type ApiHistory = {
1515
1517
  value: number | string;
1516
1518
  }[];
1517
1519
  }[]) => Promise<boolean>;
1520
+ /**
1521
+ * Renames existing expressions.
1522
+ * @param partId id or identifier of part to rename expressions from
1523
+ * @param members name of members to rename
1524
+ * @example
1525
+ * // Renames an expression from part's expression set
1526
+ * const part = api.createPart('Part')
1527
+ * api.createExpressions(part, { name: 'width', value: 20 }, { name: 'h', value: 40 })
1528
+ * api.renameExpressions(part, [{ name: 'h', newName: 'height'}])
1529
+ * await api.box(part, [], 20, 20, 'ExpressionSet.height')
1530
+ * const geoms = await api.createBufferGeometry(part)
1531
+ * return geoms.map(geom => new THREE.Mesh(geom, new THREE.MeshStandardMaterial()))
1532
+ * @return true or false, depending on whether renaming the expressions was successful or not
1533
+ */
1534
+ renameExpressions: (partId: VID | ObjectIdent, members: {
1535
+ name: string;
1536
+ newName: string;
1537
+ }[]) => Promise<boolean>;
1518
1538
  /**
1519
1539
  * Creates a mirror operation.
1520
1540
  * Mirrors the entities of an operation at the position of the plane reference
@@ -2,6 +2,8 @@ import { ObjectID } from '@buerli.io/classcad';
2
2
  import { BuerliState, DrawingID, DrawingState } from '@buerli.io/core';
3
3
  import { BufferGeometry, Scene, Vector3 } from 'three';
4
4
  /**
5
+ * @deprecated replaced by @see BuerliCadFacade in buerli.io/classcad
6
+ *
5
7
  * A simple and intuitive javascript based api that incorporates solid operations like
6
8
  * shapes, booleans (unions, subtracts, intersections), extrusions, revolves, blends,
7
9
  * chamfers, slices, arrays, patterns, offsets, etc. The api is compatible with THREEJS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buerli.io/headless",
3
- "version": "0.13.1-beta.7.apiversion",
3
+ "version": "0.13.1-beta.9",
4
4
  "description": "A non-manifold CAD workflow for the web",
5
5
  "author": "AWV Informatik AG <info@awv-informatik.ch>",
6
6
  "license": "ISC",
@@ -32,7 +32,7 @@
32
32
  "three-stdlib": ">=2.11.0"
33
33
  },
34
34
  "dependencies": {
35
- "@buerli.io/classcad": "0.13.1-beta.7.apiversion",
35
+ "@buerli.io/classcad": "0.13.1-beta.9",
36
36
  "flat-promise": "^1.0.3"
37
37
  }
38
38
  }