CHF 0.00
0

How to Change the Sheet Format on Many SOLIDWORKS Drawings in PDM

Replace the old title block on many SOLIDWORKS drawings in SOLIDWORKS PDM: a PDMShell script checks out each drawing, swaps the sheet format and checks it back in.
Picture of Amen Jlili

Amen Jlili

Amen Jlili is the founder and technical director of Blue Byte Systems Inc., a software company in Vancouver, Canada, specializing in automating SOLIDWORKS and PDM.

To change the sheet format on many SOLIDWORKS drawings stored in SOLIDWORKS PDM, select the parts or assemblies in File Explorer and run the PDMShell Change Drawing Sheet Format script. For each file it finds the drawing with the same name, checks it out, swaps the old sheet format for the new one on every sheet, saves and checks it back in. You type the old and new format once and the script reuses them for the whole batch.

A new title block is one of those changes that looks small on the template and huge in the vault. The new format only applies to drawings created from now on. Every existing drawing still carries the old one, and replacing it by hand means opening each drawing, opening Sheet Properties on each sheet, browsing to the new .slddrt and saving. This script does that loop for you.

Typical reasons to swap sheet formats

  • A company rebrand or a new logo in the title block.
  • A merger or acquisition that brings drawings from another company into your standard.
  • New fields in the title block, such as a material or approval property that did not exist before.
  • Moving sheet formats to a new shared location after a server change.

The complete script

Load it from the PDMShell Script Library, or copy it from the Change Drawing Sheet Format recipe in the PDMShell documentation.

checkout -filePath "$folderPath\$fileNameWithoutExtension.slddrw"

cd -directory "$folderPath"

runswmacro -filePath "$tempFolder\ChangeSheetFormat.swb" -search "Name=$fileNameWithoutExtension.slddrw" -timeout 500

checkin -filePath "$folderPath\$fileNameWithoutExtension.slddrw"

How it works

It finds the drawing from the model you selected

The script builds the drawing path from the selected file: $folderPath plus $fileNameWithoutExtension plus .slddrw. Select bracket.sldprt and the script works on bracket.slddrw in the same folder. That means you can select parts and assemblies, which is usually how projects are browsed, and still update their drawings.

It checks out, runs the macro and checks in

checkout locks the drawing, cd moves PDMShell to the folder, runswmacro opens the drawing in SOLIDWORKS and runs ChangeSheetFormat.swb on it, and checkin saves the new version back to the vault.

The sheet format macro

The macro is downloaded to your Windows temporary folder as ChangeSheetFormat.swb. The full code is in the documentation. The part that does the work is a loop over every sheet in the drawing:

For i = LBound(sheetNames) To UBound(sheetNames)

    swDraw.ActivateSheet CStr(sheetNames(i))

    Dim swSheet As SldWorks.Sheet
    Set swSheet = swDraw.GetCurrentSheet

    If Not swSheet Is Nothing Then

        Dim currentFormat As String
        currentFormat = swSheet.GetTemplateName

        If ShouldReplaceFormat(currentFormat, oldFormat) Then
            swSheet.SetTemplateName newFormat
            swSheet.ReloadTemplate True
            changed = True
        End If

    End If

Next i

For each sheet it reads the current format with GetTemplateName. If it matches the old format, either by full path or by file name only, it sets the new format and reloads it. When at least one sheet changed, the macro rebuilds and saves the drawing silently. Drawings that never used the old format are left exactly as they were.

The settings file

The first time the macro runs it asks for two values: the old sheet format name or path, and the full path of the new format. It saves both in ChangeSheetFormat.ini next to the macro:

OldFormat=OldSheetFormat.slddrt
NewFormat=C:\SOLIDWORKS Sheet Formats\NewSheetFormat.slddrt

Every following drawing in the batch reads this file instead of asking again. To run a different swap later, delete the .ini file or edit the two lines.

Run it from the right-click menu

Save the script as a vault script with a menu name such as Change sheet format. Our step by step guide on adding a right-click command to SOLIDWORKS PDM with a PDMShell vault script shows every setting. Then select the files in File Explorer, right-click and run it.

Requirements

  • SOLIDWORKS installed on the computer running PDMShell.
  • Check out and check in permission on the drawings.
  • Each selected file has a drawing with the same name in the same folder.
  • The new .slddrt is in a location every user can reach, such as a shared network folder or a vault folder.

Frequently asked questions

Will it touch drawings that already use the new format?

No. Only sheets whose current format matches the old format are changed. Everything else is skipped and the drawing is not saved.

What about released drawings?

Released drawings are usually read only in your workflow. Move them to an editable state first, or run the script as part of a change process so the new version gets a proper revision.

Can I test it on one drawing first?

Yes, and you should. Select one model, run the script, open the drawing and check every sheet before running it on a whole project.

Want help with a vault wide title block update?

If you have thousands of drawings and several old formats to replace, talk to us. We can plan the batches, handle released files and run the update with you.

Need this adapted to your workflow?

We build custom SOLIDWORKS macros, add-ins and PDM automation.

Picture of Amen Jlili

Amen Jlili

Amen Jlili is the founder and technical director of Blue Byte Systems Inc., a software company in Vancouver, Canada, specializing in automating SOLIDWORKS and PDM.

Leave a Comment

0
0
Your Cart
Your cart is emptyReturn to Shop