11 Replies Latest reply on Jul 15, 2017 10:25 AM by Wojciech Pogorzelski

    Sheetmetal - how to insert a note with custom cut list item properties in drawing? InsertCutListPropertyNote macro.

    Wojciech Pogorzelski

      Hi All,

      I’m trying to find a way to get a custom Cut List Property Note in a drawing from a flat pattern sheet metal part.

      A standard note consist a lot of useless information for me.

      I spend a few days searching for the solution over the internet and ended with nothing.

      Is there a way to modify a standard note, so it displays only the lines I need and save it as a standard?

      I don’t need to add anything extra to it, just less information that the standard note gives.

      Or maybe there is a way to modify this macro I have found:

      2016 SOLIDWORKS API Help - Insert Cut List Item Property Note Example (VBA)

      It puts the standard note in a specified location on a sheet, such is great, except I would like to shorten to a few specified lines:

      ---------------------------------

      Sheet Metal Properties:

      - Thickness:

      - Bend Radius:

      - Number of Bends:

      - Number of Cuts:

      - Outer cutting length:

      - Inner cutting length:

      - Material:

      - Weight:

      ---------------------------------

      Thank you for any help in advance

        • Re: Sheetmetal - how to insert a note with custom cut list item properties in drawing? InsertCutListPropertyNote macro.
          Deepak Gupta

          You can edit that note and save in library. And then can insert manually by dragging or using API.

           

          Here is the note you would need:

          Sheet Metal Properties:

          - Thickness: $PRPWLD:"Sheet Metal Thickness"

          - Bend Radius: $PRPWLD:"Bend Radius"

          - Number of Bends: $PRPWLD:"Bends"

          - Number of Cuts: $PRPWLD:"Cut Outs"

          - Outer cutting length: $PRPWLD:"Cutting Length-Outer"

          - Inner cutting length: $PRPWLD:"Cutting Length-Inner"

          - Material: $PRPWLD:"Material"

          - Weight: $PRPWLD:"Mass"

            • Re: Sheetmetal - how to insert a note with custom cut list item properties in drawing? InsertCutListPropertyNote macro.
              Wojciech Pogorzelski

              Great, I got it to work with your code (macro):

              Need vba code to insert a .sldnotestl file

              Following your instructions, I saved the note in a file by adding it to the Library, then updated the path in a macro.

              Now, what I need to do is to point a right view (flat pattern) in a dawing and execute the macro.

              The flat pattern view has to be active in order for the note to display the proper values, any other case you get just the text.

              Works for me perfect:) Great thanks.

               

              Here's the full macro I have:

               

              '-----------------------------------------------------------------

              Dim swApp        As SldWorks.SldWorks

              Dim swModel     As SldWorks.ModelDoc2

              Const FileName  As String = "C:\_SolidWorks\_Data\SW_design library\Parametry Arkusza Blachy.sldnotestl" ' Change file name/path here

               

              Sub main()

               

              Set swApp = Application.SldWorks

              Set swModel = swApp.ActiveDoc

              '-----------------------------------------------------------------

              If swModel Is Nothing Then

                  swApp.SendMsgToUser2 "                     Sheetmetal custom note" & vbNewLine & "" & vbNewLine & "                            Open SW file", swMbWarning, swMbOk

                  Exit Sub

              End If

              '-----------------------------------------------------------------

              If swModel.GetType <> swDocDRAWING Then

                  swApp.SendMsgToUser2 "                     Sheetmetal custom note" & vbNewLine & "" & vbNewLine & "                         Open SW Drawing", swMbWarning, swMbOk

                  Exit Sub

              End If

              '-----------------------------------------------------------------

              swModel.Extension.InsertAnnotationFavorite FileName, 0.01, 0.05, 0 ' Change X, Y and Z values here

               

              End Sub

                • Re: Sheetmetal - how to insert a note with custom cut list item properties in drawing? InsertCutListPropertyNote macro.
                  Deepak Gupta

                  You can check the selected view or loop throught the view and check them using IsFlatPatternView. If true then add the note else next view or warn user.

                    • Re: Sheetmetal - how to insert a note with custom cut list item properties in drawing? InsertCutListPropertyNote macro.
                      Wojciech Pogorzelski

                      I'm not a programmer so it takes me a while to figure it out. I have to say this forum is huge help.

                      I've changed this macro so it checks for flatpattern view in an active sheet and if finds it it puts a custom cut list item properties note in it. If there is no flat pattern view, nothing hapens:)

                      Thanks for the clue Deepak.

                      Here is an updated macro:

                       

                      '----------------------------------------------------------------

                      Dim swApp        As SldWorks.SldWorks

                      Dim swModel     As SldWorks.ModelDoc2

                      Const FileName  As String = "C:\_SolidWorks\_Data\SW_design library\Parametry Arkusza Blachy.sldnotestl" ' Change file name/path here

                       

                      Sub main()

                       

                      Set swApp = Application.SldWorks

                      Set swModel = swApp.ActiveDoc

                      '-----------------------------------------------------------------

                      If swModel Is Nothing Then

                          swApp.SendMsgToUser2 "                     Sheetmetal custom note" & vbNewLine & "" & vbNewLine & "                            Open SW file", swMbWarning, swMbOk

                          Exit Sub

                      End If

                      '-----------------------------------------------------------------

                      If swModel.GetType <> swDocDRAWING Then

                          swApp.SendMsgToUser2 "                     Sheetmetal custom note" & vbNewLine & "" & vbNewLine & "                         Open SW Drawing", swMbWarning, swMbOk

                          Exit Sub

                      End If

                      '-----------------------------------------------------------------

                      Set swDrawingDoc = swModel

                      Set swView = swDrawingDoc.IGetFirstView

                      Set swView = swView.GetNextView

                               

                          While Not swView Is Nothing

                              If swView.IsFlatPatternView Then

                              swModel.Extension.InsertAnnotationFavorite FileName, 0.01, 0.05, 0 ' Change X, Y and Z values here

                              End If

                              Set swView = swView.GetNextView

                          Wend

                       

                      End Sub

                • Re: Sheetmetal - how to insert a note with custom cut list item properties in drawing? InsertCutListPropertyNote macro.
                  John Stoltzfus

                  Another alternative to Deepak Gupta solution is using the Custom Property Tab Builder (CPTB) and letting the properties propagate automatically and then I would set up a "Sheet Metal" drawing template/format.  That way all you need to do is pick the proper CPTB file and template/format file, nothing else required..