Macro Basemap

Hello

I'm looking to update the backgrounds of old plans. I have the following template formats present in the windows folder C:\parameter-sw\Basemaps

A3;   A3_Technical_specifications_catalogue_products; A2; A2_TECH; A1;  A1_TECH

 

on my old basemaps I used

 

A3;  Technical_specifications_catalogue_products; A2; A2_TECH; A1;  A1_TECH

I would like if name templates is

Technical_specifications_catalogue_products.slddrt then load the basemap by: A3_Technical_specifications_catalogue_products.slddrt

If A3.slddrt then A3.slddrt new path

..............

 

I'm attaching the macro I'm using.

Do you have an idea to check the name of the template?

 

Thank you in advance for your feedback

 


mise_en_forme_fdp_avant_validation.swp

Hello

Depending on how the SldWorks.Sheet function is declared, you should write this:

Set swSheet = swDraw.GetCurrentSheet
sTemplate = Mid(swSheet.GetTemplateName, InStrRev(swSheet.GetTemplateName, "\") + 1)

 

1 Like

Thank you for your feedback cyril

I tested, but it doesn't work, here is the updated macro 

Do you have an idea?

 

 

 


mise_en_forme_fdp_avant_validation_-_copie.swp

Hello

I hadn't opened the code until then so when I open it, I see that the name of the background map found is missing a processing.

So you have to use sTemplate with If... Then.

After for the change of background plan on the same format, I will use information that @d.roger had given me in another topic in 2017.

Basically, you have to start the background change twice for it to work.

bRet = swDraw.SetupSheet4(swSheet.GetName, vSheetProps(0), 12, vSheetProps(2), vSheetProps(3), True, stemplatepath, 0#, 0#, "")
bRet = swDraw.SetupSheet4(swSheet.GetName, vSheetProps(0), 12, vSheetProps(2), vSheetProps(3), True, stemplatepath, 0#, 0#, "")

 

Hello Cyril,

Thank you for your feedback.

For the A3 format, I have 3 existing formats A3,A3TECH,A3_Technical_specifications_catalogue_products 

All templates are named the same way (A3 for A3, A3-TEC for A3-TECH, A2 for A2 ........), except for the  Technical_specifications_catalogue_products which has become A3_Technical_specifications_catalogue_products.

I guess you have to create as many constants as there are backgrounds?

I don't understand how  to check the basemap name and load the corresponding basemap.

Thank you in advance for your feedback


mise_en_forme_fdp_avant_validation_-_copie.swp

Hello

Example for the A3 format, to be repeated on the other formats.

                   If vSheetProps(0) = "8" Then
                      Select Case sTemplate
                        Case "Technical_specifications_catalogue_products.slddrt"
                            stemplatepath = cDirTemplate & "A3_Technical_specifications_catalogue_products.slddrt"
                        Case "A3.slddrt"
                            stemplatepath = cDirTemplate & cTemplateA3
                        Case "A3-TEC.slddrt"
                            stemplatepath = cDirTemplate & "A3-TEC.slddrt"
                        End Select
                        bRet = swDraw.SetupSheet4(swSheet.GetName, vSheetProps(0), 12, vSheetProps(2), vSheetProps(3), True, stemplatepath, 0#, 0#, "")
                        bRet = swDraw.SetupSheet4(swSheet.GetName, vSheetProps(0), 12, vSheetProps(2), vSheetProps(3), True, stemplatepath, 0#, 0#, "")

 

2 Likes

If I have followed everything correctly, you get the name of the template via the sTemplate variable.

Just put in the following line "sTemplate = Mid(swSheet.GetTemplateName, InStrRev(swSheet.GetTemplateName, "\") + 1)", a debug.print sTemplate or msgbox sTemplate to see the value of the variable displayed.

Then instead of doing your tests via vSheetProps you do your test with the sTemplate variable (Is sTemplate equals or starts with then...

1 Like

Thank you Cyril,

Have a nice day