Precondition:
|
Before running this macro, the user must have a SolidWorks drawing document (.slddrw) open and active. The macro explicitly checks the document type and displays an error message ("Open a drawing to run this macro") if a drawing is not the active document.
Additionally, the drawing should reference a part or assembly model that contains custom properties - specifically "Part Number" and "Description" are required, while "Revision" is optional. The macro reads these properties from the referenced model to generate output filenames. If Part Number or Description cannot be read, the macro displays an error message ("Could not read Part Number or Description from the model").
The macro exports the drawing and its referenced model to multiple formats (DWG, PDF, STEP, and DXF), using the custom properties to construct meaningful filenames based on the part number, description, and revision. |
Postcondition:
|
The macro generates multiple export files in the same directory as the source drawing. Specifically, it creates:
- PDF file - Portable document format of the drawing
- STEP file - 3D model export of the referenced part/assembly
- DXF file - Drawing exchange format (with specific preferences for version and multi-sheet handling)
All output filenames are constructed using the custom properties from the referenced model in the format: [Part Number], [Description] [Revision] (with revision appended only if present). The macro sanitizes these filenames by removing invalid characters (backslashes, colons, asterisks, quotes, angle brackets, pipes, and whitespace/newlines).
Upon completion, the user receives a message box indicating either success ("All exports succeeded" with the list of created files) or failure (showing error and warning counts if any export failed). If export files already exist at the destination, the macro prompts the user with an overwrite confirmation dialog before proceeding. |
|
SOLIDWORKS version:
|
2022 |
|
Programming Language:
|
SW_VBA |