Updating the basemap

Hello

I'm using SW2016 and I've changed my basemaps.

I would like to make a macro to automatically update my basemap.

Is it possible? If so, any idea about the code?

Thanks in advance

Fred

No code required.

 

I had to do the same thing.

 

So run a macro. (By clicking play)

Right-click at the bottom of your mep to display the different basemaps.

Either you select the new basemap if it is different, or if the name is the same click on "reload"

Close your macro with the stop button and you're done

 

Do the same for your different formats: a3, a4 etc...


macro_fdp.png
3 Likes

Hello

With adaptation (path and name of the basemaps), the attached macro changes the basemaps of each sheet if necessary.


changefonddeplans.swp
1 Like

Oops, duplicate

@Bart

It's not great, because the macro memorizes the scale and other information that is not dynamic, so it won't play.

And it is possible with knowledge to make macros that automatically browse the files to update them.

 

For example, I recently made a macro (Relatively complex which):

- Updates basemaps
- Updates dressing standards
- Updates blocks (Path detection and block replacement)
- Replacement of our revision tables
- Modification of options.

All this is managed on excel (Solidworks is therefore controlled by excel) and I can make reports on updates. I can run the macro on a folder and it updates all the plans in the subfolders.

But the disadvantage is that it takes time, but if you calculate, on our 900 plans to update I saved a lot of time.

1 Like

Thank you for your answers.

Unfortunately I can't get any results....

When I manually run the "reload" command in the plan's properties it works, but when I save the same manip in a macro nothing happens...

Since my basemap names didn't change when I changed them, I "just have" to run the "reload" command without changing anything else. Does this command exist on its own without having to validate all the other properties of the plan (scale for example)?

Thank you for your help because I admit that coding is not my great specialty....

Yes, it exists but is not registered:p

You have to get your sheet and use the "ReloadTemplate" function which applies to a "SldWorks.Sheet" type

A small macro for updating your basemap to adapt.

Dim swApp                       As SldWorks.SldWorks
Dim swModel                     As SldWorks.ModelDoc2
Dim swDraw                      As SldWorks.DrawingDoc
Dim swSheet                     As SldWorks.Sheet
Dim swView                      As SldWorks.View
Dim vSheetProps                 As Variant

Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
vSheetProps = swSheet.GetProperties

Dim size As String
If vSheetProps(0) = 6 Then
            '6 = A4 Landscape
            templateFormat="A4 - LANDSCAPE. SLDDRT" '''Here we have to change the "A4 - LANDSCAPE. SLDDRT and the others by your own template names
            size = "A4H"
ElseIf vSheetProps(0) = 7 Then
            '7 = A4 Portrait
            templateFormat = "A4 - PORTRAIT. SLDDRT"
            size = "A4"
ElseIf vSheetProps(0) = 8 Then
            '8 = A3 Landscape
            templateFormat="A3. SLDDRT"
            size = "A3"
ElseIf vSheetProps(0) = 9 Then
            '9 = A2 Landscape
            templateFormat = "A2. SLDDRT"
            size = "A2"
ElseIf vSheetProps(0) = 10 Then
            '10 = A1 Landscape
            templateFormat = "A1. SLDDRT"
            size = "A1"
ElseIf vSheetProps(0) = 11 Then
            '11 = A0 Landscape
            templateFormat = "A0. SLDDRT"
            size = "A0"
Endif


boolstatus = swModel.SetupSheet5( _
    swSheet.GetName, _
    vSheetProps(0), _
    vSheetProps(1), _
    vSheetProps(2), _
    vSheetProps(3), _
    True, _
    templateFormat _
    vSheetProps(5), _
    vSheetProps(6), _
    "By default", _
    True _
)
               
swSheet.ReloadTemplate False

 

You can then put that in a loop and go through all the sheets/files in a folder and so on.

PS: In lynkoa, it would be really nice to have code tags... because it's really not easy to share.

1 Like

Hello

@fgauvreau I see on your profile that you have MyCadServices, so you have the MyCadTools tools and the Integration tool will be able to meet your request and much more.

@+

Thank you all!

KVuillemier: The "swSheet.ReloadTemplate False" command was just missing in Cyril.F's macro.

By adding it it works great.

 

Thanks also to Coyote for the suggestion. I had never explored this powerful tool.

If the answer solved your problem, you can indicate that it solved your problem.