11 Replies Latest reply on Jan 18, 2018 7:37 AM by Max Wigfield

    Conditional Sheet Format Information

    Max Wigfield

      Hi everyone,

      My company has recently upgraded to SolidWorks 2017 SP5 (were previously using 2011) and I've become frustrated with the "forced ruler" when editing sheet format as discussed here (without resolution) - How do I disable the rulers when editing a sheet format? . Following a suggestion in that thread I would like to eliminate the need to edit the sheet format on a regular basis (currently doing so for almost every drawing), but I'm concerned the functionality I need is beyond the built-in capabilities. I believe what I require is likely achievable with macros, but having no experience with these I would much prefer a simple solution if possible and feel there may be features available that I'm not even aware of.

       

      The main issue is that we design parts that are then regularly outsourced to a range of manufacturers, who require drawings in various different formats. Company policy requires we keep a copy of all drawings in SLDDRW and PDF formats which contains the full information of that part, including details such as Client which cannot be passed on to the manufacturer. These details are added at part level and there are no problems in that regard, but when it comes to saving a drawing my process is typically along the lines of: Save drawing -> Save as PDF -> Edit Sheet Format -> Delete client name -> Save as DWG -> Exit without saving (to maintain client name in the SLDDRW). This both extremely tiresome to do for large projects and also adds a layer of user error. While the optimal solution would be to simply remove details like this from drawings outright, this is regrettably not something I have control over.

       

      As such my main question here is (1) Does SolidWorks have the capability to delete information from a sheet format dependent on what file type the drawings is being saved as, or any other means of automatically removing certain information from a drawing without having to edit the sheet format? If this is only possible through macros then I would be extremely grateful if someone could point me in the right direction.

       

      Another related question I have is (2) Is it possible to automatically detect the author of a part or drawing (using Windows username for example) and populate the sheet format with this information? At present we have fields in the sheet for the original part author, the latest user to modify the part, the original drawing author and the latest user to modify the drawing. The latest user to modify is easily controlled using the "Last Saved By" property, but original author is dependent on users actually filling in a custom property and sometimes people either forget or just don't bother.

       

      The need for this comes from having multiple users who will commonly pick up each others jobs, resulting in a situation such as: User A modelled the part, User B produced the manufacture drawings, and User C updated these drawings with a revision a week later. If there is then a problem with these drawings (regardless of what the issue actually is) there is no trace-ability that User A or B ever worked on the project unless they manually set themselves as the original part and drawing authors, and User C will then either get blamed for the problem or expected to make an alteration to the model, which would be far better suited to the original creator, User A.

       

      I don't imagine any of you have run into these exact problems as they feel fairly unique to the way we work, but any insight or suggestions to resolve either of these problems would be greatly appreciated. Thank you.

        • Re: Conditional Sheet Format Information
          Glenn Schroeder

          For your question 1, instead of editing the sheet format every time, how about having separate sheet formats, one with a note calling out the client name and one without it?  Then you could just switch the sheet format to create the pdf to send to fabricators, and then switch back.

           

          You may be able to work out something that would work better with the Custom Property Tab, but I'm not as familiar with it as I should be.  Someone that is may have a suggestion.

            • Re: Conditional Sheet Format Information
              Max Wigfield

              Hi Glenn,

              I just tested this out and it worked better than I expected. While I would still like to automate this process if possible, this is indeed a far better way of doing it than what I am using currently and something that hadn't occurred to me, so at the very least you have saved me a considerable amount of time on future projects. Thank you.

              • Re: Conditional Sheet Format Information
                Max Wigfield

                Hi Dan,

                Thank you for the linked threads. The first 2 unfortunately seem to detail the way we currently add author to drawings, which is not as automated as I would like since some of my colleagues can be absent-minded when it comes to the custom property tab. This has however reminded me of the possibility of user-specific templates on each computer, which is an improvement over the current system in exchange for more templates to manage.

                 

                The 3rd thread is of definite interest to me though, and I will see if I am able to use it to any success when I am back in office tomorrow.

              • Re: Conditional Sheet Format Information
                Max Wigfield

                Using the threads linked by Dan as well as code from Editing existing text notes in a drawing  and Solidworks instant PDF, STL, DXF macro’s | Gregor van Egdom , I have been able to create a pair of macros that are very close to what I want.

                 

                For my first problem, I have managed to modify a macro so that it will replace any information I want to hide with a blank space. Unless there is a method I'm unaware of, it unfortunately needs to make use of the macro recorder in order to find Note IDs so that the macro knows what to select and then replace. It additionally then saves a copy of the document as DWG (or any other standard format). I have linked this macro to a custom button (this appears to be a fairly new feature from my understanding) so that it simply takes one click at the end of the drawing, no more difficult than saving normally, and since this method does not require entering the sheet format directly I no longer have to contend with the rulers shifting the drawing slightly each time. Hopefully this may be of help to other users:

                 

                Dim swApp As Object

                 

                Dim Part As Object

                 

                Sub main()

                 

                    Dim swApp As SldWorks.SldWorks

                    Dim swDwg As SldWorks.ModelDoc

                    Dim selMgr As SelectionMgr

                    Dim selObj As SldWorks.Note

                 

                    Set swApp = Application.SldWorks

                    Set swDwg = swApp.ActiveDoc

                 

                'Deletes the Customer note

                 

                    'Initialize the SolidWorks selection interface

                    Set selMgr = swDwg.SelectionManager

                 

                        'Selects the Customer note on the Sheet Format

                        ret = swDwg.SelectByID("DetailItem127@Sheet Format1", "NOTE", 1.11778081570233E-02, 0.138845870909176, 0)

                 

                            'Check to make sure that an object was selected

                            If selMgr.GetSelectedObjectCount <> 0 Then

                 

                                'Gets the text note, which should be SldWorks.Note object

                                Set selObj = selMgr.GetSelectedObject(1)

                 

                                    'Call the SldWorks.Note.SetText method to change the text

                                    ret = selObj.SetText(" ")

                 

                            End If

                           

                'Clears current selection

                Set swModel = swApp.ActiveDoc

                swModel.ClearSelection

                 

                'Saves as the file as .DWG

                 

                Set swApp = Application.SldWorks

                Set Part = swApp.ActiveDoc

                 

                Dim FilePath As String

                Dim PathSize As Long

                Dim PathNoExtention As String

                Dim NewFilePath As String

                 

                FilePath = Part.GetPathName

                PathSize = Strings.Len(FilePath)

                PathNoExtention = Strings.Left(FilePath, PathSize - 6)

                NewFilePath = PathNoExtention & "dxf"

                 

                Part.SaveAs2 NewFilePath, 0, True, False

                 

                End Sub

                 

                Using the same method, I have also created a button that will set the drawing author on the sheet to the current Windows username. I had hoped to have this macro run automatically on creation of a new drawing, but this does not seem to be possible from what I've found. If anyone knows a method of achieving this then I would be very interested to know. Again, code listed below in the hope this may benefit someone:

                 

                Dim swApp As Object

                 

                Dim Part As Object

                 

                Sub main()

                 

                    Dim swApp As SldWorks.SldWorks

                    Dim swDwg As SldWorks.ModelDoc2

                    Dim selMgr As SelectionMgr

                    Dim selObj As SldWorks.Note

                    Dim UserName As String

                 

                    UserName = Environ("USERNAME")

                 

                    Set swApp = Application.SldWorks

                    Set swDwg = swApp.ActiveDoc

                 

                'Initialize the SolidWorks selection interface

                Set selMgr = swDwg.SelectionManager

                 

                    'Selects the Drawing Author note on the Sheet Format

                    ret = swDwg.SelectByID("DetailItem130@Sheet Format1", "NOTE", 8.67624098683036E-03, 0.158364277456647, 0)

                 

                        'Check to make sure that an object was selected

                        If selMgr.GetSelectedObjectCount <> 0 Then

                 

                            'Gets the text note, which should be SldWorks.Note object

                            Set selObj = selMgr.GetSelectedObject(1)

                 

                                'Call the SldWorks.Note.SetText method to change the text

                                ret = selObj.SetText(UserName)

                 

                        End If

                           

                'Clears current selection

                Set swModel = swApp.ActiveDoc

                swModel.ClearSelection

                 

                End Sub