7 Replies Latest reply on Jan 20, 2015 7:04 PM by Keith Rice

    Get flat pattern drawing view fold line details

    Michael Caulton

      Is there a way to get the fold line details in a sheet metal drawing view? Ie a list of all folds and their direction and angle?

       

      Get drawing fold lines.JPG

        • Re: Get flat pattern drawing view fold line details
          Michael Lord

          Michael,

          Select the Flat Pattern>Insert>Tables>Bend Table

          Bend.png

          Bend Table.png

            • Re: Get flat pattern drawing view fold line details
              Michael Caulton

              Hi Michael, sorry I shloud have been more specific. I want to do it through the api interface. I might be able to use a bend table in the api. I will look into it.

                • Re: Get flat pattern drawing view fold line details
                  Keith Rice

                  Michael,

                   

                  It doesn't look like IBendTable and IBendTableAnnotation have any members related to this. What you might have to do is simply insert the bend table (via the API if you want) and then extract the data from the cells.

                   

                  You can get all of the data in a table using this code:

                   

                  Dim swApp As SldWorks.SldWorks
                  Dim swModel As SldWorks.ModelDoc2
                  Dim swDraw As SldWorks.DrawingDoc
                  Dim swView As SldWorks.View
                  Dim swTable As SldWorks.TableAnnotation
                  Dim swBomTable As SldWorks.TableAnnotation
                  Dim vTables As Variant
                  Dim i As Integer
                  Dim intRow As Integer, intCol As Integer
                  
                  Sub main()
                      Set swApp = Application.SldWorks
                      Set swModel = swApp.ActiveDoc
                      Set swDraw = swModel
                      Set swView = swDraw.GetFirstView
                      vTables = swView.GetTableAnnotations
                      
                      For i = 0 To UBound(vTables)
                          Set swTable = vTables(i)
                          If swTable.Type = swTableAnnotationType_e.swTableAnnotation_BendTable Then Exit For
                      Next i
                      
                      For intCol = 0 To swTable.ColumnCount - 1
                          For intRow = 0 To swTable.RowCount - 1
                              Debug.Print swTable.Text(intRow, intCol)
                          Next intRow
                      Next intCol
                  End Sub
                  

                   

                  Keith

                  SolidWorks API Training

                    • Re: Get flat pattern drawing view fold line details
                      Michael Caulton

                      HI Keith, That was my backup if I didn't get the answer I was looking for. The closes member I have method I have found is GetBendNoteAttributeString but that just gets the attribute not the resultants directions. Looks like I will be using the IBendTable method. Thanks for the help.

                      • Re: Get flat pattern drawing view fold line details
                        Michael Caulton

                        Keith

                         

                        Is there any way to relate a bend table back to a view or configuration? In your code you kick out when you find a bend table but we sometimes have multiple flat patterns on one drawing. I need to be able to identify which view or configuration the table belongs too.

                         

                        Dim swApp As SldWorks.SldWorks
                        Dim swModel As SldWorks.ModelDoc2
                        Dim swView As SldWorks.View
                        Dim swDrawingDoc As SldWorks.DrawingDoc
                        Dim myBendTableAnnot As SldWorks.BendTableAnnotation
                        Dim myBendTableFeat As SldWorks.BendTable
                        
                        Option Explicit
                        
                        Sub main()
                        
                            Set swApp = Application.SldWorks
                            Set swModel = swApp.ActiveDoc
                            Set swDrawingDoc = swModel
                            Set swView = swDrawingDoc.IGetFirstView
                            Set swView = swView.GetNextView
                            
                            ' Make all Bend Tables
                            While Not swView Is Nothing
                                If swView.IsFlatPatternView Then
                                    Set myBendTableAnnot = swView.InsertBendTable(False, 0#, 0#, swBOMConfigurationAnchor_TopLeft, "A", "C:\Program Files\SolidWorks Corp\SolidWorks\lang\english\bendtable-standard.sldbndtbt")
                                End If
                               Set swView = swView.GetNextView
                            Wend
                                    
                            ' Run through bend table get info needed
                            Dim vTables As Variant
                            Dim swTable As SldWorks.TableAnnotation
                            
                            Set swView = swDrawingDoc.GetFirstView
                            vTables = swView.GetTableAnnotations
                              
                            For i = 0 To UBound(vTables)
                                Set swTable = vTables(i)
                                If swTable.Type = swTableAnnotationType_e.swTableAnnotation_BendTable Then
                                
                                    ' NEED TO KNOW WHAT VIEW OR CONFIG THIS PERTICULAR TALE RELATES TOO
                                    
                                End If
                            Next i
                            
                        End Sub
                        

                        My alternative plan was to run thought the views and create a bend table if the view was a flat pattern, get the data I need, then delete the table and move on to the next view. With this approach I am struggling to to relate the "Dim swTable As SldWorks.TableAnnotation" to the newly created bend table and then deleting the bend table once Ive got the data.

                         

                        Dim swApp As SldWorks.SldWorks
                        Dim swModel As SldWorks.ModelDoc2
                        Dim swView As SldWorks.View
                        Dim swDrawingDoc As SldWorks.DrawingDoc
                        Dim myBendTableAnnot As SldWorks.BendTableAnnotation
                        Dim myBendTableFeat As SldWorks.BendTable
                        
                        Option Explicit
                        
                        Sub main()
                            Set swApp = Application.SldWorks
                            Set swModel = swApp.ActiveDoc
                            Set swDrawingDoc = swModel
                            Set swView = swDrawingDoc.IGetFirstView
                            Set swView = swView.GetNextView
                                
                            While Not swView Is Nothing    
                                If swView.IsFlatPatternView Then
                                
                                    Set myBendTableAnnot = swView.InsertBendTable(False, 0#, 0#, swBOMConfigurationAnchor_TopLeft, "A", "C:\Program Files\SolidWorks Corp\SolidWorks\lang\english\bendtable-standard.sldbndtbt")
                        
                                    'PROBLEMS
                                    ' GET DATA AS PER PREVIOUS ANSWER   Set swTable = vTables(i)  
                                    ' DELETE TABLE
                                             
                                End If        
                               Set swView = swView.GetNextView       
                            Wend
                        End Sub
                        
                          • Re: Get flat pattern drawing view fold line details
                            Keith Rice

                            Correct, my code assumes there's only one bend table. I don't see a way to determine which view was used to create that bend table, unfortunately.

                             

                            You need to use IView::InsertBendTable to create the table after you have selected a view.

                             

                            You can cast from IBendTableAnnotation to ITableAnnotation, use ITableAnnotation::GetAnnotation to get the underlying IAnnotation object, then use IAnnotation::Select to select it, and IModelDoc2::EditDelete to delete it.

                             

                            If your struggling with any of that then I suggest you break the task down into bite-size pieces and attack them one at a time. If you have a question then post it in the API forum under a new thread.

                             

                            Keith

                            SolidWorks API Tutorials

                        • Re: Get flat pattern drawing view fold line details
                          Michael Lord

                          Michael

                          I thought it was too easy