19 Replies Latest reply on Sep 26, 2017 6:42 AM by Dionatan Silveira

    tag letter in a table annotation

    Dionatan Silveira

      hey,

       

      how can i fix a tag letter in a table annotation? i would like to define a especific letter for a especific hole feature in a collection drawings.

       

      is it possible by API?

        • Re: tag letter in a table annotation
          Jacob Corder

          what do you mean by tag letter?

           

          post picture of what you are trying to do

            • Re: tag letter in a table annotation
              Dionatan Silveira

              follow a picture that show what i am trying to do.

               

              i need change the letters in the first column, but not lose the link with drawing. i want define a specif letter by some holes.

               

              thanks

               

               

              image.JPG

                  • Re: tag letter in a table annotation
                    Dionatan Silveira

                    so, i studied this macro before, but it isn't work. i have a "annotationtable" and not a "holetable", it could be the problem?

                     

                    i try to modify for:

                     

                    boolstatus = swModel.Extension.SelectByID2("Item de detalhe1305@N", "ANNOTATIONTABLES", 0.126414199968846, 7.69865441259771E-02, 0, False, 0, Nothing, 0)

                     

                    but when i set "Set swHoleTable = swSelMgr.GetSelectedObject6(1, -1)" one error is showed

                     

                    sorry if my question doesn't smart, i am still beginner in API

                     

                    thank you very much!

                      • Re: tag letter in a table annotation
                        Jacob Corder

                        2017 SOLIDWORKS API Help - IHoleTableAnnotation Interface

                        you need to get SwHoleTableAnnotation From  TableAnnotation.

                         

                        you can just set it SwHoleTableAnnotation = SwTableAnnotation as it is derived from SwTableAnnotation

                         

                        so do this

                         

                        Dim SwHoleTableAnn as holeTableAnnotation

                        Set SwHoleTableAnn = SwSelMgr.GetSelectedObject6(1,-1)

                        Dim SwHoleTable as  holeTable

                        Set SwHoleTable = SwHoleTableAnn.HoleTable

                        • Re: tag letter in a table annotation
                          Jacob Corder

                          also i dont know if you can select the cell using this. "Item de detalhe1305@N"

                           

                          you may need the TableAnnotation Name. maybe someone else can chime in.

                            • Re: tag letter in a table annotation
                              Dionatan Silveira

                              So, unfortunetly it seems not to work.

                               

                              now i select the table with "Set swTable = swView.GetFirstTableAnnotation" in the first view and set the itens follow your explanetion, but in the line "SwHoleTable.HoleTag(1) = "Test1"". nothing change!

                               

                              i think that the solid block it.

                               

                              this sintaxe:

                              >>>> Debug.Print "Original name of tag in column1, row 2:   " & SwHoleTable.HoleTag(1)

                              >>>> SwHoleTable.HoleTag(1) = "Test1"

                              >>>> Debug.Print "New name of tag in column1, row 2:        " & SwHoleTable.HoleTag(1)

                               

                              result it:

                              Original name of tag in column1, row 2:   A

                              New name of tag in column1, row 2:        A

                               

                              in the others cells i can change the values, but this tags no.

                                • Re: tag letter in a table annotation
                                  Jacob Corder

                                  you need to cast the TableAnnotation to a HoleTableAnnotation

                                  Then you can get the HoleTable from The HoleTableAnnotation.GetHoleTable

                                   

                                  Dim SwHoleTableAnn as HoleTableAnnotation

                                  Set SwHoleTableAnn = SwTable

                                  Dim SwHoleTable as holetable

                                  Set SwHoleTable = SwHoleTableAnn.HoleTable

                                   

                                  SwHoleTable.HoleTag(0)= "Test1"

                                   

                                   

                                   

                                  copy your code on your next reply.

                                    • Re: tag letter in a table annotation
                                      Dionatan Silveira

                                      so, this is my code. How you suggest?

                                       

                                      Sub main()

                                          Dim swApp As SldWorks.SldWorks

                                          Dim swModel As SldWorks.ModelDoc2

                                          Dim SwHoleTable As SldWorks.HoleTable

                                          Dim SwTable As SldWorks.HoleTableAnnotation

                                          Dim boolstatus As Boolean

                                          Dim swview As SldWorks.View

                                         

                                          Set swApp = Application.SldWorks

                                          Set swModel = swApp.ActiveDoc

                                          Set swview = swModel.GetFirstView

                                         

                                          Do While Not swview Is Nothing

                                              Set SwTable = swview.GetFirstTableAnnotation

                                              Do While Not SwTable Is Nothing

                                                  Set SwHoleTable = SwTable.HoleTable

                                                            

                                                  Debug.Print "Original name of tag in column1, row 2:   " & SwHoleTable.HoleTag(1)

                                                  SwHoleTable.HoleTag(1) = "Test1"

                                                  Debug.Print "New name of tag in column1, row 2:        " & SwHoleTable.HoleTag(1)

                                                 

                                                  Set SwTable = SwTable.GetNext

                                              Loop

                                              Set swview = swview.GetNextView

                                             

                                          Loop

                                         

                                         

                                      End Sub

                                        • Re: tag letter in a table annotation
                                          Jacob Corder

                                          Sub main()

                                              Dim swApp As SldWorks.SldWorks

                                              Dim swModel As SldWorks.ModelDoc2

                                              Dim SwHoleTable As SldWorks.HoleTable

                                             Dim SwTableAnn as sldworks.TableAnnotation

                                              Dim SwHoleTableAnn As SldWorks.HoleTableAnnotation

                                              Dim boolstatus As Boolean

                                              Dim swview As SldWorks.View

                                            

                                              Set swApp = Application.SldWorks

                                              Set swModel = swApp.ActiveDoc

                                              Set swview = swModel.GetFirstView

                                            

                                              Do While Not swview Is Nothing

                                                  Set SwTableAnn= swview.GetFirstTableAnnotation

                                                  Do While Not SwTableAnn Is Nothing

                                                     Set SwHoleTableAnn= SwTableAnn

                                                      Set SwHoleTable = SwHoleTableAnn.HoleTable

                                                               

                                                      Debug.Print "Original name of tag in column1, row 2:   " & SwHoleTable.HoleTag(1)

                                                      SwHoleTable.HoleTag(1) = "Test1"

                                                      Debug.Print "New name of tag in column1, row 2:        " & SwHoleTable.HoleTag(1)

                                                    

                                                      Set SwTableAnn= SwTableAnn.GetNext

                                                  Loop

                                                  Set swview = swview.GetNextView

                                                

                                              Loop

                                            

                                            

                                          End Sub

                                           

                                          you need to cast to ITableAnnotation

                                          Then to IHoleTableAnnotation

                                          Then to IHoleTable

                                           

                                          bold has changed