save_as
Save the active CAD document to a specified file path, even for newly created documents without a filename. Sets the document's path for subsequent saves.
Instructions
Guardar el documento activo a una ruta explícita (Save As).
A diferencia de save_active_document, esta sí funciona con piezas recién creadas que aún no tienen nombre de archivo. Una vez guardadas, los siguientes save_active_document escriben a la misma ruta. [en: Save the active document to an explicit file path. Unlike save_active_document — which only works on docs that already have a filename — save_as handles a fresh, never-saved document and sets its filename in one call. Subsequent save_active_document calls then save back to this same path.]
Args: path: Absolute file path INCLUDING extension. SolidWorks infers the document type from the extension: .SLDPRT parts .SLDASM assemblies .SLDDRW drawings Passing the wrong extension for the active doc type causes SaveAs to fail.
Returns the same dict as save_active_document:
name: document title
path: filesystem path written to
saved: True if save succeeded
errors / warnings: 0 (the simpler SaveAs variant doesn't expose these — use save_active_document on a subsequent save if you need the bitmasks).
Common autoparts use: scripted runs that build a part from scratch, save it to a customer-controlled directory, and hand off the path to a downstream step.
Caveats:
The parent directory must exist; save_as does NOT mkdir.
En Windows en español con OneDrive (la configuración típica del cliente PYME), el escritorio del usuario es
C:\Users\<user>\OneDrive\Escritorio, NOC:\Users\<user>\Desktop(esa ruta no existe). Si el usuario dice "guárdalo en el escritorio" sin path explícito, prueba primero la ruta de OneDrive\Escritorio. [en: On Spanish-Windows + OneDrive — the typical PYME setup — the user's Desktop isC:\Users\<user>\OneDrive\Escritorio, notC:\Users\<user>\Desktop(which doesn't exist). When the user says "save it to the Desktop" without an explicit path, try the OneDrive\Escritorio path first.]
Example — save a fresh part: save_as(r"C:\Users\danie\OneDrive\Escritorio\bracket_v1.SLDPRT")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |