All Resources
Code SnippetSolidWorks API2026-03-13
Read & Write SolidWorks Custom Properties
Access and modify custom properties on SolidWorks documents and configurations using the CustomPropertyManager. The foundation of every SolidWorks automation project.
csharp
public void ReadWriteCustomProperties(ModelDoc2 model)
{
var ext = model.Extension;
// Read all file-level custom properties
var mgr = ext.CustomPropertyManager[""];
object names = null, types = null, values = null, resolved = null;
mgr.GetAll3(ref names, ref types, ref values, ref resolved);
var nameArr = (string[])names;
var valArr = (string[])resolved;
for (int i = 0; i < nameArr.Length; i++)
Console.WriteLine($"{nameArr[i]} = {valArr[i]}");
// Write / update a property
mgr.Add3("Project", (int)swCustomInfoType_e.swCustomInfoText,
"MFG-2026-001", (int)swCustomPropertyAddOption_e.swCustomPropertyReplaceValue);
// Read config-specific property
var cfgMgr = ext.CustomPropertyManager["Default"];
string valOut = "", resolvedOut = "";
bool wasResolved;
cfgMgr.Get6("Weight", false, out valOut, out resolvedOut, out wasResolved, out _);
}How It Works
SolidWorks stores custom properties at two levels:
- File-level properties: Accessed with an empty string as the configuration name
- Configuration-specific properties: Accessed by passing the configuration name
The CustomPropertyManager provides methods to read, add, update, and delete properties:
- GetAll3() reads all properties at once — returns parallel arrays of names, types, values, and resolved values
- Add3() creates or updates a property — use the ReplaceValue option to overwrite existing ones
- Get6() reads a single property by name — returns both the expression and the resolved (evaluated) value
Configuration-Specific vs File-Level
- File-level properties appear on the Summary tab in SolidWorks — use these for part numbers, descriptions, and project metadata
- Configuration-specific properties store values that change per config — weight, material, finish, etc.
- When reading properties for a BOM, SolidWorks resolves config-specific first, then falls back to file-level
Tips
- Always use Get6() (not Get5()) in modern SolidWorks versions — older methods are deprecated
- The resolved value evaluates expressions like '"SW-Mass"' into actual mass values
- For bulk reading without opening files, consider the Document Manager API — it reads properties without launching SolidWorks
- Custom properties are case-insensitive — 'PartNumber' and 'PARTNUMBER' are the same property
SolidWorks APIC#Custom PropertiesMetadata