set_material
Assign a material to the active part to enable accurate mass, volume, and inertia calculations. Optionally use a custom .sldmat database.
Instructions
Asignar material — set the material on the active part. Required
before get_mass_properties returns a meaningful mass.
Maps to the SolidWorks UI's "Edit Material…" panel. Standard SW
system materials work by name; database_path lets shop-specific
custom .sldmat libraries override the system DB.
Args:
name: Material name as it appears in the chosen library. Common
autoparts examples (in the SW system DB):
- Aceros: "AISI 1020", "AISI 1045 Steel", "AISI 4140",
"Plain Carbon Steel"
- Aluminios: "6061-T6 Aluminum", "7075-T6 Aluminum",
"AlSi10Mg" (cast / fundición a presión)
- Plásticos: "Nylon 6/10", "ABS", "PC High Viscosity"
Names are LOCALE-sensitive — Spanish SW installs may use
translated names (e.g. "Acero AISI 1045"). If the call
raises with "did not apply material", check the SW material
list in the current install.
database_path: Optional absolute path to a .sldmat material
database. None (default) uses the SW system database. Pass
a path to load shop-custom alloys (e.g. specific casting
recipes, supplier-graded steels not in the system DB). The
file must exist and end in .sldmat.
Returns: dict with name, applied (always True on success),
previous (the prior material name or None), database (the
resolved DB path; "" for system).
Caveat: changing material affects mass / volume / inertia from
get_mass_properties (la densidad cambia). It does NOT change
geometry — fillets, dimensions, and bodies are unaffected.
Example — quote a turned shaft: set_material("AISI 1045 Steel") props = get_mass_properties() cost_per_kg_mxn = 65.0 quote_mxn = (props["mass_g"] / 1000) * cost_per_kg_mxn
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| database_path | No |