Creating a macro to reload the basemap

Hello

I would like to update my basemaps stored in a PDM, I specify without the mycad tools or my pdm tools.
Has anyone ever made a macro in this style?
I don't know too much about VBA, but retouching the macro for filenames or paths is something I can do. Here is my basic data.

  • everything is stored in a PDM, even the plan templates.
  • The pdm is under C: so the single path for all users, the templates and basemap are in the same folder.
  • The template (drwdot) calls 5 different basemaps (SLDDRT).
  • The file names don't change, I update them in the PDM.
  • SolidWorks 2022 for now.

In manual I do property on the basemap, I stay on the selected basemap, I reload and it updates the cartridge.

The idea is to create a macro that does this automatically (reload and save) and then integrate that macro into a PDM workflow to do the bulk update. And that way I can cumulate with my PDF generation in the flow as well.

I don't know if this is possible or if someone has done it, thank you in advance for your help.

Hello

For my part, I use this type of code but not in interaction with Solidworks PDM (users have the macro available to make the change when modifying the plans).

Dim swApp           As SldWorks.SldWorks
Dim swModel         As SldWorks.ModelDoc2
Dim swDraw          As SldWorks.DrawingDoc
Dim bRet            As Boolean
Dim vSheetNameArr   As Variant
Dim vSheetName      As Variant
Dim vSheetProps     As Variant
Dim stemplatepath   As String


Const cDirTemplate = "xxx" 'Mettre le chemin d'accès aux fonds de plan slddrt
Const cTemplateA4 = "A4 - iso.slddrt"
Const cTemplateA3 = "A3 - iso.slddrt"
Const cTemplateA2 = "A2 - iso.slddrt"
Const cTemplateA1 = "A1 - iso.slddrt"
Sub ReloadTemplate()
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
vSheetNameArr = swDraw.GetSheetNames
    For Each vSheetName In vSheetNameArr
        bRet = swDraw.ActivateSheet(vSheetName): Debug.Assert bRet
        Set swSheet = swDraw.GetCurrentSheet
        vSheetProps = swSheet.GetProperties
        If vSheetProps(0) = "7" Then
            stemplatepath = cDirTemplate & cTemplateA4
            bRet = swDraw.SetupSheet4(swSheet.GetName, vSheetProps(0), 12, vSheetProps(2), vSheetProps(3), True, stemplatepath, 0#, 0#, "")
            swSheet.ReloadTemplate False
            swModel.ForceRebuild3 (False)
        ElseIf vSheetProps(0) = "8" Then
            stemplatepath = cDirTemplate & cTemplateA3
           bRet = swDraw.SetupSheet4(swSheet.GetName, vSheetProps(0), 12, vSheetProps(2), vSheetProps(3), True, stemplatepath, 0#, 0#, "")
            swSheet.ReloadTemplate False
            swModel.ForceRebuild3 (False)
        ElseIf vSheetProps(0) = "9" Then
            stemplatepath = cDirTemplate & cTemplateA2
            bRet = swDraw.SetupSheet4(swSheet.GetName, vSheetProps(0), 12, vSheetProps(2), vSheetProps(3), True, stemplatepath, 0#, 0#, "")
            swSheet.ReloadTemplate False
            swModel.ForceRebuild3 (False)
        ElseIf vSheetProps(0) = "10" Then
            stemplatepath = cDirTemplate & cTemplateA1
            bRet = swDraw.SetupSheet4(swSheet.GetName, vSheetProps(0), 12, vSheetProps(2), vSheetProps(3), True, stemplatepath, 0#, 0#, "")
            swSheet.ReloadTemplate False
            swModel.ForceRebuild3 (False)
        End If
    Next
bRet = swDraw.ActivateSheet(vSheetNameArr(0))
End Sub

To be seen to integrate it into an action via the workflow but also think that the vault folder is always with the latest version in the users' cache otherwise it will not apply the latest basemap.
For my part, all SW document templates are out of the box.

1 Like