Skip to content

Commit 77c006b

Browse files
committed
v3.5.0: STL export settings, serial operation queue, performance improvements
1 parent 49cd9b3 commit 77c006b

File tree

79 files changed

+5911
-577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+5911
-577
lines changed

.cursor/plans/extensible_module_architecture.plan.md

Lines changed: 1393 additions & 0 deletions
Large diffs are not rendered by default.

.cursor/reports/AGENT1_REPORT.md

Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
# Agent 1 Report: SolidWorks C# Service - STL Export Implementation
2+
3+
## Summary
4+
5+
Successfully implemented STL export functionality in the BluePLM SolidWorks Service with full support for resolution and format options.
6+
7+
## Changes Made
8+
9+
### 1. `SolidWorksAPI.cs` - Added `ExportToStl` Method
10+
11+
**Location:** Lines 977-1143 (new method)
12+
13+
Added a comprehensive `ExportToStl` method with the following features:
14+
15+
- **Multi-configuration export:** Supports exporting single config, specific configs, or all configs
16+
- **STL quality options:**
17+
- `coarse` - Fast, low-poly output
18+
- `fine` - Default, good balance of quality and size
19+
- `custom` - User-defined deviation and angle tolerances
20+
- **Binary vs ASCII format:** Binary (smaller files) or ASCII (human-readable)
21+
- **Filename pattern support:** Uses existing pattern substitution like STEP export
22+
- **PDM metadata fallback:** Inherits metadata fallback pattern from STEP export
23+
- **File type validation:** Only allows .sldprt and .sldasm files
24+
25+
**Method Signature:**
26+
```csharp
27+
public CommandResult ExportToStl(
28+
string? filePath,
29+
string? outputPath,
30+
string? configuration,
31+
bool exportAllConfigs,
32+
string[]? configurations = null,
33+
string? resolution = "fine",
34+
bool binaryFormat = true,
35+
double? customDeviation = null,
36+
double? customAngle = null,
37+
string? filenamePattern = null,
38+
PdmMetadata? pdmMetadata = null)
39+
```
40+
41+
### 2. `SolidWorksAPI.cs` - Added `SetStlExportOptions` Helper Method
42+
43+
**Location:** Lines 1145-1179 (new method)
44+
45+
Private helper method that sets SolidWorks user preferences for STL export:
46+
47+
- `swSTLQuality` - Sets quality level (0=Coarse, 1=Fine, 2=Custom)
48+
- `swExportStlBinary` (preference 73) - Sets binary/ASCII format
49+
- `swSTLDeviation` - Custom chord deviation in meters (when using custom quality)
50+
- `swSTLAngleTolerance` - Custom angle tolerance in radians (when using custom quality)
51+
52+
### 3. `Program.cs` - Added `exportStl` Action Routing
53+
54+
**Location:** Line 228-238 (new case in switch statement)
55+
56+
Added routing for the `exportStl` action with all parameters:
57+
- `filePath`, `outputPath`, `configuration`
58+
- `exportAllConfigs`, `configurations`
59+
- `resolution` (defaults to "fine")
60+
- `binaryFormat` (defaults to true)
61+
- `customDeviation`, `customAngle`
62+
- `filenamePattern`, `pdmMetadata`
63+
64+
## Build Status
65+
66+
**Build successful** - Code compiles without errors
67+
68+
```
69+
BluePLM.SolidWorksService -> bin\Release\BluePLM.SolidWorksService.exe
70+
71+
Build succeeded.
72+
6 Warning(s)
73+
0 Error(s)
74+
```
75+
76+
The build completed successfully with 0 errors. The 6 warnings are all pre-existing nullability warnings in other parts of the codebase (DocumentManagerAPI.cs and existing code in SolidWorksAPI.cs), not from the new STL export implementation.
77+
78+
## Testing Notes
79+
80+
To test the STL export:
81+
82+
1. Restart the dev server to pick up the new executable
83+
2. Right-click a part or assembly configuration
84+
3. Select "Export STL"
85+
4. Verify STL file is created with correct quality settings
86+
87+
### JSON Command Format
88+
89+
```json
90+
{
91+
"action": "exportStl",
92+
"filePath": "C:\\path\\to\\file.sldprt",
93+
"outputPath": "C:\\output\\path",
94+
"configuration": "Default",
95+
"exportAllConfigs": false,
96+
"configurations": ["Config1", "Config2"],
97+
"resolution": "fine",
98+
"binaryFormat": true,
99+
"customDeviation": 0.1,
100+
"customAngle": 5.0,
101+
"filenamePattern": "{partNumber}.stl",
102+
"pdmMetadata": {
103+
"partNumber": "BR-12345",
104+
"revision": "A",
105+
"description": "Test part"
106+
}
107+
}
108+
```
109+
110+
## Files Modified
111+
112+
| File | Type of Change |
113+
|------|----------------|
114+
| `SolidWorksAPI.cs` | Added `ExportToStl` and `SetStlExportOptions` methods |
115+
| `Program.cs` | Added `exportStl` action routing |
116+
117+
## Dependencies for Other Agents
118+
119+
- **Agent 2 (Electron IPC):** Can now implement `solidworks:export-stl` handler that calls `sendSWCommand({ action: 'exportStl', ... })`
120+
- **Agent 3 (Frontend):** Can now pass STL settings to the export call
121+
122+
## Notes
123+
124+
- The STL binary format setting uses user preference value 73 (`swExportStlBinary`) rather than an enum constant, as the enum may not be available in all SolidWorks API versions
125+
- Custom deviation is converted from mm to meters (divide by 1000)
126+
- Custom angle is converted from degrees to radians (multiply by π/180)

.cursor/reports/AGENT2_REPORT.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Agent 2 Report: Electron IPC Layer for STL Export
2+
3+
## Summary
4+
5+
Successfully implemented the Electron IPC handler for STL export with full support for resolution and format options.
6+
7+
## Changes Made
8+
9+
### 1. `electron/handlers/solidworks.ts` (lines ~1088)
10+
11+
Added `solidworks:export-stl` IPC handler after the existing `export-iges` handler:
12+
13+
```typescript
14+
ipcMain.handle('solidworks:export-stl', async (_, filePath: string, options?: {
15+
outputPath?: string;
16+
exportAllConfigs?: boolean;
17+
configurations?: string[];
18+
resolution?: 'coarse' | 'fine' | 'custom';
19+
binaryFormat?: boolean;
20+
filenamePattern?: string;
21+
pdmMetadata?: { partNumber?: string; tabNumber?: string; revision?: string; description?: string };
22+
}) => {
23+
return sendSWCommand({ action: 'exportStl', filePath, ...options })
24+
})
25+
```
26+
27+
### 2. `electron/preload.ts` (lines ~367)
28+
29+
Added `exportStl` function to the preload API (was previously missing!):
30+
31+
```typescript
32+
exportStl: (filePath: string, options?: {
33+
outputPath?: string;
34+
exportAllConfigs?: boolean;
35+
configurations?: string[];
36+
resolution?: 'coarse' | 'fine' | 'custom';
37+
binaryFormat?: boolean;
38+
filenamePattern?: string;
39+
pdmMetadata?: { partNumber?: string; tabNumber?: string; revision?: string; description?: string };
40+
}) =>
41+
ipcRenderer.invoke('solidworks:export-stl', filePath, options),
42+
```
43+
44+
### 3. `src/electron.d.ts` (line 320)
45+
46+
Updated `exportStl` type signature to include STL-specific options:
47+
48+
```typescript
49+
exportStl: (filePath: string, options?: {
50+
outputPath?: string;
51+
exportAllConfigs?: boolean;
52+
configurations?: string[];
53+
resolution?: 'coarse' | 'fine' | 'custom';
54+
binaryFormat?: boolean;
55+
filenamePattern?: string;
56+
pdmMetadata?: { partNumber?: string; tabNumber?: string; revision?: string; description?: string };
57+
}) =>
58+
Promise<{ success: boolean; data?: { inputFile: string; exportedFiles: string[]; count: number }; error?: string }>
59+
```
60+
61+
**Note:** Also updated the return type from `outputFile: string` to `exportedFiles: string[]` to support multi-configuration export (matching the STEP export pattern).
62+
63+
## STL Options Supported
64+
65+
| Option | Type | Description |
66+
|--------|------|-------------|
67+
| `outputPath` | `string` | Custom output directory |
68+
| `exportAllConfigs` | `boolean` | Export all configurations |
69+
| `configurations` | `string[]` | Specific configurations to export |
70+
| `resolution` | `'coarse' \| 'fine' \| 'custom'` | STL mesh quality |
71+
| `binaryFormat` | `boolean` | true = binary (smaller), false = ASCII |
72+
| `filenamePattern` | `string` | Filename pattern with placeholders |
73+
| `pdmMetadata` | `object` | PDM metadata for filename substitution |
74+
75+
## Verification
76+
77+
- ✅ No linting errors in modified files
78+
- ✅ TypeScript compilation passes for modified files
79+
- ⚠️ Pre-existing error in `extensionsSlice.ts:269` (unrelated to this change)
80+
81+
## Dependencies
82+
83+
- **Depends on Agent 1:** C# `ExportToStl` method must be implemented for the IPC handler to function
84+
- **Depended on by Agent 3:** Frontend can now use the updated `exportStl` API with STL options

.cursor/reports/AGENT3_REPORT.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# Agent 3 Report: Frontend Types and UI
2+
3+
## Summary
4+
5+
Successfully implemented STL resolution settings in the frontend, including gap fixes for the Electron layer and complete UI implementation.
6+
7+
## Changes Made
8+
9+
### Part A: Gap Fixes (Missing Electron Parameters)
10+
11+
Added `customDeviation?: number` and `customAngle?: number` to all three files:
12+
13+
1. **`electron/handlers/solidworks.ts`** (line ~1095)
14+
- Added parameters to `solidworks:export-stl` handler options
15+
16+
2. **`electron/preload.ts`** (line ~373)
17+
- Added parameters to `exportStl` function options
18+
19+
3. **`src/electron.d.ts`** (line ~326)
20+
- Added parameters to `exportStl` type signature
21+
22+
### Part B: Frontend Types
23+
24+
**`src/types/pdm.ts`**
25+
26+
Added STL-specific fields to `ExportSettings` interface:
27+
```typescript
28+
// STL-specific settings
29+
stl_resolution?: 'coarse' | 'fine' | 'custom'
30+
stl_binary_format?: boolean // true = binary (smaller), false = ASCII
31+
stl_custom_deviation?: number // mm, only for custom resolution
32+
stl_custom_angle?: number // degrees, only for custom resolution
33+
```
34+
35+
Updated `DEFAULT_EXPORT_SETTINGS` with sensible defaults:
36+
```typescript
37+
stl_resolution: 'fine',
38+
stl_binary_format: true,
39+
stl_custom_deviation: 0.1, // mm
40+
stl_custom_angle: 10 // degrees
41+
```
42+
43+
### Part C: Frontend UI
44+
45+
**`src/features/settings/system/ExportSettings.tsx`**
46+
47+
Added new "STL Export Options" section with:
48+
- Resolution quality selector (Coarse/Fine/Custom buttons with descriptions)
49+
- Custom resolution inputs (Deviation in mm, Angle in degrees) - only visible when Custom is selected
50+
- Binary format toggle with explanation
51+
52+
**`src/features/source/browser/hooks/useConfigHandlers.ts`**
53+
54+
Updated STL export case in `handleExportConfigs` to pass all settings:
55+
- `resolution`
56+
- `binaryFormat`
57+
- `customDeviation`
58+
- `customAngle`
59+
- `filenamePattern`
60+
- `pdmMetadata`
61+
62+
**`src/features/source/browser/components/ContextMenu/actions/ExportActions.tsx`**
63+
64+
Updated STL export case in `handleExport` to pass all settings.
65+
66+
## Verification
67+
68+
**TypeScript check passed** - `npm run typecheck` completed with no errors
69+
70+
## Files Modified
71+
72+
| File | Change Type |
73+
|------|-------------|
74+
| `electron/handlers/solidworks.ts` | Gap fix |
75+
| `electron/preload.ts` | Gap fix |
76+
| `src/electron.d.ts` | Gap fix |
77+
| `src/types/pdm.ts` | Type additions |
78+
| `src/features/settings/system/ExportSettings.tsx` | UI section added |
79+
| `src/features/source/browser/hooks/useConfigHandlers.ts` | Export call updated |
80+
| `src/features/source/browser/components/ContextMenu/actions/ExportActions.tsx` | Export call updated |
81+
82+
## UI Preview
83+
84+
The new STL Export Options section appears after "Additional Options" in Settings → Export Options:
85+
86+
- **Resolution Quality**: Three buttons (Coarse/Fine/Custom) with contextual descriptions
87+
- **Custom settings**: Only visible when "Custom" is selected, shows deviation (mm) and angle (degrees) inputs
88+
- **Binary format toggle**: Checkbox with explanation about file size vs readability
89+
90+
All UI follows existing patterns in the component and uses consistent styling (violet accent color for STL to match the STL icon color in context menus).

.cursor/reports/Untitled

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The report file is in the Reports folder in the bluePLM repo.

CHANGELOG.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,36 @@ All notable changes to BluePLM will be documented in this file.
66

77
---
88

9+
## [3.5.0] - 2026-01-12
10+
11+
### Added
12+
- **STL Export Quality Settings**: New export options in Settings → Export Options for STL files:
13+
- **Resolution presets**: Coarse (faster, smaller), Fine (recommended for 3D printing), or Custom
14+
- **Custom deviation/angle**: Fine-grained control over mesh quality when using Custom resolution
15+
- **Binary/ASCII format**: Toggle between compact binary STL or human-readable ASCII format
16+
- **File Operation Tracker**: New DevTools panel showing real-time progress of file operations (checkout, checkin, sync) with step-by-step timing breakdowns for debugging performance issues
17+
- **Serial number race condition protection**: New `update_serialization_settings_safe` RPC function prevents counter overwrites when multiple users generate part numbers simultaneously
18+
19+
### Performance
20+
- **Serial file operation queue**: Checkout, checkin, sync, download, and discard operations now execute serially through a queue system. This prevents overlapping operations, provides cleaner progress feedback, and eliminates race conditions when rapidly clicking multiple files
21+
- **Batch setReadonly calls**: File operations now collect all paths and make a single IPC call to set file permissions, instead of one call per file
22+
- **Incremental flush optimization**: For large batches (50+ files), incremental UI updates are skipped during processing to avoid expensive React re-renders. Final update happens once at completion
23+
- **Backup panel two-phase loading**: Config loads first (~100ms) so the UI renders immediately, while snapshots load in the background (~30s for large repositories). Previously the entire panel was blocked until snapshots finished loading
24+
- **Debounced realtime updates**: Local file modifications are tracked for 5 seconds to prevent stale realtime events from reverting local changes
25+
26+
### Fixed
27+
- **Metadata property priority**: "Number" property is now checked first when extracting part numbers from SolidWorks files. Previously "Base Item Number" was checked first, which could contain legacy/template values that incorrectly overrode user edits saved via "Save to File"
28+
- **Cross-machine checkout release**: Releasing a checkout from a different machine now properly updates the local UI. Previously, if you checked out a file on Machine A and released it from Machine B, Machine A would still show the file as checked out until refresh
29+
- **Pending metadata preserved on realtime updates**: Files with unsaved local edits (pending metadata) are now protected from realtime event overwrites. This fixes the bug where typing in a datacard field could be interrupted by a stale database update
30+
- **Part number not clearing on discard**: Clearing the part number field in the datacard now properly persists `null` instead of being ignored. Previously, clearing a field would revert to the original value on the next update
31+
- **Metadata merged on clear**: When pending metadata is cleared after save, the values are now merged into pdmData so the UI continues showing the saved values without requiring a refresh
32+
33+
### Changed
34+
- **hasPendingConfigChanges → hasPendingMetadataChanges**: Renamed function to reflect that it now checks ALL pending metadata (part number, description, revision) not just config-specific changes
35+
- **Schema version**: Bumped to v42
36+
37+
---
38+
939
## [3.4.0] - 2026-01-10
1040

1141
### Added

0 commit comments

Comments
 (0)