Skip to content

Commit dcf1f47

Browse files
committed
fix: drawing sync not reading from parent model (v3.13.1)
1 parent 90a94ac commit dcf1f47

File tree

3 files changed

+36
-55
lines changed

3 files changed

+36
-55
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

33
All notable changes to BluePLM will be documented in this file.
44

5+
## [3.13.1] - 2026-02-05
6+
7+
### Fixed
8+
- **Drawing sync not reading from parent model**: Fixed bug where "Sync Metadata" on a drawing would not update the item number from the parent part if the drawing had its own hardcoded properties. The sync now always traverses to the referenced part/assembly and reads the current values, using the drawing's own properties only as a fallback if the parent lookup fails
9+
10+
---
11+
512
## [3.13.0] - 2026-02-04
613

714
### Added

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "blue-plm",
3-
"version": "3.13.0",
3+
"version": "3.13.1",
44
"description": "Open-source Product Lifecycle Management",
55
"main": "dist-electron/main.js",
66
"scripts": {

src/lib/commands/handlers/syncMetadata.ts

Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -180,42 +180,15 @@ async function pullDrawingMetadata(fullPath: string): Promise<ExtractedMetadata
180180
}
181181
}
182182

183-
// Extract drawing's own metadata first
183+
// Extract drawing's own metadata as fallback (used if parent lookup fails)
184184
const drawingMetadata = extractMetadataFromProperties(drawingProps)
185185

186-
// Helper to check if a value is a PRP reference (needs parent model lookup)
187-
const isPrpValue = (val: string | null | undefined): boolean => {
188-
return typeof val === 'string' && (val.startsWith('$PRP:') || val.startsWith('$PRPSHEET:'))
189-
}
190-
191-
// Check if we need parent model inheritance
192-
const partNumberNeedsInheritance = !drawingMetadata.partNumber || isPrpValue(drawingMetadata.partNumber)
193-
const descriptionNeedsInheritance = !drawingMetadata.description || isPrpValue(drawingMetadata.description)
194-
195-
// Also check raw properties for PRP values
196-
const rawPartNumberKeys = ['Number', 'PartNumber', 'Part Number', 'Part No', 'Part No.']
197-
const rawDescriptionKeys = ['Description', 'Desc', 'Title']
198-
const hasRawPrpPartNumber = rawPartNumberKeys.some(key => isPrpValue(drawingProps[key]))
199-
const hasRawPrpDescription = rawDescriptionKeys.some(key => isPrpValue(drawingProps[key]))
200-
201-
const needsParentInheritance = (partNumberNeedsInheritance || hasRawPrpPartNumber) &&
202-
(descriptionNeedsInheritance || hasRawPrpDescription)
203-
204-
// If drawing has valid metadata, skip expensive getReferences call
205-
if (!needsParentInheritance) {
206-
logSync('debug', 'Drawing has valid metadata - skipping parent model lookup', {
207-
fullPath,
208-
partNumber: drawingMetadata.partNumber,
209-
description: drawingMetadata.description?.substring(0, 30)
210-
})
211-
return drawingMetadata
212-
}
213-
214-
// Need parent model inheritance - this is expensive (9-13+ seconds for complex assemblies)
215-
logSync('info', 'Drawing needs parent model inheritance', {
186+
// Always read from parent model for drawings - user expects "Sync Metadata" to pull
187+
// current values from the referenced part/assembly, not use stale drawing properties
188+
logSync('info', 'Reading metadata from parent model for drawing', {
216189
fullPath,
217-
partNumberNeedsInheritance,
218-
descriptionNeedsInheritance
190+
drawingPartNumber: drawingMetadata.partNumber,
191+
drawingDescription: drawingMetadata.description?.substring(0, 30)
219192
})
220193

221194
const drawingRefs = await getDrawingReferences(fullPath)
@@ -422,31 +395,32 @@ async function pullDrawingMetadata(fullPath: string): Promise<ExtractedMetadata
422395
}
423396
}
424397

425-
// If getReferences didn't find a valid parent, check if SW is running
426-
// This helps the user understand why inheritance didn't work for drawings
427-
if (needsParentInheritance) {
428-
// Check if SolidWorks is running - if not, we couldn't traverse drawing views
429-
try {
430-
const swStatus = await window.electronAPI?.solidworks?.getServiceStatus?.()
431-
const swRunning = swStatus?.data?.running === true
432-
433-
if (!swRunning) {
434-
logSync('warn', 'Drawing needs parent inheritance but SolidWorks is not running', {
435-
fullPath,
436-
partNumberNeedsInheritance,
437-
descriptionNeedsInheritance
438-
})
439-
return {
440-
...drawingMetadata,
441-
drawingNeedsSwButNotRunning: true
442-
}
398+
// Parent lookup failed - check if SW is running to help user understand why
399+
// (getReferences requires SW API for drawings to traverse views)
400+
try {
401+
const swStatus = await window.electronAPI?.solidworks?.getServiceStatus?.()
402+
const swRunning = swStatus?.data?.running === true
403+
404+
if (!swRunning) {
405+
logSync('warn', 'Could not read from parent model - SolidWorks is not running', {
406+
fullPath,
407+
fallbackPartNumber: drawingMetadata.partNumber
408+
})
409+
return {
410+
...drawingMetadata,
411+
drawingNeedsSwButNotRunning: true
443412
}
444-
} catch {
445-
// If we can't check SW status, just return metadata without flag
446413
}
414+
} catch {
415+
// If we can't check SW status, just return drawing metadata as fallback
447416
}
448417

449-
// Return drawing's own metadata
418+
// Fallback to drawing's own metadata if parent lookup failed
419+
logSync('warn', 'Parent model lookup failed, using drawing properties as fallback', {
420+
fullPath,
421+
partNumber: drawingMetadata.partNumber,
422+
description: drawingMetadata.description?.substring(0, 30)
423+
})
450424
return drawingMetadata
451425
}
452426

0 commit comments

Comments
 (0)