9 Replies Latest reply on Feb 16, 2018 10:00 AM by Elmar Klammer

    Changing sheet format with macro causes duplicate blocks when multiple sheets exist in drawing.

    Lucas Malina

      Hi,

       

      I have seen this question asked once or twice a number of years ago but none of the previous threads I found were resolved as far as I could find and I thought there might be a new solution available.  Apologies in advance if this issue has already been solved.  I also searched the API documentation for a long time and couldn't find anything in there either.

       

      When we change the sheet format manually (because we use blocks in the sheet format) on multiple sheet drawings Solidworks prompts the user if they want to rename the duplicate block or use the existing definition.  The user then can easily select 'No' do not rename and we have no problems.

       

      Below is a screen shot of the prompt I am referring to.

       

      Untitled.jpg

       

      I then have a macro I am trying to use to batch change sheet formats using the SetupSheet6 command.

       

      The problem I am facing is when I run the macro, Solidworks doesn't get the chance to prompt the user and so it automatically uses the default option to rename the block and so I end up with multiple definitions of the same block instead of multiple instances of the single block definition.  This causes issues with our other macros which pull and push attributes to the blocks as it searches through and edits the block instances based on the block definition name.

       

      For example.  the block is called Title_Block and all macros can search and find the instance on the current sheet and modify the attributes but it doesn't work when on the second sheet the block is renamed to Title_Block_1 etc.

       

      My question is:

      Can I set the default option to "use existing block" for all duplicate blocks (using API or other method i.e. setting).  Or can I pause the macro while changing the sheet format to allow Solidworks to prompt the user and we can manually choose to use existing block instead of renaming?

       

      I am coding in VBA and using Solidworks 2017 on a windows 7 system.

       

      Thanks for your help.

      Lucas