.swp macro

Set Custom Property: write a property across files

Writes one custom property across every file in the scope. Works on parts, assemblies and drawings.

Properties

PRT PartsASM AssembliesDRW Drawings

Download Set Custom Property.swp Get SwMacroFlow

Put the downloaded file in this folder, then open SwMacroFlow and choose it from the library.

%LOCALAPPDATA%\SwMacroFlow\macros

Runs per file — point the scope at a folder and it writes the property into each document in turn.

Inputs

FieldPurpose
PropertyNameThe property to write, for example PartNumber. Required.
PropertyValueThe value. {Property} and {FileName} placeholders are resolved per document, so {FileName} writes each file's own name and {PartNumber}-{Revision} composes from existing properties.
ScopeFile, Active configuration, or All configurations.
OnlyIfMissingOff by default. Tick it to leave documents that already have the property untouched.

Scope is not a hierarchy

File-level properties and configuration-specific properties are separate stores, not a default and an override. Writing to File does not give the configurations the value, and writing to All configurations does not put it in the file-level store. Pick the one your drawing template and BOM actually read.

Results

OutcomeMeaning
OKThe property was written and the document was saved. The message says how many targets changed.
WarningEvery target already had the property and OnlyIfMissing is on. Nothing was changed and nothing was saved.
ErrorRead-only, never saved, no such configuration, or the save itself failed — each reported with the specific cause.

Notes

It saves the document. SwMacroFlow closes each file with CloseAllDocuments(True), which discards unsaved changes. A property written and not saved would be thrown away when the file closes, reporting a clean run for a file that never changed on disk. Read-only documents are therefore rejected before anything is written, rather than after — SOLIDWORKS accepts the property into the in-memory document quite happily and only refuses at save time.

Existing properties keep their type and their links. The write uses swCustomPropertyReplaceValue rather than delete-and-re-add, so a property linked to a dimension or an equation keeps that link. New properties are created as text, because the value it is given is free text and a property typed as Number or Date rejects anything it cannot parse.

OnlyIfMissing counts a linked property as present. A property driven by a dimension or equation resolves rather than reads from cache, and both count as existing.

Chaining

Place it before any export macro in a chain so the exported file carries the new value. It saves but does not close or rebuild the document, so later macros see the saved state.

Two copies of this macro in one chain write two different properties in one pass over the files — each row in the chain keeps its own inputs.