Skip to content

Commit d0288cd

Browse files
update to assembly parsing.
1 parent 7603813 commit d0288cd

23 files changed

Lines changed: 2777 additions & 29 deletions

packages/dev/core/lib/api/context.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ export interface PreviewCSVInterface {
1616
hidden?: boolean;
1717
}
1818

19+
export interface PreviewAssemblyHierarchyInterface {
20+
data: any;
21+
hidden?: boolean;
22+
}
23+
1924
export class ContextBase {
2025
blocklyWorkspace: any;
2126
verb: any;
@@ -27,6 +32,7 @@ export class ContextBase {
2732
promptPrint: (prompt: PrintSaveInterface) => void;
2833
promptPreviewData: (data: PreviewDataInterface) => void;
2934
promptPreviewCSV: (data: PreviewCSVInterface) => void;
35+
promptPreviewAssemblyHierarchy: (data: PreviewAssemblyHierarchyInterface) => void;
3036

3137
rerenderScene: () => void;
3238
tolerance = 0.00001;

packages/dev/occt-worker/lib/api/occt/assembly/manager.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,42 @@ export class OCCTAssemblyManager {
9292
return this.occWorkerManager.genericCallToWorkerPromise("assembly.manager.createInstanceNode", inputs);
9393
}
9494

95+
/**
96+
* Create a part update definition for modifying an existing part in a document.
97+
* Part updates can change the shape, name, and/or color of an existing part.
98+
*
99+
* @param inputs - Update details including label and optional new shape/name/color
100+
* @returns Part update definition that can be added to an assembly structure's partUpdates array
101+
* @group assembly
102+
* @shortname create part update
103+
* @drawable false
104+
*
105+
* @example
106+
* ```typescript
107+
* // Get existing parts from document
108+
* const parts = await occt.assembly.query.getDocumentParts({ document });
109+
*
110+
* // Create a new shape to replace the old one
111+
* const newBox = await occt.shapes.solid.createBox({ width: 20, length: 20, height: 20 });
112+
*
113+
* // Create an update definition
114+
* const update = await occt.assembly.manager.createPartUpdate({
115+
* label: parts[0].label,
116+
* shape: newBox,
117+
* name: "Bigger Box",
118+
* colorRgba: { r: 0, g: 1, b: 0, a: 1 }
119+
* });
120+
*
121+
* // Combine with structure and rebuild
122+
* const structure = await occt.assembly.manager.combineStructure({ parts: [], nodes: [], partUpdates: [update] });
123+
* await occt.assembly.manager.buildAssemblyDocument({ structure, existingDocument: document });
124+
* ```
125+
*/
126+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
127+
async createPartUpdate(inputs: Inputs.OCCT.CreatePartUpdateDto<any>): Promise<Models.OCCT.AssemblyPartUpdateDef<any>> {
128+
return this.occWorkerManager.genericCallToWorkerPromise("assembly.manager.createPartUpdate", inputs);
129+
}
130+
95131
/**
96132
* Combine parts and nodes into a complete assembly structure definition.
97133
* This is the final step before calling buildAssemblyDocument.

packages/dev/occt/bitbybit-dev-occt-64-bit-mt/bitbybit-dev-occt-64-bit-mt.95baabc7.wasm renamed to packages/dev/occt/bitbybit-dev-occt-64-bit-mt/bitbybit-dev-occt-64-bit-mt.c14311b1.wasm

20.8 MB
Binary file not shown.

packages/dev/occt/bitbybit-dev-occt-64-bit-mt/bitbybit-dev-occt-64-bit-mt.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dev/occt/bitbybit-dev-occt-64-bit-mt/cdn.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { GlobalCDNProvider } from "@bitbybit-dev/base";
1313
* @returns Promise that resolves to the initialized OCCT module
1414
*/
1515
const createBitbybitDevOcct = (moduleOverrides = {}) => {
16-
const cdnWasmUrl = GlobalCDNProvider.BITBYBIT_CDN_URL + "/wasm/bitbybit-dev-occt-64-bit-mt.95baabc7.wasm";
16+
const cdnWasmUrl = GlobalCDNProvider.BITBYBIT_CDN_URL + "/wasm/bitbybit-dev-occt-64-bit-mt.c14311b1.wasm";
1717

1818
// If user provided their own locateFile, wrap it to preserve their customizations
1919
const userLocateFile = moduleOverrides.locateFile;

packages/dev/occt/bitbybit-dev-occt-64-bit/bitbybit-dev-occt-64-bit.911a10a8.wasm renamed to packages/dev/occt/bitbybit-dev-occt-64-bit/bitbybit-dev-occt-64-bit.531f1660.wasm

22.9 MB
Binary file not shown.

packages/dev/occt/bitbybit-dev-occt-64-bit/bitbybit-dev-occt-64-bit.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/dev/occt/bitbybit-dev-occt-64-bit/cdn.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@ import { GlobalCDNProvider } from "@bitbybit-dev/base";
1414
* @returns Promise that resolves to the initialized OCCT module
1515
*/
1616
const createBitbybitDevOcct = (moduleOverrides = {}) => {
17-
const cdnWasmUrl = GlobalCDNProvider.BITBYBIT_CDN_URL + "/wasm/bitbybit-dev-occt-64-bit.b96ec633.wasm";
17+
const cdnWasmUrl = GlobalCDNProvider.BITBYBIT_CDN_URL + "/wasm/bitbybit-dev-occt-64-bit.531f1660.wasm";
18+
1819
// If user provided their own locateFile, wrap it to preserve their customizations
1920
const userLocateFile = moduleOverrides.locateFile;
20-
21+
2122
return createBitbybitDevOcctOriginal({
2223
...moduleOverrides,
2324
locateFile(path, scriptDirectory) {

packages/dev/occt/bitbybit-dev-occt/bitbybit-dev-occt.d.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ export interface BitbybitOcctModule {
430430
* Build an assembly document from a structure definition and return the document handle directly.
431431
* The caller is responsible for managing the document lifetime.
432432
*
433-
* Structure JSON format:
433+
* Structure JSON format (for creating new assembly):
434434
* {
435435
* "parts": [
436436
* { "id": "part-1", "shapeIndex": 0, "name": "Box", "color": { "r": 1, "g": 0, "b": 0, "a": 1 } }
@@ -442,9 +442,18 @@ export interface BitbybitOcctModule {
442442
* ]
443443
* }
444444
*
445-
* @param structureJson - JSON string with assembly structure
446-
* @param shapesArray - Array of TopoDS_Shape objects, referenced by shapeIndex in parts
447-
* @param existingDoc - Optional existing document handle to reuse (clears and updates instead of creating new)
445+
* When updating an existing document, you can also include:
446+
* - "removals": ["0:1:1:2", "0:1:1:3:1"] - Labels to remove (parts, instances, or assemblies)
447+
* - "partUpdates": [{ "label": "0:1:1:1", "shapeIndex": 0, "name": "New Name", "color": {...} }] - Updates to apply
448+
*
449+
* Processing order for updates:
450+
* 1. Removals are applied first
451+
* 2. Part updates are applied second
452+
* 3. New parts and nodes are added last
453+
*
454+
* @param structureJson - JSON string with assembly structure (parts, nodes, optional removals/partUpdates)
455+
* @param shapesArray - Array of TopoDS_Shape objects, referenced by shapeIndex in parts and partUpdates
456+
* @param existingDoc - Optional existing document handle to update (for removals/partUpdates/additions)
448457
* @returns Handle to the created/updated document. Call IsNull() to check for errors.
449458
*/
450459
BuildAssemblyDocument(structureJson: string, shapesArray: TopoDS_Shape[], existingDoc?: Handle_TDocStd_Document): Handle_TDocStd_Document;

packages/dev/occt/bitbybit-dev-occt/bitbybit-dev-occt.c1ca00b0.wasm renamed to packages/dev/occt/bitbybit-dev-occt/bitbybit-dev-occt.dec37f82.wasm

22.6 MB
Binary file not shown.

0 commit comments

Comments
 (0)